Mercurial > public > ostc4
comparison Small_CPU/Src/scheduler.c @ 988:d9290c76b840 GasConsumption
OSTC4/5 joined code:
In the previous version code differences between OSTC4/5 were identified using the ENABLE_GPIO_V2 compiler switch. In the new version this is done using the display version as indicator which OSTC model is in used. Since this is detected by Firmware the information is forwarded from there to the RTE. This causes a little delay in the GPIO initialization but this applies only to the cold start of the RTE which should not happen very often.
| author | ideenmodellierer |
|---|---|
| date | Sun, 06 Apr 2025 21:02:17 +0200 |
| parents | 9b29995d6619 |
| children | c386ae6635e4 |
comparison
equal
deleted
inserted
replaced
| 984:41136649b90d | 988:d9290c76b840 |
|---|---|
| 340 externalInface_SetSensorMap(global.dataSendToSlave.data.externalInterface_SensorMap); | 340 externalInface_SetSensorMap(global.dataSendToSlave.data.externalInterface_SensorMap); |
| 341 if(global.dataSendToSlave.data.externalInterface_Cmd & 0x00FF) /* lowest nibble for commands */ | 341 if(global.dataSendToSlave.data.externalInterface_Cmd & 0x00FF) /* lowest nibble for commands */ |
| 342 { | 342 { |
| 343 externalInterface_ExecuteCmd(global.dataSendToSlave.data.externalInterface_Cmd); | 343 externalInterface_ExecuteCmd(global.dataSendToSlave.data.externalInterface_Cmd); |
| 344 } | 344 } |
| 345 #ifdef ENABLE_GPIO_V2 | 345 |
| 346 GPIO_HandleBuzzer(); | 346 if(GPIO_GetVersion() < global.dataSendToSlave.displayVersion) |
| 347 #endif | 347 { |
| 348 GPIO_Activate_V2(); | |
| 349 } | |
| 350 | |
| 351 if(GPIO_GetVersion() > 0) | |
| 352 { | |
| 353 GPIO_HandleBuzzer(); | |
| 354 } | |
| 348 | 355 |
| 349 | 356 |
| 350 #if 0 | 357 #if 0 |
| 351 //TODO: Temporary placed here. Duration ~210 ms. | 358 //TODO: Temporary placed here. Duration ~210 ms. |
| 352 if (global.I2C_SystemStatus != HAL_OK) { | 359 if (global.I2C_SystemStatus != HAL_OK) { |
| 531 { | 538 { |
| 532 lasttick = HAL_GetTick(); | 539 lasttick = HAL_GetTick(); |
| 533 ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); | 540 ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); |
| 534 | 541 |
| 535 externalInterface_HandleUART(); | 542 externalInterface_HandleUART(); |
| 536 #ifdef ENABLE_GPIO_V2 | 543 #ifdef ENABLE_GNSS_INTERN |
| 537 UART6_HandleUART(); | 544 if(GPIO_GetVersion() > 0) |
| 545 { | |
| 546 UART6_HandleUART(); | |
| 547 } | |
| 538 #endif | 548 #endif |
| 539 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) | 549 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) |
| 540 { | 550 { |
| 541 if(SPI_Evaluate_RX_Data()!=0) /* did we receive something ? */ | 551 if(SPI_Evaluate_RX_Data()!=0) /* did we receive something ? */ |
| 542 { | 552 { |
| 836 if(scheduleSetButtonResponsiveness()) | 846 if(scheduleSetButtonResponsiveness()) |
| 837 setButtonsNow = 0; | 847 setButtonsNow = 0; |
| 838 } | 848 } |
| 839 | 849 |
| 840 externalInterface_HandleUART(); | 850 externalInterface_HandleUART(); |
| 841 #ifdef ENABLE_GPIO_V2 | 851 #ifdef ENABLE_GNSS_INTERN |
| 842 UART6_HandleUART(); | 852 if(GPIO_GetVersion() > 0) |
| 853 { | |
| 854 UART6_HandleUART(); | |
| 855 } | |
| 843 #endif | 856 #endif |
| 844 | 857 |
| 845 /* Evaluate received data at 10 ms, 110 ms, 210 ms,... duration ~<1ms */ | 858 /* Evaluate received data at 10 ms, 110 ms, 210 ms,... duration ~<1ms */ |
| 846 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) | 859 if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) |
| 847 { | 860 { |
| 891 if(ticksdiff >= Scheduler.counterAmbientLight100msec * 100 + 70) | 904 if(ticksdiff >= Scheduler.counterAmbientLight100msec * 100 + 70) |
| 892 { | 905 { |
| 893 adc_ambient_light_sensor_get_data(); | 906 adc_ambient_light_sensor_get_data(); |
| 894 copyAmbientLightData(); | 907 copyAmbientLightData(); |
| 895 | 908 |
| 896 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | 909 #if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN |
| 897 copyGNSSdata(); | 910 copyGNSSdata(); |
| 898 #endif | 911 #endif |
| 899 Scheduler.counterAmbientLight100msec++; | 912 Scheduler.counterAmbientLight100msec++; |
| 900 } | 913 } |
| 901 | 914 |
| 1108 void scheduleSleepMode(void) | 1121 void scheduleSleepMode(void) |
| 1109 { | 1122 { |
| 1110 global.dataSendToMaster.mode = 0; | 1123 global.dataSendToMaster.mode = 0; |
| 1111 global.deviceDataSendToMaster.mode = 0; | 1124 global.deviceDataSendToMaster.mode = 0; |
| 1112 secondsCount = 0; | 1125 secondsCount = 0; |
| 1113 #ifdef ENABLE_GPIO_V2 | 1126 #ifdef ENABLE_GNSS_INTERN |
| 1114 uint16_t deepSleepCntDwn = 21600; /* 12 hours in 2 second steps */ | 1127 uint16_t deepSleepCntDwn = 21600; /* 12 hours in 2 second steps */ |
| 1115 uint8_t deepSleep = 0; | 1128 uint8_t deepSleep = 0; |
| 1116 GPIO_InitTypeDef GPIO_InitStruct; | 1129 GPIO_InitTypeDef GPIO_InitStruct; |
| 1117 #endif | 1130 #endif |
| 1118 /* prevent button wake up problem while in sleep_prepare | 1131 /* prevent button wake up problem while in sleep_prepare |
| 1189 || (global.lifeData.pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR)) | 1202 || (global.lifeData.pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR)) |
| 1190 { | 1203 { |
| 1191 global.mode = MODE_BOOT; | 1204 global.mode = MODE_BOOT; |
| 1192 } | 1205 } |
| 1193 scheduleUpdateLifeData(2000); | 1206 scheduleUpdateLifeData(2000); |
| 1194 #ifdef ENABLE_GPIO_V2 | 1207 #ifdef ENABLE_GNSS_INTER |
| 1195 if(deepSleepCntDwn) | 1208 if(GPIO_GetVersion() > 0) |
| 1196 { | 1209 { |
| 1197 deepSleepCntDwn--; | 1210 if(deepSleepCntDwn) |
| 1198 if(deepSleepCntDwn == 0) | 1211 { |
| 1199 { | 1212 deepSleepCntDwn--; |
| 1200 deepSleep = 1; | 1213 if(deepSleepCntDwn == 0) |
| 1201 GPIO_GPS_OFF(); | 1214 { |
| 1202 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | 1215 deepSleep = 1; |
| 1203 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | 1216 GPIO_GPS_OFF(); |
| 1204 GPIO_InitStruct.Pull = GPIO_NOPULL; | 1217 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
| 1205 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN); | 1218 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
| 1206 HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); | 1219 GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 1207 uartGnss_SetState(UART_GNSS_INIT); | 1220 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN); |
| 1208 } | 1221 HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); |
| 1209 } | 1222 uartGnss_SetState(UART_GNSS_INIT); |
| 1210 else | 1223 } |
| 1211 { | 1224 } |
| 1212 if((deepSleep = 1) && (global.lifeData.battery_voltage < 3.5)) /* switch off backup voltage if battery gets low */ | 1225 else |
| 1213 { | 1226 { |
| 1214 deepSleep = 2; | 1227 if((deepSleep = 1) && (global.lifeData.battery_voltage < 3.5)) /* switch off backup voltage if battery gets low */ |
| 1215 GPIO_GPS_BCKP_OFF(); | 1228 { |
| 1216 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_BCKP_CONTROL_PIN); | 1229 deepSleep = 2; |
| 1217 HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); | 1230 GPIO_GPS_BCKP_OFF(); |
| 1218 __HAL_RCC_GPIOB_CLK_DISABLE(); | 1231 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_BCKP_CONTROL_PIN); |
| 1232 HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); | |
| 1233 __HAL_RCC_GPIOB_CLK_DISABLE(); | |
| 1234 } | |
| 1219 } | 1235 } |
| 1220 } | 1236 } |
| 1221 #endif | 1237 #endif |
| 1222 } | 1238 } |
| 1223 while(global.mode == MODE_SLEEP); | 1239 while(global.mode == MODE_SLEEP); |
| 1225 scheduleUpdateLifeData(-1); | 1241 scheduleUpdateLifeData(-1); |
| 1226 clearDecoNow = 0; | 1242 clearDecoNow = 0; |
| 1227 setButtonsNow = 0; | 1243 setButtonsNow = 0; |
| 1228 reinitGlobals(); | 1244 reinitGlobals(); |
| 1229 ReInit_battery_charger_status_pins(); | 1245 ReInit_battery_charger_status_pins(); |
| 1230 #ifdef ENABLE_GPIO_V2 | 1246 #ifdef ENABLE_GNSS_INTERN |
| 1231 if(deepSleep != 0) | 1247 if(GPIO_GetVersion() > 0) |
| 1232 { | 1248 { |
| 1233 GPIO_GNSS_Init(); | 1249 if(deepSleep != 0) |
| 1250 { | |
| 1251 GPIO_GNSS_Init(); | |
| 1252 } | |
| 1234 } | 1253 } |
| 1235 #endif | 1254 #endif |
| 1236 } | 1255 } |
| 1237 | 1256 |
| 1238 | 1257 |
