Mercurial > public > ostc4
diff Small_CPU/Src/uart.c @ 725:621265ec3d23
Update CO2 sensor implementation:
Some updates were needed to get the CO2 sensor code up and running again (menu handling and UART DMA transfer).
author | Ideenmodellierer |
---|---|
date | Sat, 07 Jan 2023 18:11:52 +0100 |
parents | fceae45b3a69 |
children | d646a0f724a7 |
line wrap: on
line diff
--- a/Small_CPU/Src/uart.c Thu Jan 05 18:30:06 2023 +0100 +++ b/Small_CPU/Src/uart.c Sat Jan 07 18:11:52 2023 +0100 @@ -148,7 +148,8 @@ static receiveState_t rxState = RX_Ready; static uint32_t lastReceiveTick = 0; - while(localRX != rxWriteIndex) + + while((rxBuffer[localRX]!=0)) { lastReceiveTick = HAL_GetTick(); if(rxState == RX_Ready) /* identify data content */ @@ -167,12 +168,20 @@ break; } } - else if((rxState >= RX_Data0) && (rxState <= RX_Data4)) + else if((rxBuffer[localRX] >= '0') && (rxBuffer[localRX] <= '9')) { - if((rxBuffer[localRX] >= '0') && (rxBuffer[localRX] <= '9')) + if((rxState >= RX_Data0) && (rxState <= RX_Data4)) { dataValue = dataValue * 10 + (rxBuffer[localRX] - '0'); rxState++; + if(rxState == RX_Data5) + { + rxState = RX_DataComplete; + } + } + else /* protocol error data has max 5 digits */ + { + rxState = RX_Ready; } } if((rxBuffer[localRX] == ' ') || (rxBuffer[localRX] == '\n')) /* Abort data detection */