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
+ − 40 #define SCHEDULER_TICK_EXE1SEC (980u) /* tick count based on cycle start which is used to trigger functions which */
+ − 41 /* shall be executed once in a second (20ms before cycle restarts) */
+ − 42
763
+ − 43 #define SPI_COM_TIMEOUT_START (5) /* *100 ms timeout to avoid timeout e.g. after Main wakeup */
265
+ − 44 #define SPI_COM_TIMEOUT_COMMON (3) /* *100ms shorter timeout during normal operation to have a faster error reaction */
+ − 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
+ − 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
+ − 90 uint8_t communicationTimeout;
220
+ − 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
+ − 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
+ − 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****/