comparison Small_CPU/Inc/uart.h @ 932:effadaa3a1f7 Evo_2_23

Cleanup Gnss UART implementation: The first draft of the internal UART implementation was just a copy of the external UART handling. To avoid duplicated code and maintainance issue both UARTs (external/internal 6/1) share the same functions. To enable this a control structure has to be used as function input which defines the none shared resources like DMA control and rx/tx buffers
author Ideenmodellierer
date Sat, 07 Dec 2024 21:28:08 +0100
parents 7c996354b8ac
children 3029f0332f4f
comparison
equal deleted inserted replaced
931:5a9bc2e6112d 932:effadaa3a1f7
26 26
27 27
28 #define BUFFER_NODATA_LOW (0x15) /* The read function needs a signiture which indicates that no data for processing is available.*/ 28 #define BUFFER_NODATA_LOW (0x15) /* The read function needs a signiture which indicates that no data for processing is available.*/
29 #define BUFFER_NODATA_HIGH (0xA5) 29 #define BUFFER_NODATA_HIGH (0xA5)
30 30
31 #define TX_BUF_SIZE (40u) /* max length for commands */
32 #define CHUNK_SIZE (80u) /* the DMA will handle chunk size transfers */
33 #define CHUNKS_PER_BUFFER (3u)
34
35 typedef struct
36 {
37 UART_HandleTypeDef* pHandle; /* Pointer to UART handle structure */
38
39 uint8_t* pRxBuffer; /* Pointer to receive buffer */
40 uint8_t* pTxBuffer; /* Pointer to transmit buffer */
41 uint8_t* pTxQue; /* Pointer to transmit que */
42 uint8_t rxWriteIndex ; /* Index of the data item which is analyzed */
43 uint8_t rxReadIndex; /* Index at which new data is stared */
44 uint8_t txBufferQueLen; /* Length of qued data waiting for transmission */
45
46 uint8_t dmaRxActive; /* Indicator if DMA reception needs to be started */
47 uint8_t dmaTxActive; /* Indicator if DMA reception needs to be started */
48
49 } sUartComCtrl;
50
51 extern sUartComCtrl Uart1Ctrl;
31 52
32 UART_HandleTypeDef huart1; 53 UART_HandleTypeDef huart1;
33 54
34 void MX_USART1_UART_Init(void); 55 void MX_USART1_UART_Init(void);
35 void MX_USART1_UART_DeInit(void); 56 void MX_USART1_UART_DeInit(void);
39 void MX_USART6_DMA_Init(void); 60 void MX_USART6_DMA_Init(void);
40 void MX_USART6_UART_DeInit(void); 61 void MX_USART6_UART_DeInit(void);
41 void GNSS_IO_init(void); 62 void GNSS_IO_init(void);
42 63
43 uint8_t UART_ButtonAdjust(uint8_t *array); 64 uint8_t UART_ButtonAdjust(uint8_t *array);
44 void UART_StartDMA_Receiption(void); 65 void UART_StartDMA_Receiption(sUartComCtrl* pUartCtrl);
45 #ifdef ENABLE_CO2_SUPPORT 66 #ifdef ENABLE_CO2_SUPPORT
46 void UART_HandleCO2Data(void); 67 void UART_HandleCO2Data(void);
47 void DigitalCO2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength); 68 void DigitalCO2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength);
48 #endif 69 #endif
49 70
51 void UART_HandleGnssData(void); 72 void UART_HandleGnssData(void);
52 #endif 73 #endif
53 #ifdef ENABLE_SENTINEL_MODE 74 #ifdef ENABLE_SENTINEL_MODE
54 void UART_HandleSentinelData(void); 75 void UART_HandleSentinelData(void);
55 #endif 76 #endif
56 void UART_clearRxBuffer(void); 77 void UART_SetGnssCtrl(sUartComCtrl* pTarget);
78 sUartComCtrl* UART_GetGnssCtrl();
79 void UART_clearRxBuffer(sUartComCtrl* pUartCtrl);
57 uint8_t UART_isCO2Connected(); 80 uint8_t UART_isCO2Connected();
58 uint8_t UART_isSentinelConnected(); 81 uint8_t UART_isSentinelConnected();
59 void UART_setTargetChannel(uint8_t channel); 82 void UART_setTargetChannel(uint8_t channel);
60 void UART_MUX_SelectAddress(uint8_t muxAddress); 83 void UART_MUX_SelectAddress(uint8_t muxAddress);
61 void UART_SendCmdString(uint8_t *cmdString); 84 void UART_SendCmdString(uint8_t *cmdString);
62 void UART_SendCmdUbx(const uint8_t *cmd, uint8_t len); 85 void UART_SendCmdUbx(const uint8_t *cmd, uint8_t len);
63 void UART_ReadData(uint8_t sensorType); 86 void UART_ReadData(uint8_t sensorType);
64 void UART_WriteData(void); 87 void UART_WriteData(sUartComCtrl* pUartCtrl);
65 void UART_FlushRxBuffer(void); 88 void UART_FlushRxBuffer(void);
66 void UART_ChangeBaudrate(uint32_t newBaudrate); 89 void UART_ChangeBaudrate(uint32_t newBaudrate);
67 uint8_t UART_isComActive(uint8_t sensorId); 90 uint8_t UART_isComActive(uint8_t sensorId);
91 uint8_t UART_isEndIndication(sUartComCtrl* pCtrl, uint8_t index);
68 92
69 void StringToInt(char *pstr, uint32_t *puInt32); 93 void StringToInt(char *pstr, uint32_t *puInt32);
70 void StringToUInt64(char *pstr, uint64_t *puint64); 94 void StringToUInt64(char *pstr, uint64_t *puint64);
71 95
72 #ifdef __cplusplus 96 #ifdef __cplusplus