Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 232:f0069f002c55 div-fixes-4-1
Bugfix: make date/time setting work over reboots
Setting the time/date over the UART interface or by the menu, seems
to work, but a reboot of the RTE brings back strange, seemingly
random, time.
The reason for this is rather simple. In the settings, a time
is stored, based on some flawed logic, and that time was restored
on reboot. There is no reason to store any time, when the moment of
restoring it is unrelated in time. So, the fix is simple: do not
set time (in the RTC) based on some time from the past. The whole idea
of a RTC is that it does preserve the time for you, as long its
powered. Any attempt to do things better using stored time data is
futile (and nonsense).
And while working on his, also kick out some useless code from the RTE.
There is no reason to initialize the time on the RTC to some random
time/date in the past. A zero data/time is as good and any random
date.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 03 Apr 2019 21:11:56 +0200 |
parents | e524a824d8f2 |
children | e4207f0aaa4b |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @file scheduler.h | |
4 * @author heinrichs weikamp gmbh | |
5 * @version V0.0.5 | |
6 * @date 27-March-2014 | |
7 * @brief | |
8 * | |
9 ****************************************************************************** | |
10 * @attention | |
11 * | |
12 * <h2><center>© COPYRIGHT(c) 2015 heinrichs weikamp</center></h2> | |
13 * | |
14 ****************************************************************************** | |
15 */ | |
16 | |
17 | |
18 #ifndef SCHEDULER_H | |
19 #define SCHEDULER_H | |
20 | |
21 #ifdef __cplusplus | |
22 extern "C" { | |
23 #endif | |
24 | |
25 | |
26 /* Includes ------------------------------------------------------------------*/ | |
27 #include "data_central.h" | |
28 #include "data_exchange.h" | |
29 #include "settings.h" | |
30 | |
31 /* Types -------------------------------------------------------------*/ | |
32 #define SENSOR_PRESSURE_ID 0 | |
33 #define MAX_SENSORS 1 | |
181 | 34 |
207 | 35 #define SPI_SYNC_METHOD_NONE (0u) |
36 #define SPI_SYNC_METHOD_HARD (1u) /* Scheduler shall reset all counters to 0 */ | |
37 #define SPI_SYNC_METHOD_SOFT (2u) /* Scheduler shall reset adjust counters to 100ms SPI data exchange cycle */ | |
38 #define SPI_SYNC_METHOD_INVALID (4u) | |
39 | |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
40 #define SCHEDULER_TICK_EXE1SEC (980u) /* tick count based on cycle start which is used to trigger functions which */ |
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
41 /* shall be executed once in a second (20ms before cycle restarts) */ |
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
42 |
38 | 43 typedef struct |
44 { | |
45 uint8_t mode; | |
46 short conservatism; | |
47 short repetitive_dive; | |
48 long seconds_since_last_dive; | |
49 long no_fly_time_minutes; | |
50 uint8_t whichGas; | |
51 SGas aktualGas[2]; | |
52 float ceiling_from_main_CPU_mbar; | |
53 SLifeData lifeData; | |
54 SVpm vpm; | |
55 SSettings settings; | |
56 SDevice deviceData; | |
57 SDataExchangeSlaveToMasterDeviceData deviceDataSendToMaster; | |
58 SDataExchangeSlaveToMaster dataSendToMaster; | |
59 SDataReceiveFromMaster dataSendToSlave; | |
60 _Bool demo_mode; | |
61 uint8_t dataSendToSlaveIsValid; | |
62 uint8_t dataSendToSlavePending; | |
88 | 63 uint8_t dataSendToSlaveStopEval; |
38 | 64 uint32_t sync_error_count; |
65 uint32_t check_sync_not_running; | |
66 uint8_t ButtonResponsiveness[4]; | |
67 uint8_t chargerStatus; | |
68 uint8_t dataSendToSlaveIsNotValidCount; | |
69 uint8_t ButtonPICdata[4]; | |
70 uint8_t accidentFlag; | |
71 uint32_t accidentRemainingSeconds; | |
72 uint8_t sensorError[MAX_SENSORS]; | |
73 uint8_t I2C_SystemStatus; | |
74 } SGlobal; | |
75 | |
76 typedef struct | |
77 { | |
78 long seconds_since_last_dive; | |
79 long no_fly_time_minutes; | |
80 } SBackup; | |
81 | |
144 | 82 typedef struct |
83 { | |
84 uint8_t counterSPIdata100msec; | |
85 uint8_t counterPressure100msec; | |
86 uint8_t counterCompass100msec; | |
87 uint8_t counterAmbientLight100msec; | |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
88 uint32_t tick_execute1second; |
144 | 89 uint32_t tickstart; |
90 } SScheduleCtrl; | |
91 | |
92 | |
38 | 93 /* Variables ---------------------------------------------------------*/ |
94 extern SGlobal global; | |
95 | |
96 | |
97 /* Function prototypes -----------------------------------------------*/ | |
98 | |
99 void initGlobals(void); | |
100 | |
101 void scheduleSurfaceMode(void); | |
102 void scheduleDiveMode(void); | |
103 void scheduleSleepMode(void); | |
104 void scheduleCompassCalibrationMode(void); | |
105 void scheduleTestMode(void); | |
106 | |
107 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last); | |
108 void scheduleSpecial_Evaluate_DataSendToSlave(void); | |
109 void scheduleUpdateDeviceDataChargerFull(void); | |
110 void scheduleUpdateDeviceDataChargerCharging(void); | |
111 | |
207 | 112 void Scheduler_Request_sync_with_SPI(uint8_t SyncMethod); |
113 void Scheduler_SyncToSPI(void); | |
114 | |
38 | 115 uint8_t scheduleSetButtonResponsiveness(void); |
116 | |
117 void copyBatteryData(void); | |
118 | |
119 //void scheduleSurfaceMode_test(void); | |
120 //void scheduleSleepMode_test(void); | |
121 | |
122 #ifdef __cplusplus | |
123 } | |
124 #endif | |
125 | |
126 #endif /* SCHEDULER_H */ | |
127 | |
128 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |