diff --git a/code/l452_code/Core/Inc/buff.hpp b/code/l452_code/Core/Inc/buff.hpp index 7fbf9e5..bfaf024 100644 --- a/code/l452_code/Core/Inc/buff.hpp +++ b/code/l452_code/Core/Inc/buff.hpp @@ -2,12 +2,14 @@ #include "packet.hpp" #include "usbd_cdc_if.h" +#include "usart.h" extern uint8_t databank1[1024]; extern uint8_t databank2[1024]; extern uint16_t pos; volatile extern bool usb_ready; +volatile extern bool wb1mmc_ready; // Every time we get a reading add to the active databank if it fits, // if not we switch banks and write out the now unactive databank @@ -23,6 +25,10 @@ void write(packet_type packet) { CDC_Transmit_FS(databank1, sizeof(databank1)); usb_ready = false; } + if (wb1mmc_ready) { + HAL_UART_Transmit_DMA(&huart1, databank1, sizeof(databank1)); + wb1mmc_ready = false; + } memset(databank2, 0, sizeof(databank2)); pos = sizeof(databank1); return write(packet); @@ -37,6 +43,10 @@ void write(packet_type packet) { CDC_Transmit_FS(databank2, sizeof(databank2)); usb_ready = false; } + if (wb1mmc_ready) { + HAL_UART_Transmit_DMA(&huart1, databank2, sizeof(databank2)); + wb1mmc_ready = false; + } memset(databank1, 0, sizeof(databank1)); pos = 0; return write(packet); diff --git a/code/l452_code/Core/Src/main.cpp b/code/l452_code/Core/Src/main.cpp index 160749e..afbea14 100644 --- a/code/l452_code/Core/Src/main.cpp +++ b/code/l452_code/Core/Src/main.cpp @@ -83,9 +83,7 @@ volatile bool usb_ready = false; volatile bool wb1mmc_ready = false; volatile bool print_desc = false; -volatile bool uart_rx_busy = false; uint8_t uart_rx_data[1]; -volatile bool queue_send = false; void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) { if (hadc->Instance == ADC1) { @@ -100,7 +98,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { tim6_reloads += 1; to_recordVbatt = true; to_recordTime = true; - queue_send = true; } } @@ -116,6 +113,7 @@ void USB_CDC_RxHandler(uint8_t* Buf, uint32_t Len) { void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if (uart_rx_data[0] == 'R') { HAL_GPIO_TogglePin(GPIOB, LED1_Pin | LED2_Pin | LED3_Pin); + wb1mmc_ready = true; } HAL_UART_Receive_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data)); } @@ -174,8 +172,8 @@ int main(void) HAL_TIM_Base_Start_IT(&htim6); HAL_UART_Receive_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data)); // For some reason initializing the ads131 first breaks the lsm6dsv gyro readings - //initialize_lsm6dsv(&hspi1); - //initialize_ads131(&hspi1); + initialize_lsm6dsv(&hspi1); + initialize_ads131(&hspi1); while (1) { @@ -217,13 +215,6 @@ int main(void) // CDC_Transmit_FS((uint8_t*) "Not Detected\n\r", 14); // HAL_Delay(10); // } - uint8_t uart_tx_data[1] = {'T'}; - if (queue_send) { - HAL_UART_Transmit_DMA(&huart1, (uint8_t*)uart_tx_data, sizeof(uart_tx_data)); - queue_send = false; - } - - continue; if (print_desc) { data_description(); diff --git a/code/l452_code/Core/Src/usart.c b/code/l452_code/Core/Src/usart.c index e56870b..77d14af 100644 --- a/code/l452_code/Core/Src/usart.c +++ b/code/l452_code/Core/Src/usart.c @@ -41,7 +41,7 @@ void MX_USART1_UART_Init(void) /* USER CODE END USART1_Init 1 */ huart1.Instance = USART1; - huart1.Init.BaudRate = 115200; + huart1.Init.BaudRate = 460800; huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.StopBits = UART_STOPBITS_1; huart1.Init.Parity = UART_PARITY_NONE; diff --git a/code/l452_code/Makefile b/code/l452_code/Makefile index 4629ca3..a2187fa 100644 --- a/code/l452_code/Makefile +++ b/code/l452_code/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [4.9.0-B19] date: [Wed Apr 29 16:32:32 CDT 2026] +# File automatically-generated by tool: [projectgenerator] version: [4.9.0-B19] date: [Thu Apr 30 14:57:20 CDT 2026] ########################################################################################################################## # ------------------------------------------------ diff --git a/code/l452_code/l452_code.ioc b/code/l452_code/l452_code.ioc index a94bb0d..6be7c96 100644 --- a/code/l452_code/l452_code.ioc +++ b/code/l452_code/l452_code.ioc @@ -335,8 +335,9 @@ TIM6.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM6.IPParameters=Prescaler,AutoReloadPreload,Period TIM6.Period=1999 TIM6.Prescaler=39999 +USART1.BaudRate=460800 USART1.DMADisableonRxErrorParam=ADVFEATURE_DMA_ENABLEONRXERROR -USART1.IPParameters=VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam +USART1.IPParameters=VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam,BaudRate USART1.OverrunDisableParam=ADVFEATURE_OVERRUN_ENABLE USART1.VirtualMode-Asynchronous=VM_ASYNC USB.IPParameters=Sof_enable