Revision cda14729 core/inc/aos_system.h
core/inc/aos_system.h | ||
---|---|---|
40 | 40 |
#define AOS_SYSTEM_TIME_RESOLUTION ((MICROSECONDS_PER_SECOND + CH_CFG_ST_FREQUENCY - 1) / CH_CFG_ST_FREQUENCY) |
41 | 41 |
|
42 | 42 |
/** |
43 |
* @brief System event flag which is emitted when a shutdown was initiated.
|
|
43 |
* @brief System event flag mask for shutdown related events.
|
|
44 | 44 |
*/ |
45 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN (eventflags_t)(1 << 0) |
|
45 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK ((eventflags_t)0x1F) |
|
46 |
|
|
47 |
/** |
|
48 |
* @brief System event flag which is emitted when a passive shutdown was initiated. |
|
49 |
*/ |
|
50 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_PASSIVE ((eventflags_t)(1 << 0)) |
|
46 | 51 |
|
47 | 52 |
/** |
48 | 53 |
* @brief System event flag which is emitted when a shutdown to transportation mode was initiated. |
49 | 54 |
*/ |
50 |
#define AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION (AOS_SYSTEM_EVENTFLAGS_SHUTDOWN | (eventflags_t)(1 << 1))
|
|
55 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_TRANSPORTATION ((eventflags_t)(1 << 1))
|
|
51 | 56 |
|
52 | 57 |
/** |
53 | 58 |
* @brief System event flag which is emitted when a shutdown to deepsleep mode was initiated. |
54 | 59 |
*/ |
55 |
#define AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP (AOS_SYSTEM_EVENTFLAGS_SHUTDOWN | (eventflags_t)(1 << 2))
|
|
60 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_DEEPSLEEP ((eventflags_t)(1 << 2))
|
|
56 | 61 |
|
57 | 62 |
/** |
58 | 63 |
* @brief System event flag which is emitted when a shutdown to hibernate mode was initiated. |
59 | 64 |
*/ |
60 |
#define AOS_SYSTEM_EVENTFLAGS_HIBERNATE (AOS_SYSTEM_EVENTFLAGS_SHUTDOWN | (eventflags_t)(1 << 3))
|
|
65 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_HIBERNATE ((eventflags_t)(1 << 3))
|
|
61 | 66 |
|
62 | 67 |
/** |
63 | 68 |
* @brief System event flag which is emitted when a system restart was initiated. |
64 | 69 |
*/ |
65 |
#define AOS_SYSTEM_EVENTFLAGS_RESTART (AOS_SYSTEM_EVENTFLAGS_SHUTDOWN | (eventflags_t)(1 << 4)) |
|
66 |
|
|
67 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
68 |
|
|
69 |
/** |
|
70 |
* @brief Major version of the implemented SSSP. |
|
71 |
*/ |
|
72 |
#define AOS_SYSTEM_SSSP_VERSION_MAJOR 1 |
|
73 |
|
|
74 |
/** |
|
75 |
* @brief Minor version of the implemented SSSP. |
|
76 |
*/ |
|
77 |
#define AOS_SYSTEM_SSSP_VERSION_MINOR 4 |
|
78 |
|
|
79 |
/** |
|
80 |
* @brief Timeout delay according to SSSP. |
|
81 |
* @details SSSP defines timeouts to be ten times longer than the signal delay time. |
|
82 |
*/ |
|
83 |
#define AOS_SYSTEM_SSSP_TIMEOUT (10 * AMIROOS_CFG_SSSP_SIGNALDELAY) |
|
84 |
|
|
85 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
|
70 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_RESTART ((eventflags_t)(1 << 4)) |
|
86 | 71 |
|
87 | 72 |
/******************************************************************************/ |
88 | 73 |
/* SETTINGS */ |
... | ... | |
101 | 86 |
*/ |
102 | 87 |
typedef enum aos_shutdown { |
103 | 88 |
AOS_SHUTDOWN_NONE, /**< Default value if no shutdown action was initiated */ |
89 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
104 | 90 |
AOS_SHUTDOWN_PASSIVE, /**< Passive shutdown (initiated by another module). */ |
91 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
|
92 |
#if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE) || defined (__DOXYGEN__) |
|
93 |
AOS_SHUTDOWN_ACTIVE, /**< Active shutdown. */ |
|
94 |
#endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE) */ |
|
95 |
#if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT) || defined (__DOXYGEN__) |
|
105 | 96 |
AOS_SHUTDOWN_HIBERNATE, /**< Active shutdown to hibernate mode. */ |
106 | 97 |
AOS_SHUTDOWN_DEEPSLEEP, /**< Active shutdown to deepsleep mode. */ |
107 | 98 |
AOS_SHUTDOWN_TRANSPORTATION, /**< Active shutdown to transportation mode. */ |
108 | 99 |
AOS_SHUTDOWN_RESTART, /**< Active saystem restart request. */ |
100 |
#endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT) */ |
|
109 | 101 |
} aos_shutdown_t; |
110 | 102 |
|
111 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
112 |
|
|
113 |
/** |
|
114 |
* @brief Enumerator of the several stages of SSSP. |
|
115 |
*/ |
|
116 |
typedef enum aos_ssspstage { |
|
117 |
AOS_SSSP_STARTUP_1_1 = 0x10, /**< Identifier of SSSP startup phase stage 1-1. */ |
|
118 |
AOS_SSSP_STARTUP_1_2 = 0x11, /**< Identifier of SSSP startup phase stage 1-2. */ |
|
119 |
AOS_SSSP_STARTUP_1_3 = 0x12, /**< Identifier of SSSP startup phase stage 1-3. */ |
|
120 |
AOS_SSSP_STARTUP_2_1 = 0x14, /**< Identifier of SSSP startup phase stage 2-1. */ |
|
121 |
AOS_SSSP_STARTUP_2_2 = 0x15, /**< Identifier of SSSP startup phase stage 2-2. */ |
|
122 |
AOS_SSSP_STARTUP_3_1 = 0x18, /**< Identifier of SSSP startup phase stage 3-1. */ |
|
123 |
AOS_SSSP_STARTUP_3_2 = 0x19, /**< Identifier of SSSP startup phase stage 3-2. */ |
|
124 |
AOS_SSSP_STARTUP_3_3 = 0x1A, /**< Identifier of SSSP startup phase stage 3-3. */ |
|
125 |
AOS_SSSP_STARTUP_3_4 = 0x1B, /**< Identifier of SSSP startup phase stage 3-4. */ |
|
126 |
AOS_SSSP_OPERATION = 0x20, /**< Identifier of SSSP operation pahse. */ |
|
127 |
AOS_SSSP_SHUTDOWN_1_1 = 0x30, /**< Identifier of SSSP shutdown phase stage 1-1. */ |
|
128 |
AOS_SSSP_SHUTDOWN_1_2 = 0x31, /**< Identifier of SSSP shutdown phase stage 1-2. */ |
|
129 |
AOS_SSSP_SHUTDOWN_1_3 = 0x32, /**< Identifier of SSSP shutdown phase stage 1-3. */ |
|
130 |
AOS_SSSP_SHUTDOWN_2_1 = 0x34, /**< Identifier of SSSP shutdown phase stage 2-1. */ |
|
131 |
AOS_SSSP_SHUTDOWN_2_2 = 0x35, /**< Identifier of SSSP shutdown phase stage 2-2. */ |
|
132 |
AOS_SSSP_SHUTDOWN_3 = 0x38, /**< Identifier of SSSP shutdown phase stage 3. */ |
|
133 |
} aos_ssspstage_t; |
|
134 |
|
|
135 |
/** |
|
136 |
* @brief Type to represent module IDs. |
|
137 |
*/ |
|
138 |
typedef uint16_t aos_ssspmoduleid_t; |
|
139 |
|
|
140 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
|
141 |
|
|
142 | 103 |
/** |
143 | 104 |
* @brief AMiRo-OS base system structure. |
144 | 105 |
*/ |
145 | 106 |
typedef struct aos_system { |
146 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
147 |
/** |
|
148 |
* @brief SSSP relevant data. |
|
149 |
*/ |
|
150 |
struct { |
|
151 |
/** |
|
152 |
* @brief Current SSSP stage of the system. |
|
153 |
*/ |
|
154 |
aos_ssspstage_t stage; |
|
155 |
|
|
156 |
/** |
|
157 |
* @brief Module identifier. |
|
158 |
* @details A value of 0 indicates an uninitialized ID. |
|
159 |
* The vlaues 0 and ~0 are reserved und must not be set. |
|
160 |
*/ |
|
161 |
aos_ssspmoduleid_t moduleId; |
|
162 |
} sssp; |
|
163 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
|
164 | 107 |
|
165 | 108 |
/** |
166 | 109 |
* @brief System I/O stream. |
... | ... | |
173 | 116 |
struct { |
174 | 117 |
|
175 | 118 |
/** |
176 |
* @brief I/O event source.
|
|
119 |
* @brief GPIO event source.
|
|
177 | 120 |
*/ |
178 |
event_source_t io; |
|
121 |
event_source_t gpio;
|
|
179 | 122 |
|
180 | 123 |
/** |
181 | 124 |
* @brief OS event source. |
... | ... | |
183 | 126 |
event_source_t os; |
184 | 127 |
} events; |
185 | 128 |
|
186 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
|
|
129 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
187 | 130 |
|
188 | 131 |
/** |
189 | 132 |
* @brief Pointer to the shell object. |
190 | 133 |
*/ |
191 | 134 |
aos_shell_t shell; |
192 | 135 |
|
193 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
|
136 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
|
137 |
|
|
138 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
|
139 |
|
|
140 |
/** |
|
141 |
* @brief SSSP relevant data. |
|
142 |
*/ |
|
143 |
aos_ssspdata_t sssp; |
|
144 |
|
|
145 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
|
194 | 146 |
|
195 | 147 |
} aos_system_t; |
196 | 148 |
|
... | ... | |
217 | 169 |
#if defined(__cplusplus) |
218 | 170 |
extern "C" { |
219 | 171 |
#endif /* defined(__cplusplus) */ |
220 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true)
|
|
172 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
|
|
221 | 173 |
void aosSysInit(const char* shellPrompt); |
222 |
#else /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
|
|
174 |
#else /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
|
223 | 175 |
void aosSysInit(void); |
224 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
|
|
176 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
|
225 | 177 |
void aosSysStart(void); |
226 | 178 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined (__DOXYGEN__) |
227 |
eventmask_t aosSysSsspStartupOsInitSyncCheck(event_listener_t* syncEvtListener);
|
|
179 |
void aosSysStartUptime(void);
|
|
228 | 180 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
229 | 181 |
void aosSysGetUptimeX(aos_timestamp_t* ut); |
230 |
#if (HAL_USE_RTC == TRUE) |
|
182 |
#if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
|
|
231 | 183 |
void aosSysGetDateTime(struct tm* dt); |
232 | 184 |
void aosSysSetDateTime(struct tm* dt); |
233 | 185 |
#endif /* (HAL_USE_RTC == TRUE) */ |
234 | 186 |
void aosSysShutdownInit(aos_shutdown_t shutdown); |
235 | 187 |
void aosSysStop(void); |
236 | 188 |
void aosSysDeinit(void); |
237 |
void aosSysShutdownFinal(aos_shutdown_t shutdown); |
|
238 |
palcallback_t aosSysGetStdExtiCallback(void); |
|
189 |
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_SHUTDOWN != true)) || \ |
|
190 |
((AMIROOS_CFG_SSSP_ENABLE != true) && (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)) || \ |
|
191 |
defined(__DOXYGEN__) |
|
192 |
void aosSysShutdownToBootloader(aos_shutdown_t shutdown); |
|
193 |
#endif /* ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_SHUTDOWN != true)) || ((AMIROOS_CFG_SSSP_ENABLE != true) && (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)) */ |
|
194 |
palcallback_t aosSysGetStdGpioCallback(void); |
|
239 | 195 |
#if defined(__cplusplus) |
240 | 196 |
} |
241 | 197 |
#endif /* defined(__cplusplus) */ |
Also available in: Unified diff