Mercurial > public > ostc4
diff 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 |
line wrap: on
line diff
--- a/Small_CPU/Inc/uart.h Tue Dec 03 20:32:51 2024 +0100 +++ b/Small_CPU/Inc/uart.h Sat Dec 07 21:28:08 2024 +0100 @@ -28,6 +28,27 @@ #define BUFFER_NODATA_LOW (0x15) /* The read function needs a signiture which indicates that no data for processing is available.*/ #define BUFFER_NODATA_HIGH (0xA5) +#define TX_BUF_SIZE (40u) /* max length for commands */ +#define CHUNK_SIZE (80u) /* the DMA will handle chunk size transfers */ +#define CHUNKS_PER_BUFFER (3u) + + typedef struct + { + UART_HandleTypeDef* pHandle; /* Pointer to UART handle structure */ + + uint8_t* pRxBuffer; /* Pointer to receive buffer */ + uint8_t* pTxBuffer; /* Pointer to transmit buffer */ + uint8_t* pTxQue; /* Pointer to transmit que */ + uint8_t rxWriteIndex ; /* Index of the data item which is analyzed */ + uint8_t rxReadIndex; /* Index at which new data is stared */ + uint8_t txBufferQueLen; /* Length of qued data waiting for transmission */ + + uint8_t dmaRxActive; /* Indicator if DMA reception needs to be started */ + uint8_t dmaTxActive; /* Indicator if DMA reception needs to be started */ + + } sUartComCtrl; + +extern sUartComCtrl Uart1Ctrl; UART_HandleTypeDef huart1; @@ -41,7 +62,7 @@ void GNSS_IO_init(void); uint8_t UART_ButtonAdjust(uint8_t *array); -void UART_StartDMA_Receiption(void); +void UART_StartDMA_Receiption(sUartComCtrl* pUartCtrl); #ifdef ENABLE_CO2_SUPPORT void UART_HandleCO2Data(void); void DigitalCO2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength); @@ -53,7 +74,9 @@ #ifdef ENABLE_SENTINEL_MODE void UART_HandleSentinelData(void); #endif -void UART_clearRxBuffer(void); +void UART_SetGnssCtrl(sUartComCtrl* pTarget); +sUartComCtrl* UART_GetGnssCtrl(); +void UART_clearRxBuffer(sUartComCtrl* pUartCtrl); uint8_t UART_isCO2Connected(); uint8_t UART_isSentinelConnected(); void UART_setTargetChannel(uint8_t channel); @@ -61,10 +84,11 @@ void UART_SendCmdString(uint8_t *cmdString); void UART_SendCmdUbx(const uint8_t *cmd, uint8_t len); void UART_ReadData(uint8_t sensorType); -void UART_WriteData(void); +void UART_WriteData(sUartComCtrl* pUartCtrl); void UART_FlushRxBuffer(void); void UART_ChangeBaudrate(uint32_t newBaudrate); uint8_t UART_isComActive(uint8_t sensorId); +uint8_t UART_isEndIndication(sUartComCtrl* pCtrl, uint8_t index); void StringToInt(char *pstr, uint32_t *puInt32); void StringToUInt64(char *pstr, uint64_t *puint64);
