annotate Small_CPU/Inc/scheduler.h @ 392:b57f497726f7 ImproveBluetooth

Bugfix negativ ascend bar: Due to floating <> int conversion a value < 1 will result in a small bar in negativ direction if close to surface => display only ascend rates > 1m per minute
author ideenmodellierer
date Tue, 26 Nov 2019 18:13:26 +0100
parents a91d99265884
children aa6006975e76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file scheduler.h
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V0.0.5
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 27-March-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 #ifndef SCHEDULER_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 #define SCHEDULER_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 extern "C" {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 #include "data_central.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 #include "data_exchange.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 #include "settings.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 /* Types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #define SENSOR_PRESSURE_ID 0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #define MAX_SENSORS 1
181
331882a89421 Removed not suppoted wireless feature
ideenmodellierer
parents: 148
diff changeset
34
207
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
35 #define SPI_SYNC_METHOD_NONE (0u)
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
36 #define SPI_SYNC_METHOD_HARD (1u) /* Scheduler shall reset all counters to 0 */
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
37 #define SPI_SYNC_METHOD_SOFT (2u) /* Scheduler shall reset adjust counters to 100ms SPI data exchange cycle */
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
38 #define SPI_SYNC_METHOD_INVALID (4u)
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
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
265
a91d99265884 Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents: 264
diff changeset
43 #define SPI_COM_TIMEOUT_START (5) /* *100 ms timeout to avoid tiemout e.g. after Main wakeup */
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 uint8_t mode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 short conservatism;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 short repetitive_dive;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 long seconds_since_last_dive;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 long no_fly_time_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 uint8_t whichGas;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 SGas aktualGas[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 float ceiling_from_main_CPU_mbar;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 SLifeData lifeData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 SVpm vpm;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 SSettings settings;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 SDevice deviceData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 SDataExchangeSlaveToMasterDeviceData deviceDataSendToMaster;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 SDataExchangeSlaveToMaster dataSendToMaster;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 SDataReceiveFromMaster dataSendToSlave;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 _Bool demo_mode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 uint8_t dataSendToSlaveIsValid;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 uint8_t dataSendToSlavePending;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 uint32_t sync_error_count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 uint32_t check_sync_not_running;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 uint8_t ButtonResponsiveness[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 uint8_t chargerStatus;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 uint8_t dataSendToSlaveIsNotValidCount;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 uint8_t ButtonPICdata[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 uint8_t accidentFlag;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 uint32_t accidentRemainingSeconds;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 } SGlobal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 long seconds_since_last_dive;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 long no_fly_time_minutes;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 } SBackup;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83
144
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
84 typedef struct
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
85 {
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
86 uint8_t counterSPIdata100msec;
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
87 uint8_t counterPressure100msec;
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
88 uint8_t counterCompass100msec;
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
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
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
92 uint32_t tickstart;
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
93 } SScheduleCtrl;
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
94
6b83ca1225de Use one global structure for schedule data
Ideenmodellierer
parents: 88
diff changeset
95
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 /* Variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 extern SGlobal global;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 /* Function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 void scheduleSurfaceMode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 void scheduleDiveMode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 void scheduleSleepMode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 void scheduleCompassCalibrationMode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 void scheduleTestMode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 void scheduleSpecial_Evaluate_DataSendToSlave(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 void scheduleUpdateDeviceDataChargerFull(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 void scheduleUpdateDeviceDataChargerCharging(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
207
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
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
b95741467355 Introduce scheduler function
ideenmodellierer
parents: 181
diff changeset
118
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 uint8_t scheduleSetButtonResponsiveness(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 void copyBatteryData(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 //void scheduleSurfaceMode_test(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 //void scheduleSleepMode_test(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 #endif /* SCHEDULER_H */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/