# HG changeset patch # User Ideenmodellierer # Date 1673111512 -3600 # Node ID 621265ec3d2370931270b3f62cef4c8fecd86f5c # Parent f285424f04d9a68dbdb99a72dfd367947c3247bc Update CO2 sensor implementation: Some updates were needed to get the CO2 sensor code up and running again (menu handling and UART DMA transfer). diff -r f285424f04d9 -r 621265ec3d23 Discovery/Src/tMenuEditXtra.c --- a/Discovery/Src/tMenuEditXtra.c Thu Jan 05 18:30:06 2023 +0100 +++ b/Discovery/Src/tMenuEditXtra.c Sat Jan 07 18:11:52 2023 +0100 @@ -319,6 +319,9 @@ static void openEdit_CO2Sensor() { char text[32]; + + resetMenuEdit(CLUT_MenuPageXtra); + snprintf(text,32,"\001%c",TXT_CO2Sensor); write_topline(text); diff -r f285424f04d9 -r 621265ec3d23 Small_CPU/Src/scheduler.c --- a/Small_CPU/Src/scheduler.c Thu Jan 05 18:30:06 2023 +0100 +++ b/Small_CPU/Src/scheduler.c Sat Jan 07 18:11:52 2023 +0100 @@ -516,7 +516,7 @@ ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); #ifdef ENABLE_CO2_SUPPORT - if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_SENTINEL) + if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_CO2) { HandleUARTCO2Data(); } @@ -838,7 +838,7 @@ } #ifdef ENABLE_CO2_SUPPORT - if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_SENTINEL) + if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_CO2) { HandleUARTCO2Data(); } diff -r f285424f04d9 -r 621265ec3d23 Small_CPU/Src/uart.c --- 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 */