Mercurial > public > ostc4
changeset 1036:5865f0aeb438 Puls_Integration
Radio data integration:
Added functionality for displaying radio data as debug message. The USART3 has been configurated for receiption and a function for the visualization of the data has been added to the demo unit (draft implementation). For activation the radio as well as the logger functionality needs to be activated via compile switch. Note that at the moment bluetooth and radio DMA may not be operated in parallel.
| author | Ideenmodellierer |
|---|---|
| date | Sun, 10 Aug 2025 15:28:59 +0200 |
| parents | 5b913cdaa9dc |
| children | 2af07aa38531 |
| files | Common/Inc/configuration.h Discovery/Inc/demo.h Discovery/Inc/ostc.h Discovery/Inc/ostc_hw2.h Discovery/Inc/tInfoLogger.h Discovery/Src/base.c Discovery/Src/demo.c Discovery/Src/ostc.c Discovery/Src/stm32f4xx_hal_msp_hw2.c Discovery/Src/tInfoLogger.c |
| diffstat | 10 files changed, 181 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Common/Inc/configuration.h Sat Aug 09 16:55:20 2025 +0200 +++ b/Common/Inc/configuration.h Sun Aug 10 15:28:59 2025 +0200 @@ -97,10 +97,15 @@ #define ENABLE_FAST_COMM /* Enable to have support of Polar HC10 heartbeat sensor active */ -#define ENABLE_PULSE_SENSOR_BT +/* #define ENABLE_PULSE_SENSOR_BT */ /* Enable RTE sleep mode debugging */ /* #define ENABLE_SLEEP_DEBUG */ +/* Enable to receive data from the radio connection usart */ +#define ENABLE_USART_RADIO + +/* Enable to show messages which are den during runtime in a popup window */ +#define ENABLE_LOGGER_WINDOW #endif
--- a/Discovery/Inc/demo.h Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Inc/demo.h Sun Aug 10 15:28:59 2025 +0200 @@ -35,4 +35,6 @@ void demoConfigureSettings(void); void demoSendCommand(uint8_t action); +void demo_HandleData(void); + #endif // DEMO_H
--- a/Discovery/Inc/ostc.h Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Inc/ostc.h Sun Aug 10 15:28:59 2025 +0200 @@ -110,7 +110,14 @@ uint8_t isNewDisplay(void); uint8_t UART_getChar(); + +#ifdef ENABLE_PULSE_SENSOR_BT void UART_StartDMARx(); +#endif +#ifdef ENABLE_USART_RADIO +void MX_UART_RADIO_Init_DMA(); +void UART_StartDMARxRadio(); +#endif #endif // OSTC_H
--- a/Discovery/Inc/ostc_hw2.h Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Inc/ostc_hw2.h Sun Aug 10 15:28:59 2025 +0200 @@ -167,6 +167,22 @@ #define USART_IR_HUD_IRQn USART2_IRQn // to it directly#define USART_IR_HUD_IRQHandler USART2_IRQHandler +#define USART_RADIO USART3 +#define USART_RADIO_CLK_ENABLE() __USART3_CLK_ENABLE(); +#define USART_RADIO_FORCE_RESET() __USART3_FORCE_RESET() +#define USART_RADIO_RELEASE_RESET() __USART3_RELEASE_RESET() +//#define USART_IR_HUD_TX_AF GPIO_AF7_USART3 +//#define USART_IR_HUD_TX_PIN GPIO_PIN_5 +//#define USART_IR_HUD_TX_GPIO_PORT GPIOD +//#define USART_IR_HUD_TX_GPIO_CLK_ENABLE() __GPIOD_CLK_ENABLE() + +#define USART_RADIO_RX_AF GPIO_AF7_USART3 +#define USART_RADIO_RX_PIN GPIO_PIN_11 +#define USART_RADIO_RX_GPIO_PORT GPIOB +#define USART_RADIO_RX_GPIO_CLK_ENABLE() __GPIOB_CLK_ENABLE() +#define USART_RADIO_IRQn USART3_IRQn + + #define TIMx TIM4 #define TIMx_CLK_ENABLE __TIM4_CLK_ENABLE #define TIMx_IRQn TIM4_IRQn
--- a/Discovery/Inc/tInfoLogger.h Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Inc/tInfoLogger.h Sun Aug 10 15:28:59 2025 +0200 @@ -35,6 +35,8 @@ #define LOG_TX_LINE (0u) #define LOG_RX_LINE (1u) +#include "gfx_engine.h" + /* Exported functions --------------------------------------------------------*/ void openInfo_Logger(); void refreshInfo_Logger(GFX_DrawCfgScreen s);
--- a/Discovery/Src/base.c Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Src/base.c Sun Aug 10 15:28:59 2025 +0200 @@ -245,6 +245,9 @@ static void TIM_DEMO_init(void); #endif +#ifdef ENABLE_USART_RADIO +#include "demo.h" +#endif //#include "lodepng.h" //#include <stdlib.h> // for malloc and free @@ -532,6 +535,10 @@ #ifdef ENABLE_PULSE_SENSOR_BT cv_heartbeat_HandleData(); #endif + +#ifdef ENABLE_USART_RADIO + demo_HandleData(); +#endif if(DoHousekeeping) { DoHousekeeping = housekeepingFrame();
--- a/Discovery/Src/demo.c Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Src/demo.c Sun Aug 10 15:28:59 2025 +0200 @@ -28,6 +28,8 @@ #include "data_exchange_main.h" // for time_elapsed_ms() #include "settings.h" #include "ostc.h" +#include "tInfoLogger.h" +#include <string.h> #ifndef DEMOMODE @@ -425,5 +427,62 @@ #endif // DEMO +#ifdef ENABLE_USART_RADIO /* debug function to check receiption of radio data */ +void demo_HandleData(void) +{ + static uint8_t comStarted = 0; + static uint8_t text[50]; + static uint8_t index = 0; + static uint32_t startTick = 0; + static uint8_t firstData = 1; + uint8_t data = 0; + + switch(comStarted) + { + case 0: startTick = HAL_GetTick(); + comStarted++; + break; + case 1: if(time_elapsed_ms(startTick, HAL_GetTick()) > 5000) + { + MX_UART_RADIO_Init_DMA(); + UART_StartDMARxRadio(); + comStarted++; + sprintf((char*)text,"RadioStarted"); + InfoLogger_writeLine(text,strlen((char*)text),1); + } + break; + case 2: data = UART_getChar(); + if(data != 0) + { + if(firstData) + { + firstData = 0; + sprintf((char*)text,"FirstData"); + InfoLogger_writeLine(text,strlen((char*)text),1); + } + if((index == 50) || (data =='r') || (data =='n')) + { + if(index > 0) + { + InfoLogger_writeLine(text,index,0); + index = 0; + } + } + else + { + text[index++] = data; + } + } + break; + default: + break; + } + + + { + } +} +#endif + /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
--- a/Discovery/Src/ostc.c Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Src/ostc.c Sun Aug 10 15:28:59 2025 +0200 @@ -47,6 +47,10 @@ #endif UART_HandleTypeDef UartIR_HUD_Handle; +#ifdef ENABLE_USART_RADIO +UART_HandleTypeDef UartRadio_Handle; +#endif + __IO ITStatus UartReady = RESET; __IO ITStatus UartReadyHUD = RESET; @@ -57,6 +61,14 @@ /* Private variables with external access via get_xxx() function -------------*/ static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) +#ifdef ENABLE_PULSE_SENSOR_BT +static DMA_HandleTypeDef hdma_uart_BT_rx; +#endif + +#ifdef ENABLE_USART_RADIO +static DMA_HandleTypeDef hdma_uart_radio_rx; +#endif + static uint16_t rxBufRead = 0; static uint16_t rxBufWrite = 0; static uint8_t rxBufferUart[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */ @@ -385,10 +397,22 @@ HAL_UART_Init(&UartIR_HUD_Handle); #endif + +#ifdef ENABLE_USART_RADIO + UartRadio_Handle.Instance = USART_RADIO; + UartRadio_Handle.Init.BaudRate = 9600; + UartRadio_Handle.Init.WordLength = UART_WORDLENGTH_8B; + UartRadio_Handle.Init.StopBits = UART_STOPBITS_1; + UartRadio_Handle.Init.Parity = UART_PARITY_NONE; + UartRadio_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE; + UartRadio_Handle.Init.Mode = UART_MODE_RX; + + HAL_UART_Init(&UartRadio_Handle); +#endif + } -static DMA_HandleTypeDef hdma_uart_BT_rx; - +#ifdef ENABLE_PULSE_SENSOR_BT void MX_UART_BT_Init_DMA() { @@ -412,6 +436,33 @@ HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn); } +#endif + +#ifdef ENABLE_USART_RADIO +void MX_UART_RADIO_Init_DMA() +{ + + __DMA2_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + + hdma_uart_radio_rx.Instance = DMA2_Stream1; + hdma_uart_radio_rx.Init.Channel = DMA_CHANNEL_4; + hdma_uart_radio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_uart_radio_rx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_uart_radio_rx.Init.MemInc = DMA_MINC_ENABLE; + hdma_uart_radio_rx.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_uart_radio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_uart_radio_rx.Init.Mode = DMA_NORMAL; + hdma_uart_radio_rx.Init.Priority = DMA_PRIORITY_LOW; + hdma_uart_radio_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + HAL_DMA_Init(&hdma_uart_radio_rx); + + __HAL_LINKDMA(&UartRadio_Handle, hdmarx, hdma_uart_radio_rx); + + HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); +} +#endif uint8_t UART_getChar() @@ -429,7 +480,7 @@ } return retChar; } - +#ifdef ENABLE_PULSE_SENSOR_BT void UART_StartDMARx() { HAL_UART_Receive_DMA (&UartHandle, &rxBufferUart[rxBufWrite], CHUNK_SIZE); @@ -439,11 +490,28 @@ rxBufWrite = 0; } } - void DMA2_Stream2_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_uart_BT_rx); } +#endif + +#ifdef ENABLE_USART_RADIO +void UART_StartDMARxRadio() +{ + HAL_UART_Receive_DMA (&UartRadio_Handle, &rxBufferUart[rxBufWrite], CHUNK_SIZE); + rxBufWrite += CHUNK_SIZE; + if(rxBufWrite >= CHUNK_SIZE * CHUNKS_PER_BUFFER) + { + rxBufWrite = 0; + } +} + +void DMA2_Stream2_IRQHandler(void) +{ + HAL_DMA_IRQHandler(&hdma_uart_radio_rx); +} +#endif void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
--- a/Discovery/Src/stm32f4xx_hal_msp_hw2.c Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Src/stm32f4xx_hal_msp_hw2.c Sun Aug 10 15:28:59 2025 +0200 @@ -630,18 +630,20 @@ /* USER CODE END USART3_MspInit 0 */ /* Peripheral clock enable */ - __USART3_CLK_ENABLE(); + USART_RADIO_RX_GPIO_CLK_ENABLE(); /**USART3 GPIO Configuration - PC10 ------> USART3_TX - PC11 ------> USART3_RX + PB11 ------> USART3_RX */ - GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11; + GPIO_InitStruct.Pin = USART_RADIO_RX_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; - GPIO_InitStruct.Alternate = GPIO_AF7_USART3; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Alternate = USART_RADIO_RX_AF; + HAL_GPIO_Init(USART_RADIO_RX_GPIO_PORT, &GPIO_InitStruct); + + HAL_NVIC_SetPriority(USART_RADIO_IRQn, 0, 1); + HAL_NVIC_EnableIRQ(USART_RADIO_IRQn); /* USER CODE BEGIN USART3_MspInit 1 */ @@ -706,7 +708,7 @@ PC10 ------> USART3_TX PC11 ------> USART3_RX */ - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11); + HAL_GPIO_DeInit(USART_RADIO_RX_GPIO_PORT, USART_RADIO_RX_PIN); /* USER CODE BEGIN USART3_MspDeInit 1 */
--- a/Discovery/Src/tInfoLogger.c Sat Aug 09 16:55:20 2025 +0200 +++ b/Discovery/Src/tInfoLogger.c Sun Aug 10 15:28:59 2025 +0200 @@ -35,7 +35,7 @@ #include "tInfoLogger.h" #include "tMenuEdit.h" #include "data_exchange_main.h" -#include "t7.h"" +#include "t7.h" #include <string.h> #include <inttypes.h>
