Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 933:43055e069bd1 Evo_2_23
UART Gnss: Added fletcher calculation:
Communication is verified using the Fletcher check. In the example code the commands were har coded including the check bytes. To make definition of new commands easier the check bytes are now calculated at runtime. This may be referted to hardcoded values once the implementation is getting a mature state.
author | Ideenmodellierer |
---|---|
date | Sun, 08 Dec 2024 17:38:16 +0100 |
parents | aa6006975e76 |
children |
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 |
763
aa6006975e76
increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents:
265
diff
changeset
|
43 #define SPI_COM_TIMEOUT_START (5) /* *100 ms timeout to avoid timeout e.g. after Main wakeup */ |
265
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
44 #define SPI_COM_TIMEOUT_COMMON (3) /* *100ms shorter timeout during normal operation to have a faster error reaction */ |
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
45 |
38 | 46 typedef struct |
47 { | |
48 uint8_t mode; | |
49 short conservatism; | |
50 short repetitive_dive; | |
51 long seconds_since_last_dive; | |
52 long no_fly_time_minutes; | |
53 uint8_t whichGas; | |
54 SGas aktualGas[2]; | |
55 float ceiling_from_main_CPU_mbar; | |
56 SLifeData lifeData; | |
57 SVpm vpm; | |
58 SSettings settings; | |
59 SDevice deviceData; | |
60 SDataExchangeSlaveToMasterDeviceData deviceDataSendToMaster; | |
61 SDataExchangeSlaveToMaster dataSendToMaster; | |
62 SDataReceiveFromMaster dataSendToSlave; | |
63 _Bool demo_mode; | |
64 uint8_t dataSendToSlaveIsValid; | |
65 uint8_t dataSendToSlavePending; | |
66 uint32_t sync_error_count; | |
67 uint32_t check_sync_not_running; | |
68 uint8_t ButtonResponsiveness[4]; | |
69 uint8_t chargerStatus; | |
70 uint8_t dataSendToSlaveIsNotValidCount; | |
71 uint8_t ButtonPICdata[4]; | |
72 uint8_t accidentFlag; | |
73 uint32_t accidentRemainingSeconds; | |
74 uint8_t sensorError[MAX_SENSORS]; | |
241
2b9775f71e30
cleanup: factor out I2C1_Status() and cleanup type
Jan Mulder <jlmulder@xs4all.nl>
parents:
239
diff
changeset
|
75 HAL_StatusTypeDef I2C_SystemStatus; |
38 | 76 } SGlobal; |
77 | |
78 typedef struct | |
79 { | |
80 long seconds_since_last_dive; | |
81 long no_fly_time_minutes; | |
82 } SBackup; | |
83 | |
144 | 84 typedef struct |
85 { | |
86 uint8_t counterSPIdata100msec; | |
87 uint8_t counterPressure100msec; | |
88 uint8_t counterCompass100msec; | |
89 uint8_t counterAmbientLight100msec; | |
265
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
90 uint8_t communicationTimeout; |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
91 uint32_t tick_execute1second; |
144 | 92 uint32_t tickstart; |
93 } SScheduleCtrl; | |
94 | |
95 | |
38 | 96 /* Variables ---------------------------------------------------------*/ |
97 extern SGlobal global; | |
98 | |
99 | |
100 /* Function prototypes -----------------------------------------------*/ | |
101 | |
102 void initGlobals(void); | |
264
b3685fbada3b
Sync to Main 100ms time stamp & added Reinitialization of globals after startup
ideenmodellierer
parents:
241
diff
changeset
|
103 void reinitGlobals(void); |
38 | 104 |
105 void scheduleSurfaceMode(void); | |
106 void scheduleDiveMode(void); | |
107 void scheduleSleepMode(void); | |
108 void scheduleCompassCalibrationMode(void); | |
109 void scheduleTestMode(void); | |
110 | |
111 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last); | |
112 void scheduleSpecial_Evaluate_DataSendToSlave(void); | |
113 void scheduleUpdateDeviceDataChargerFull(void); | |
114 void scheduleUpdateDeviceDataChargerCharging(void); | |
115 | |
207 | 116 void Scheduler_Request_sync_with_SPI(uint8_t SyncMethod); |
264
b3685fbada3b
Sync to Main 100ms time stamp & added Reinitialization of globals after startup
ideenmodellierer
parents:
241
diff
changeset
|
117 void Scheduler_SyncToSPI(uint8_t TXtick); |
207 | 118 |
38 | 119 uint8_t scheduleSetButtonResponsiveness(void); |
120 | |
121 void copyBatteryData(void); | |
122 | |
123 //void scheduleSurfaceMode_test(void); | |
124 //void scheduleSleepMode_test(void); | |
125 | |
126 #ifdef __cplusplus | |
127 } | |
128 #endif | |
129 | |
130 #endif /* SCHEDULER_H */ | |
131 | |
132 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |