Mercurial > public > ostc4
comparison Small_CPU/Src/uart.c @ 1077:bd8ab302ef4a Icon_Integration
Added uart support for HUD:
the protocol implementation for the HUD has been added. It may be activated by the compile switch ENABLE_HUD_SUPPORT. Because the HUD will not mapped to the three classic o2 value display slots, the sensor data structure has been increased to the max number of devices => all devices may now raise device specific data.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 02 Mar 2026 17:22:25 +0100 |
| parents | 1f2067cad41b |
| children |
comparison
equal
deleted
inserted
replaced
| 1076:c87753e73eb8 | 1077:bd8ab302ef4a |
|---|---|
| 22 #include "uart.h" | 22 #include "uart.h" |
| 23 #include "uartProtocol_O2.h" | 23 #include "uartProtocol_O2.h" |
| 24 #include "uartProtocol_Co2.h" | 24 #include "uartProtocol_Co2.h" |
| 25 #include "uartProtocol_Sentinel.h" | 25 #include "uartProtocol_Sentinel.h" |
| 26 #include "uartProtocol_GNSS.h" | 26 #include "uartProtocol_GNSS.h" |
| 27 #include "uartProtocol_HUD.h" | |
| 27 #include "externalInterface.h" | 28 #include "externalInterface.h" |
| 28 #include "data_exchange.h" | 29 #include "data_exchange.h" |
| 29 #include "gpio.h" | 30 #include "gpio.h" |
| 30 #include <string.h> /* memset */ | 31 #include <string.h> /* memset */ |
| 31 | 32 |
| 197 Uart1Ctrl.txBufferQueLen = 4; | 198 Uart1Ctrl.txBufferQueLen = 4; |
| 198 } | 199 } |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 | 202 |
| 202 | 203 void UART_SendCmdRaw(const uint8_t *cmd, uint8_t cmdLength) |
| 203 void UART_SendCmdString(uint8_t *cmdString) | 204 { |
| 204 { | |
| 205 uint8_t cmdLength = strlen((char*)cmdString); | |
| 206 | |
| 207 if(Uart1Ctrl.dmaTxActive == 0) | 205 if(Uart1Ctrl.dmaTxActive == 0) |
| 208 { | 206 { |
| 209 if(cmdLength < TX_BUF_SIZE) /* A longer string is an indication for a missing 0 termination */ | 207 if(cmdLength < TX_BUF_SIZE) /* A longer string is an indication for a missing 0 termination */ |
| 210 { | 208 { |
| 211 if(Uart1Ctrl.dmaRxActive == 0) | 209 if(Uart1Ctrl.dmaRxActive == 0) |
| 212 { | 210 { |
| 213 UART_StartDMA_Receiption(&Uart1Ctrl); | 211 UART_StartDMA_Receiption(&Uart1Ctrl); |
| 214 } | 212 } |
| 215 memcpy(txBuffer, cmdString, cmdLength); | 213 memcpy(txBuffer, cmd, cmdLength); |
| 216 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,cmdLength)) | 214 if(HAL_OK == HAL_UART_Transmit_DMA(&huart1,txBuffer,cmdLength)) |
| 217 { | 215 { |
| 218 Uart1Ctrl.dmaTxActive = 1; | 216 Uart1Ctrl.dmaTxActive = 1; |
| 219 LastCmdRequestTick = HAL_GetTick(); | 217 LastCmdRequestTick = HAL_GetTick(); |
| 220 } | 218 } |
| 221 } | 219 } |
| 222 } | 220 } |
| 223 else | 221 else |
| 224 { | 222 { |
| 225 memcpy(txBufferQue, cmdString, cmdLength); | 223 memcpy(txBufferQue, cmd, cmdLength); |
| 226 Uart1Ctrl.txBufferQueLen = cmdLength; | 224 Uart1Ctrl.txBufferQueLen = cmdLength; |
| 227 } | 225 } |
| 226 } | |
| 227 | |
| 228 void UART_SendCmdString(uint8_t *cmdString) | |
| 229 { | |
| 230 uint8_t cmdLength = strlen((char*)cmdString); | |
| 231 | |
| 232 UART_SendCmdRaw(cmdString, cmdLength); | |
| 228 } | 233 } |
| 229 | 234 |
| 230 void UART_AddFletcher(uint8_t* pBuffer, uint8_t length) | 235 void UART_AddFletcher(uint8_t* pBuffer, uint8_t length) |
| 231 { | 236 { |
| 232 uint8_t ck_A = 0; | 237 uint8_t ck_A = 0; |
| 457 #endif | 462 #endif |
| 458 #ifdef ENABLE_SENTINEL_MODE | 463 #ifdef ENABLE_SENTINEL_MODE |
| 459 case SENSOR_SENTINEL: uartSentinel_ProcessData(pUartCtrl->pRxBuffer[localRX]); | 464 case SENSOR_SENTINEL: uartSentinel_ProcessData(pUartCtrl->pRxBuffer[localRX]); |
| 460 break; | 465 break; |
| 461 #endif | 466 #endif |
| 467 #ifdef ENABLE_HUD_SUPPORT | |
| 468 case SENSOR_HUD: uartHUD_ProcessData(pUartCtrl->pRxBuffer[localRX]); | |
| 469 break; | |
| 470 #endif | |
| 462 default: | 471 default: |
| 463 break; | 472 break; |
| 464 } | 473 } |
| 465 } | 474 } |
| 466 if(localRX % 2) | 475 if(localRX % 2) |
