From f9a850b7477ba273e0caa3d55df2fa825804bd72 Mon Sep 17 00:00:00 2001 From: Local user Date: Mon, 8 Jun 2026 19:03:10 -0600 Subject: [PATCH 1/3] handle irc tramp msg from canbus --- CommunicationSystemsSubmodule | 2 +- Components/Communication/CANMessageHandler.cpp | 10 ++++++++++ Components/PeriphTasks/CameraTask.cpp | 11 +++++++++++ Components/PeriphTasks/Inc/CameraTask.hpp | 3 ++- Core/Src/main.c | 6 +++--- RPB.ioc | 8 ++++++-- SoarDrivers | 2 +- SoarOS | 2 +- 8 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CommunicationSystemsSubmodule b/CommunicationSystemsSubmodule index 8a5b492..df4e123 160000 --- a/CommunicationSystemsSubmodule +++ b/CommunicationSystemsSubmodule @@ -1 +1 @@ -Subproject commit 8a5b49256d9879b661437f2cf52fd4e2d7ddd614 +Subproject commit df4e1239a4470632f1339133de7ac1fe27f974b1 diff --git a/Components/Communication/CANMessageHandler.cpp b/Components/Communication/CANMessageHandler.cpp index 0069489..840fd8b 100644 --- a/Components/Communication/CANMessageHandler.cpp +++ b/Components/Communication/CANMessageHandler.cpp @@ -65,5 +65,15 @@ bool CANTask::HandleCANCommands() { } } + { + RPB_IRCTRAMP_SET_COMMAND cmd; + if(dau.ReadMessageByLogIndex(_RPB_IRCTRAMP_SET_COMMAND_LOGINDEX, (uint8_t*)&cmd,sizeof(cmd))) { + SOAR_PRINT("got irc tramp cmd\n"); + Command cm = {TASK_SPECIFIC_COMMAND,CAMERA_COMMAND_IRC_TRAMP}; + cm.CopyDataToCommand((uint8_t*)&cmd, sizeof(cmd)); + CameraTask::Inst().SendCommandReference(cm); + } + } + return foundone; }; diff --git a/Components/PeriphTasks/CameraTask.cpp b/Components/PeriphTasks/CameraTask.cpp index 0bcd5b3..b9b712b 100644 --- a/Components/PeriphTasks/CameraTask.cpp +++ b/Components/PeriphTasks/CameraTask.cpp @@ -239,6 +239,17 @@ void CameraTask::HandleCommand(Command &cm) } break; } + case CAMERA_COMMAND_IRC_TRAMP: { + RPB_IRCTRAMP_SET_COMMAND cmd = *(RPB_IRCTRAMP_SET_COMMAND*)cm.GetDataPointer(); + if(cmd.setFreq) { + IRCTramp::SetVTXFrequency(cmd.freq, UART5); + osDelay(10); + } + if(cmd.setPower) { + IRCTramp::SetVTXPower(cmd.power, UART5); + } + break; + } default: SOAR_PRINT("CameraTask - Received Unsupported Task Command {%d}\n", cm.GetTaskCommand()); break; diff --git a/Components/PeriphTasks/Inc/CameraTask.hpp b/Components/PeriphTasks/Inc/CameraTask.hpp index 5f7ffc3..9369e62 100644 --- a/Components/PeriphTasks/Inc/CameraTask.hpp +++ b/Components/PeriphTasks/Inc/CameraTask.hpp @@ -27,7 +27,8 @@ enum CAMERA_TASK_COMMANDS CAMERA_COMMAND_START_RECORDING, CAMERA_COMMAND_STOP_RECORDING, CAMERA_COMMAND_POWER_ON, - CAMERA_COMMAND_POWER_OFF + CAMERA_COMMAND_POWER_OFF, + CAMERA_COMMAND_IRC_TRAMP }; /* Macros ------------------------------------------------------------------*/ diff --git a/Core/Src/main.c b/Core/Src/main.c index ba4f2ee..9c765a5 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -530,7 +530,7 @@ static void MX_UART5_Init(void) /* USER CODE END UART5_Init 1 */ USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; + USART_InitStruct.BaudRate = 9600; USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; USART_InitStruct.StopBits = LL_USART_STOPBITS_1; USART_InitStruct.Parity = LL_USART_PARITY_NONE; @@ -827,11 +827,11 @@ static void MX_SPI2_Init(void) hspi2.Instance = SPI2; hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_2LINES; - hspi2.Init.DataSize = SPI_DATASIZE_4BIT; + hspi2.Init.DataSize = SPI_DATASIZE_8BIT; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; - hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; diff --git a/RPB.ioc b/RPB.ioc index 36d88e7..f05d09e 100644 --- a/RPB.ioc +++ b/RPB.ioc @@ -337,14 +337,18 @@ RCC.VCOInputFreq_Value=16000000 RCC.VCOOutputFreq_Value=160000000 SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1 SH.S_TIM3_CH1.ConfNb=1 -SPI2.CalculateBaudRate=20.0 MBits/s +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +SPI2.CalculateBaudRate=2.5 MBits/s +SPI2.DataSize=SPI_DATASIZE_8BIT SPI2.Direction=SPI_DIRECTION_2LINES -SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler SPI2.Mode=SPI_MODE_MASTER SPI2.VirtualType=VM_MASTER TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM3.IPParameters=Channel-PWM Generation1 CH1,Prescaler TIM3.Prescaler=16 +UART5.BaudRate=9600 +UART5.IPParameters=BaudRate USART1.IPParameters=VirtualMode-Asynchronous USART1.VirtualMode-Asynchronous=VM_ASYNC USART2.IPParameters=VirtualMode-Asynchronous diff --git a/SoarDrivers b/SoarDrivers index 119ce34..7159239 160000 --- a/SoarDrivers +++ b/SoarDrivers @@ -1 +1 @@ -Subproject commit 119ce34fcdb2c0691e7554ae856ffe577bbad0b8 +Subproject commit 71592395942b3c479df63631292875e255f1e39e diff --git a/SoarOS b/SoarOS index b11ec63..426c1ef 160000 --- a/SoarOS +++ b/SoarOS @@ -1 +1 @@ -Subproject commit b11ec637d2dc5fdc4858dda280bf777e947a828c +Subproject commit 426c1efe895bb58ba2a57ea128c9aad642e9be9f From add43846194c3e631031b1ee744178fc4c9c1fea Mon Sep 17 00:00:00 2001 From: Local user Date: Mon, 8 Jun 2026 19:51:01 -0600 Subject: [PATCH 2/3] add camera button presses to init --- Components/PeriphTasks/CameraTask.cpp | 12 ++++++++++++ SoarDrivers | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Components/PeriphTasks/CameraTask.cpp b/Components/PeriphTasks/CameraTask.cpp index b9b712b..5842ff1 100644 --- a/Components/PeriphTasks/CameraTask.cpp +++ b/Components/PeriphTasks/CameraTask.cpp @@ -77,6 +77,18 @@ void CameraTask::Run(void *pvParams) osdDriver.OSD_WriteCustomCharacter(0xE3, callsign_tile_3); osdDriver.OSD_WriteCustomCharacter(0xE4, callsign_tile_4); + for (uint8_t cam = 0; cam < 3; cam++) { + Command startRec = {TASK_SPECIFIC_COMMAND,CAMERA_COMMAND_START_RECORDING}; + startRec.CopyDataToCommand(&cam, sizeof(cam)); + qEvtQueue->Send(startRec); + + } + + // Take cameras out of weird useless usb mode + RunCamCommand(USART1, 0x01); + RunCamCommand(USART2, 0x01); + RunCamCommand(USART3, 0x01); + while (1) { /* Process commands */ diff --git a/SoarDrivers b/SoarDrivers index 7159239..f8ed3ba 160000 --- a/SoarDrivers +++ b/SoarDrivers @@ -1 +1 @@ -Subproject commit 71592395942b3c479df63631292875e255f1e39e +Subproject commit f8ed3ba7c6b90ecd2a3c24916e28a4542f567056 From fe8d9192a0ef7d210edcddfb09ca60286e35d0ca Mon Sep 17 00:00:00 2001 From: Local user Date: Mon, 8 Jun 2026 20:23:31 -0600 Subject: [PATCH 3/3] separated out cam control --- Components/PeriphTasks/CameraTask.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Components/PeriphTasks/CameraTask.cpp b/Components/PeriphTasks/CameraTask.cpp index 9ec8bc5..0bd3120 100644 --- a/Components/PeriphTasks/CameraTask.cpp +++ b/Components/PeriphTasks/CameraTask.cpp @@ -79,19 +79,6 @@ void CameraTask::Run(void *pvParams) osdDriver.OSD_WriteCustomCharacter(0xE4, callsign_tile_4); - for (uint8_t cam = 0; cam < 3; cam++) { - Command startRec = {TASK_SPECIFIC_COMMAND,CAMERA_COMMAND_START_RECORDING}; - startRec.CopyDataToCommand(&cam, sizeof(cam)); - qEvtQueue->Send(startRec); - - } - - // Take cameras out of u-disk mode - RunCamCommand(USART1, 0x01); - RunCamCommand(USART2, 0x01); - RunCamCommand(USART3, 0x01); - - muxDriver.Enable(); muxDriver.Select(Camera::CAMERA2);