Mercurial > public > ostc4
comparison Small_CPU/Src/scheduler.c @ 475:4b000e2386c2 Improve_Button_Sleep
Changed default values:
Invalid pressure was signalled using the float 100.0 causing the OSTC to enter dive mode if for some I2C communication was disturbed during startup.
The default value for button responsitivness was set to 85% without considering the needed HWOS transformation calculation. Applying that the value for 85% is 51
PowerOnReset is state is now identified using the same functionality as already introduced for the battery charge handling.
Initialization of pressure sensor in case of I2C problems only if the initialization was not successfull before:
The pressure sensor is reset via a I2C commend in case of a I2C error. A reset might be helpfull in case of a "hanging" ADC operation but that would not be indicated by a I2C problem => resetting the sensor in case of a I2C problem might cause (small) change of pressure value
author | ideenmodellierer |
---|---|
date | Tue, 12 May 2020 22:52:05 +0200 |
parents | 6886aeeca454 |
children | 9eeab3fead8f |
comparison
equal
deleted
inserted
replaced
474:4be72d55b09a | 475:4b000e2386c2 |
---|---|
43 #include "tm_stm32f4_otp.h" | 43 #include "tm_stm32f4_otp.h" |
44 | 44 |
45 /* uncomment to enable restoting of last known date in case of a power loss (RTC looses timing data) */ | 45 /* uncomment to enable restoting of last known date in case of a power loss (RTC looses timing data) */ |
46 /* #define RESTORE_LAST_KNOWN_DATE */ | 46 /* #define RESTORE_LAST_KNOWN_DATE */ |
47 | 47 |
48 #define INVALID_PREASURE_VALUE (100.0f) | 48 #define INVALID_PREASURE_VALUE (0.0f) |
49 #define START_DIVE_MOUNTAIN_MODE_BAR (0.88f) | 49 #define START_DIVE_MOUNTAIN_MODE_BAR (0.88f) |
50 #define START_DIVE_IMMEDIATLY_BAR (1.16f) | 50 #define START_DIVE_IMMEDIATLY_BAR (1.16f) |
51 | 51 |
52 /* Private types -------------------------------------------------------------*/ | 52 /* Private types -------------------------------------------------------------*/ |
53 const SGas Air = {79,0,0,0,0}; | 53 const SGas Air = {79,0,0,0,0}; |
108 global.conservatism = 0; | 108 global.conservatism = 0; |
109 global.whichGas = 0; | 109 global.whichGas = 0; |
110 global.aktualGas[0] = Air; | 110 global.aktualGas[0] = Air; |
111 global.lifeData.actualGas = global.aktualGas[0]; | 111 global.lifeData.actualGas = global.aktualGas[0]; |
112 | 112 |
113 const uint8_t button_standard_sensitivity = 85; | 113 const uint8_t button_standard_sensitivity = 51; /* 51 equals a percentage of 85% which was the default value before */ |
114 global.ButtonResponsiveness[0] = button_standard_sensitivity; | 114 global.ButtonResponsiveness[0] = button_standard_sensitivity; |
115 global.ButtonResponsiveness[1] = button_standard_sensitivity; | 115 global.ButtonResponsiveness[1] = button_standard_sensitivity; |
116 global.ButtonResponsiveness[2] = button_standard_sensitivity; | 116 global.ButtonResponsiveness[2] = button_standard_sensitivity; |
117 global.ButtonResponsiveness[3] = button_standard_sensitivity; | 117 global.ButtonResponsiveness[3] = button_standard_sensitivity; |
118 | 118 |
136 | 136 |
137 global.dataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH;; | 137 global.dataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH;; |
138 global.dataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW;; | 138 global.dataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW;; |
139 global.dataSendToMaster.chargeStatus = 0; | 139 global.dataSendToMaster.chargeStatus = 0; |
140 | 140 |
141 global.dataSendToMaster.power_on_reset = 1; | 141 global.dataSendToMaster.power_on_reset = 0; |
142 global.dataSendToMaster.header.checkCode[0] = 0xA1; | 142 global.dataSendToMaster.header.checkCode[0] = 0xA1; |
143 global.dataSendToMaster.header.checkCode[1] = SPI_RX_STATE_OFFLINE; | 143 global.dataSendToMaster.header.checkCode[1] = SPI_RX_STATE_OFFLINE; |
144 global.dataSendToMaster.header.checkCode[2] = 0xA3; | 144 global.dataSendToMaster.header.checkCode[2] = 0xA3; |
145 global.dataSendToMaster.header.checkCode[3] = 0xA4; | 145 global.dataSendToMaster.header.checkCode[3] = 0xA4; |
146 global.dataSendToMaster.footer.checkCode[3] = 0xE4; | 146 global.dataSendToMaster.footer.checkCode[3] = 0xE4; |
154 | 154 |
155 global.deviceDataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH; | 155 global.deviceDataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH; |
156 global.deviceDataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW; | 156 global.deviceDataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW; |
157 global.deviceDataSendToMaster.chargeStatus = 0; | 157 global.deviceDataSendToMaster.chargeStatus = 0; |
158 | 158 |
159 global.deviceDataSendToMaster.power_on_reset = 1; | 159 global.deviceDataSendToMaster.power_on_reset = 0; |
160 global.deviceDataSendToMaster.header.checkCode[0] = 0xDF; | 160 global.deviceDataSendToMaster.header.checkCode[0] = 0xDF; |
161 global.deviceDataSendToMaster.header.checkCode[1] = 0xDE; | 161 global.deviceDataSendToMaster.header.checkCode[1] = 0xDE; |
162 global.deviceDataSendToMaster.header.checkCode[2] = 0xDD; | 162 global.deviceDataSendToMaster.header.checkCode[2] = 0xDD; |
163 global.deviceDataSendToMaster.header.checkCode[3] = 0xDC; | 163 global.deviceDataSendToMaster.header.checkCode[3] = 0xDC; |
164 global.deviceDataSendToMaster.footer.checkCode[3] = 0xE4; | 164 global.deviceDataSendToMaster.footer.checkCode[3] = 0xE4; |
1030 secondsCount += 2; | 1030 secondsCount += 2; |
1031 | 1031 |
1032 MX_I2C1_Init(); | 1032 MX_I2C1_Init(); |
1033 pressure_sensor_get_pressure_raw(); | 1033 pressure_sensor_get_pressure_raw(); |
1034 | 1034 |
1035 /* check if I2C is not up an running and try to reactivate if necessary. Also do initialization if problem occurred during startup */ | 1035 /* check if I2C is not up and running and try to reactivate if necessary. Also do initialization if problem occurred during startup */ |
1036 if(global.I2C_SystemStatus != HAL_OK) | 1036 if(global.I2C_SystemStatus != HAL_OK) |
1037 { | 1037 { |
1038 MX_I2C1_TestAndClear(); | 1038 MX_I2C1_TestAndClear(); |
1039 MX_I2C1_Init(); | 1039 MX_I2C1_Init(); |
1040 if(global.I2C_SystemStatus == HAL_OK) | 1040 |
1041 if((global.I2C_SystemStatus == HAL_OK) && (!is_init_pressure_done())) | |
1041 { | 1042 { |
1042 init_pressure(); | 1043 init_pressure(); |
1043 } | 1044 } |
1044 } | 1045 } |
1045 | 1046 |