Revision 6b53f6bf
modules/DiWheelDrive_1-1/aosconf.h | ||
---|---|---|
28 | 28 |
|
29 | 29 |
#include <stdbool.h> |
30 | 30 |
|
31 |
/*===========================================================================*/ |
|
32 |
/** |
|
33 |
* @name Kernel parameters and options |
|
34 |
* @{ |
|
35 |
*/ |
|
36 |
/*===========================================================================*/ |
|
37 |
|
|
38 | 31 |
/* |
39 | 32 |
* Include an external configuration file to override the following default settings only if required. |
40 | 33 |
*/ |
... | ... | |
42 | 35 |
#include <osconf.h> |
43 | 36 |
#endif |
44 | 37 |
|
38 |
/*===========================================================================*/ |
|
45 | 39 |
/** |
46 |
* @brief Flag to set the module as SSSP master. |
|
47 |
*/ |
|
48 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
49 |
#define AMIROOS_CFG_SSSP_MASTER false |
|
50 |
#else |
|
51 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
52 |
#endif |
|
53 |
|
|
54 |
/** |
|
55 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
56 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
57 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
40 |
* @name Kernel parameters and options |
|
41 |
* @{ |
|
58 | 42 |
*/ |
59 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
60 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
61 |
#else |
|
62 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
63 |
#endif |
|
43 |
/*===========================================================================*/ |
|
64 | 44 |
|
65 | 45 |
/** |
66 | 46 |
* @brief Flag to enable/disable debug API. |
... | ... | |
103 | 83 |
|
104 | 84 |
/*===========================================================================*/ |
105 | 85 |
/** |
86 |
* @name SSSP (Startup Shutdown Synchronization Protocol) configuration. |
|
87 |
* @{ |
|
88 |
*/ |
|
89 |
/*===========================================================================*/ |
|
90 |
|
|
91 |
/** |
|
92 |
* @brief Flag to set the module as SSSP master. |
|
93 |
* @details There must be only one module with this flag set to true in a system. |
|
94 |
*/ |
|
95 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
96 |
#define AMIROOS_CFG_SSSP_MASTER false |
|
97 |
#else |
|
98 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
99 |
#endif |
|
100 |
|
|
101 |
/** |
|
102 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
103 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
104 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
105 |
*/ |
|
106 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
107 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
108 |
#else |
|
109 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
110 |
#endif |
|
111 |
|
|
112 |
/** @} */ |
|
113 |
|
|
114 |
/*===========================================================================*/ |
|
115 |
/** |
|
106 | 116 |
* @name System shell options |
107 | 117 |
* @{ |
108 | 118 |
*/ |
modules/DiWheelDrive_1-1/module.c | ||
---|---|---|
36 | 36 |
(void)extp; |
37 | 37 |
|
38 | 38 |
chSysLockFromISR(); |
39 |
chEvtBroadcastFlagsI(&aos.events.io.source, (1 << channel));
|
|
39 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel)); |
|
40 | 40 |
chSysUnlockFromISR(); |
41 | 41 |
|
42 | 42 |
return; |
... | ... | |
297 | 297 |
*/ |
298 | 298 |
/*===========================================================================*/ |
299 | 299 |
|
300 |
apalControlGpio_t moduleSsspPd = { |
|
300 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
301 |
const char* moduleShellPrompt = "DiWheelDrive"; |
|
302 |
#endif |
|
303 |
|
|
304 |
/** @} */ |
|
305 |
|
|
306 |
/*===========================================================================*/ |
|
307 |
/** |
|
308 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
309 |
* @{ |
|
310 |
*/ |
|
311 |
/*===========================================================================*/ |
|
312 |
|
|
313 |
|
|
314 |
apalControlGpio_t moduleSsspGpioPd = { |
|
301 | 315 |
/* GPIO */ &moduleGpioSysPd, |
302 | 316 |
/* meta */ { |
303 | 317 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
306 | 320 |
}, |
307 | 321 |
}; |
308 | 322 |
|
309 |
apalControlGpio_t moduleSsspSync = { |
|
323 |
apalControlGpio_t moduleSsspGpioSync = {
|
|
310 | 324 |
/* GPIO */ &moduleGpioSysSync, |
311 | 325 |
/* meta */ { |
312 | 326 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
315 | 329 |
}, |
316 | 330 |
}; |
317 | 331 |
|
318 |
const char* moduleShellPrompt = "DiWheelDrive"; |
|
319 |
|
|
320 | 332 |
/** @} */ |
321 | 333 |
|
322 | 334 |
/*===========================================================================*/ |
... | ... | |
497 | 509 |
} |
498 | 510 |
static ut_hmc5883ldata_t _utHmc5883lData = { |
499 | 511 |
/* HMC driver */ &moduleLldCompass, |
500 |
/* event source */ &aos.events.io.source,
|
|
512 |
/* event source */ &aos.events.io, |
|
501 | 513 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_COMPASSDRDY), |
502 | 514 |
/* timeout */ MICROSECONDS_PER_SECOND, |
503 | 515 |
}; |
... | ... | |
553 | 565 |
static ut_l3g4200ddata_t _utL3g4200dData = { |
554 | 566 |
/* driver */ &moduleLldGyroscope, |
555 | 567 |
/* SPI configuration */ &moduleHalSpiGyroscopeConfig, |
556 |
/* event source */ &aos.events.io.source,
|
|
568 |
/* event source */ &aos.events.io, |
|
557 | 569 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_GYRODRDY), |
558 | 570 |
}; |
559 | 571 |
aos_unittest_t moduleUtAlldL3g4200d = { |
... | ... | |
602 | 614 |
static ut_lis331dlhdata_t _utLis331dlhData = { |
603 | 615 |
/* driver */ &moduleLldAccelerometer, |
604 | 616 |
/* SPI configuration */ &moduleHalSpiAccelerometerConfig, |
605 |
/* event source */ &aos.events.io.source,
|
|
617 |
/* event source */ &aos.events.io, |
|
606 | 618 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_ACCELINT), |
607 | 619 |
}; |
608 | 620 |
aos_unittest_t moduleUtAlldLis331dlh = { |
... | ... | |
758 | 770 |
static ut_vcnl4020data_t _utVcnl4020Data = { |
759 | 771 |
/* driver */ &moduleLldProximity, |
760 | 772 |
/* timeout */ MICROSECONDS_PER_SECOND, |
761 |
/* event source */ &aos.events.io.source,
|
|
773 |
/* event source */ &aos.events.io, |
|
762 | 774 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_IRINT), |
763 | 775 |
}; |
764 | 776 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
modules/DiWheelDrive_1-1/module.h | ||
---|---|---|
342 | 342 |
*/ |
343 | 343 |
#define MODULE_OS_IOEVENTFLAGS_ACCELINT ((eventflags_t)(1 << MODULE_GPIO_EXTCHANNEL_ACCELINT)) |
344 | 344 |
|
345 |
/** |
|
346 |
* @brief PD signal for SSSP. |
|
347 |
*/ |
|
348 |
extern apalControlGpio_t moduleSsspPd; |
|
349 |
|
|
350 |
/** |
|
351 |
* @brief SYNC signal for SSSP. |
|
352 |
*/ |
|
353 |
extern apalControlGpio_t moduleSsspSync; |
|
354 |
|
|
345 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
355 | 346 |
/** |
356 | 347 |
* @brief Shell prompt text. |
357 | 348 |
*/ |
358 | 349 |
extern const char* moduleShellPrompt; |
350 |
#endif |
|
359 | 351 |
|
360 | 352 |
/** |
361 | 353 |
* @brief Additional HAL initialization hook. |
... | ... | |
369 | 361 |
*/ |
370 | 362 |
#define MODULE_INIT_TESTS() { \ |
371 | 363 |
/* add unit-test shell commands */ \ |
372 |
aosShellAddCommand(aos.shell, &moduleUtAlldA3906.shellcmd); \
|
|
373 |
aosShellAddCommand(aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
374 |
aosShellAddCommand(aos.shell, &moduleUtAlldHmc5883l.shellcmd); \
|
|
375 |
aosShellAddCommand(aos.shell, &moduleUtAlldIna219.shellcmd); \
|
|
376 |
aosShellAddCommand(aos.shell, &moduleUtAlldL3g4200d.shellcmd); \
|
|
377 |
aosShellAddCommand(aos.shell, &moduleUtAlldLed.shellcmd); \
|
|
378 |
aosShellAddCommand(aos.shell, &moduleUtAlldLis331dlh.shellcmd); \
|
|
379 |
aosShellAddCommand(aos.shell, &moduleUtAlldLtc4412.shellcmd); \
|
|
380 |
aosShellAddCommand(aos.shell, &moduleUtAlldPca9544a.shellcmd); \
|
|
381 |
aosShellAddCommand(aos.shell, &moduleUtAlldTps62113.shellcmd); \
|
|
382 |
aosShellAddCommand(aos.shell, &moduleUtAlldVcnl4020.shellcmd); \
|
|
364 |
aosShellAddCommand(&aos.shell, &moduleUtAlldA3906.shellcmd); \
|
|
365 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
366 |
aosShellAddCommand(&aos.shell, &moduleUtAlldHmc5883l.shellcmd); \
|
|
367 |
aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \
|
|
368 |
aosShellAddCommand(&aos.shell, &moduleUtAlldL3g4200d.shellcmd); \
|
|
369 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \
|
|
370 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLis331dlh.shellcmd); \
|
|
371 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLtc4412.shellcmd); \
|
|
372 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \
|
|
373 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \
|
|
374 |
aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \
|
|
383 | 375 |
} |
384 | 376 |
|
385 | 377 |
/** |
... | ... | |
409 | 401 |
} |
410 | 402 |
|
411 | 403 |
/** |
412 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
413 |
*/ |
|
414 |
#define MODULE_SSP_STARTUP_OUTRO_IO_EVENT(mask, flags) { \ |
|
415 |
/* ignore all events */ \ |
|
416 |
(void)mask; \ |
|
417 |
(void)flags; \ |
|
418 |
} |
|
419 |
|
|
420 |
/** |
|
421 | 404 |
* @brief Periphery communication interface deinitialization hook. |
422 | 405 |
*/ |
423 | 406 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \ |
... | ... | |
438 | 421 |
|
439 | 422 |
/*===========================================================================*/ |
440 | 423 |
/** |
424 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
425 |
* @{ |
|
426 |
*/ |
|
427 |
/*===========================================================================*/ |
|
428 |
|
|
429 |
/** |
|
430 |
* @brief PD signal GPIO. |
|
431 |
*/ |
|
432 |
extern apalControlGpio_t moduleSsspGpioPd; |
|
433 |
|
|
434 |
/** |
|
435 |
* @brief SYNC signal GPIO. |
|
436 |
*/ |
|
437 |
extern apalControlGpio_t moduleSsspGpioSync; |
|
438 |
|
|
439 |
/** |
|
440 |
* @brief Event flags for PD signal events. |
|
441 |
*/ |
|
442 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD |
|
443 |
|
|
444 |
/** |
|
445 |
* @brief Event flags for Sync signal events. |
|
446 |
*/ |
|
447 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC |
|
448 |
|
|
449 |
/** |
|
450 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
451 |
*/ |
|
452 |
#define MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK(mask, flags) { \ |
|
453 |
/* ignore all events */ \ |
|
454 |
(void)mask; \ |
|
455 |
(void)flags; \ |
|
456 |
} |
|
457 |
|
|
458 |
/** @} */ |
|
459 |
|
|
460 |
/*===========================================================================*/ |
|
461 |
/** |
|
441 | 462 |
* @name Low-level drivers |
442 | 463 |
* @{ |
443 | 464 |
*/ |
modules/LightRing_1-0/aosconf.h | ||
---|---|---|
28 | 28 |
|
29 | 29 |
#include <stdbool.h> |
30 | 30 |
|
31 |
/*===========================================================================*/ |
|
32 |
/** |
|
33 |
* @name Kernel parameters and options |
|
34 |
* @{ |
|
35 |
*/ |
|
36 |
/*===========================================================================*/ |
|
37 |
|
|
38 | 31 |
/* |
39 | 32 |
* Include an external configuration file to override the following default settings only if required. |
40 | 33 |
*/ |
... | ... | |
42 | 35 |
#include <osconf.h> |
43 | 36 |
#endif |
44 | 37 |
|
38 |
/*===========================================================================*/ |
|
45 | 39 |
/** |
46 |
* @brief Flag to set the module as SSSP master. |
|
47 |
*/ |
|
48 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
49 |
#define AMIROOS_CFG_SSSP_MASTER false |
|
50 |
#else |
|
51 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
52 |
#endif |
|
53 |
|
|
54 |
/** |
|
55 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
56 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
57 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
40 |
* @name Kernel parameters and options |
|
41 |
* @{ |
|
58 | 42 |
*/ |
59 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
60 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
61 |
#else |
|
62 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
63 |
#endif |
|
43 |
/*===========================================================================*/ |
|
64 | 44 |
|
65 | 45 |
/** |
66 | 46 |
* @brief Flag to enable/disable debug API. |
... | ... | |
103 | 83 |
|
104 | 84 |
/*===========================================================================*/ |
105 | 85 |
/** |
86 |
* @name SSSP (Startup Shutdown Synchronization Protocol) configuration. |
|
87 |
* @{ |
|
88 |
*/ |
|
89 |
/*===========================================================================*/ |
|
90 |
|
|
91 |
/** |
|
92 |
* @brief Flag to set the module as SSSP master. |
|
93 |
* @details There must be only one module with this flag set to true in a system. |
|
94 |
*/ |
|
95 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
96 |
#define AMIROOS_CFG_SSSP_MASTER false |
|
97 |
#else |
|
98 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
99 |
#endif |
|
100 |
|
|
101 |
/** |
|
102 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
103 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
104 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
105 |
*/ |
|
106 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
107 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
108 |
#else |
|
109 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
110 |
#endif |
|
111 |
|
|
112 |
/** @} */ |
|
113 |
|
|
114 |
/*===========================================================================*/ |
|
115 |
/** |
|
106 | 116 |
* @name System shell options |
107 | 117 |
* @{ |
108 | 118 |
*/ |
modules/LightRing_1-0/module.c | ||
---|---|---|
36 | 36 |
(void)extp; |
37 | 37 |
|
38 | 38 |
chSysLockFromISR(); |
39 |
chEvtBroadcastFlagsI(&aos.events.io.source, (1 << channel));
|
|
39 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel)); |
|
40 | 40 |
chSysUnlockFromISR(); |
41 | 41 |
|
42 | 42 |
return; |
... | ... | |
219 | 219 |
*/ |
220 | 220 |
/*===========================================================================*/ |
221 | 221 |
|
222 |
apalControlGpio_t moduleSsspPd = { |
|
222 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
223 |
const char* moduleShellPrompt = "LightRing"; |
|
224 |
#endif |
|
225 |
|
|
226 |
/** @} */ |
|
227 |
|
|
228 |
/*===========================================================================*/ |
|
229 |
/** |
|
230 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
231 |
* @{ |
|
232 |
*/ |
|
233 |
/*===========================================================================*/ |
|
234 |
|
|
235 |
apalControlGpio_t moduleSsspGpioPd = { |
|
223 | 236 |
/* GPIO */ &moduleGpioSysPd, |
224 | 237 |
/* meta */ { |
225 | 238 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
228 | 241 |
}, |
229 | 242 |
}; |
230 | 243 |
|
231 |
apalControlGpio_t moduleSsspSync = { |
|
244 |
apalControlGpio_t moduleSsspGpioSync = {
|
|
232 | 245 |
/* GPIO */ &moduleGpioSysSync, |
233 | 246 |
/* meta */ { |
234 | 247 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
237 | 250 |
}, |
238 | 251 |
}; |
239 | 252 |
|
240 |
const char* moduleShellPrompt = "LightRing"; |
|
241 |
|
|
242 | 253 |
/** @} */ |
243 | 254 |
|
244 | 255 |
/*===========================================================================*/ |
modules/LightRing_1-0/module.h | ||
---|---|---|
215 | 215 |
*/ |
216 | 216 |
#define MODULE_OS_IOEVENTFLAGS_SYSSYNC ((eventflags_t)(1 << MODULE_GPIO_EXTCHANNEL_SYSSYNC)) |
217 | 217 |
|
218 |
/** |
|
219 |
* @brief PD signal for SSSP. |
|
220 |
*/ |
|
221 |
extern apalControlGpio_t moduleSsspPd; |
|
222 |
|
|
223 |
/** |
|
224 |
* @brief SYNC signal for SSSP. |
|
225 |
*/ |
|
226 |
extern apalControlGpio_t moduleSsspSync; |
|
227 |
|
|
218 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
228 | 219 |
/** |
229 | 220 |
* @brief Shell prompt text. |
230 | 221 |
*/ |
231 | 222 |
extern const char* moduleShellPrompt; |
223 |
#endif |
|
232 | 224 |
|
233 | 225 |
/** |
234 | 226 |
* @brief Unit test initialization hook. |
235 | 227 |
*/ |
236 | 228 |
#define MODULE_INIT_TESTS() { \ |
237 | 229 |
/* add unit-test shell commands */ \ |
238 |
aosShellAddCommand(aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
239 |
aosShellAddCommand(aos.shell, &moduleUtAlldTlc5947.shellcmd); \
|
|
240 |
aosShellAddCommand(aos.shell, &moduleUtAlldTps2051bdbv.shellcmd); \
|
|
230 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
231 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd); \
|
|
232 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd); \
|
|
241 | 233 |
} |
242 | 234 |
|
243 | 235 |
/** |
... | ... | |
255 | 247 |
} |
256 | 248 |
|
257 | 249 |
/** |
258 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
259 |
*/ |
|
260 |
#define MODULE_SSP_STARTUP_OUTRO_IO_EVENT(mask, flags) { \ |
|
261 |
/* ignore all events */ \ |
|
262 |
(void)mask; \ |
|
263 |
(void)flags; \ |
|
264 |
} |
|
265 |
|
|
266 |
/** |
|
267 | 250 |
* @brief Periphery communication interface deinitialization hook. |
268 | 251 |
*/ |
269 | 252 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \ |
... | ... | |
278 | 261 |
|
279 | 262 |
/*===========================================================================*/ |
280 | 263 |
/** |
264 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
265 |
* @{ |
|
266 |
*/ |
|
267 |
/*===========================================================================*/ |
|
268 |
|
|
269 |
/** |
|
270 |
* @brief PD signal GPIO. |
|
271 |
*/ |
|
272 |
extern apalControlGpio_t moduleSsspGpioPd; |
|
273 |
|
|
274 |
/** |
|
275 |
* @brief SYNC signal GPIO. |
|
276 |
*/ |
|
277 |
extern apalControlGpio_t moduleSsspGpioSync; |
|
278 |
|
|
279 |
/** |
|
280 |
* @brief Event flags for PD signal events. |
|
281 |
*/ |
|
282 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD |
|
283 |
|
|
284 |
/** |
|
285 |
* @brief Event flags for Sync signal events. |
|
286 |
*/ |
|
287 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC |
|
288 |
|
|
289 |
/** |
|
290 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
291 |
*/ |
|
292 |
#define MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK(mask, flags) { \ |
|
293 |
/* ignore all events */ \ |
|
294 |
(void)mask; \ |
|
295 |
(void)flags; \ |
|
296 |
} |
|
297 |
|
|
298 |
/** @} */ |
|
299 |
|
|
300 |
/*===========================================================================*/ |
|
301 |
/** |
|
281 | 302 |
* @name Low-level drivers |
282 | 303 |
* @{ |
283 | 304 |
*/ |
modules/PowerManagement_1-1/aosconf.h | ||
---|---|---|
28 | 28 |
|
29 | 29 |
#include <stdbool.h> |
30 | 30 |
|
31 |
/*===========================================================================*/ |
|
32 |
/** |
|
33 |
* @name Kernel parameters and options |
|
34 |
* @{ |
|
35 |
*/ |
|
36 |
/*===========================================================================*/ |
|
37 |
|
|
38 | 31 |
/* |
39 | 32 |
* Include an external configuration file to override the following default settings only if required. |
40 | 33 |
*/ |
... | ... | |
42 | 35 |
#include <osconf.h> |
43 | 36 |
#endif |
44 | 37 |
|
38 |
/*===========================================================================*/ |
|
45 | 39 |
/** |
46 |
* @brief Flag to set the module as SSSP master. |
|
47 |
*/ |
|
48 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
49 |
#define AMIROOS_CFG_SSSP_MASTER true |
|
50 |
#else |
|
51 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
52 |
#endif |
|
53 |
|
|
54 |
/** |
|
55 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
56 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
57 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
40 |
* @name Kernel parameters and options |
|
41 |
* @{ |
|
58 | 42 |
*/ |
59 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
60 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
61 |
#else |
|
62 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
63 |
#endif |
|
43 |
/*===========================================================================*/ |
|
64 | 44 |
|
65 | 45 |
/** |
66 | 46 |
* @brief Flag to enable/disable debug API. |
... | ... | |
103 | 83 |
|
104 | 84 |
/*===========================================================================*/ |
105 | 85 |
/** |
86 |
* @name SSSP (Startup Shutdown Synchronization Protocol) configuration. |
|
87 |
* @{ |
|
88 |
*/ |
|
89 |
/*===========================================================================*/ |
|
90 |
|
|
91 |
/** |
|
92 |
* @brief Flag to set the module as SSSP master. |
|
93 |
* @details There must be only one module with this flag set to true in a system. |
|
94 |
*/ |
|
95 |
#if !defined(OS_CFG_SSSP_MASTER) |
|
96 |
#define AMIROOS_CFG_SSSP_MASTER true |
|
97 |
#else |
|
98 |
#define AMIROOS_CFG_SSSP_MASTER OS_CFG_SSSP_MASTER |
|
99 |
#endif |
|
100 |
|
|
101 |
/** |
|
102 |
* @brief Time boundary for robot wide clock synchronization in microseconds. |
|
103 |
* @details Whenever the SSSP S (snychronization) signal gets logically deactivated, |
|
104 |
* All modules need to align their local uptime to the nearest multiple of this value. |
|
105 |
*/ |
|
106 |
#if !defined(OS_CFG_SSSP_SYSSYNCPERIOD) |
|
107 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD 1000000 |
|
108 |
#else |
|
109 |
#define AMIROOS_CFG_SSSP_SYSSYNCPERIOD OS_CFG_SSSP_SYSSYNCPERIOD |
|
110 |
#endif |
|
111 |
|
|
112 |
/** @} */ |
|
113 |
|
|
114 |
/*===========================================================================*/ |
|
115 |
/** |
|
106 | 116 |
* @name System shell options |
107 | 117 |
* @{ |
108 | 118 |
*/ |
modules/PowerManagement_1-1/module.c | ||
---|---|---|
36 | 36 |
(void)extp; |
37 | 37 |
|
38 | 38 |
chSysLockFromISR(); |
39 |
chEvtBroadcastFlagsI(&aos.events.io.source, (1 << channel));
|
|
39 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel)); |
|
40 | 40 |
chSysUnlockFromISR(); |
41 | 41 |
|
42 | 42 |
return; |
... | ... | |
355 | 355 |
*/ |
356 | 356 |
/*===========================================================================*/ |
357 | 357 |
|
358 |
apalControlGpio_t moduleSsspPd = { |
|
358 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
359 |
const char* moduleShellPrompt = "PowerManagement"; |
|
360 |
#endif |
|
361 |
|
|
362 |
/** @} */ |
|
363 |
|
|
364 |
/*===========================================================================*/ |
|
365 |
/** |
|
366 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
367 |
* @{ |
|
368 |
*/ |
|
369 |
/*===========================================================================*/ |
|
370 |
|
|
371 |
apalControlGpio_t moduleSsspGpioPd = { |
|
359 | 372 |
/* GPIO */ &moduleGpioSysPd, |
360 | 373 |
/* meta */ { |
361 | 374 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
364 | 377 |
}, |
365 | 378 |
}; |
366 | 379 |
|
367 |
apalControlGpio_t moduleSsspSync = { |
|
380 |
apalControlGpio_t moduleSsspGpioSync = {
|
|
368 | 381 |
/* GPIO */ &moduleGpioSysSync, |
369 | 382 |
/* meta */ { |
370 | 383 |
/* active state */ APAL_GPIO_ACTIVE_LOW, |
... | ... | |
373 | 386 |
}, |
374 | 387 |
}; |
375 | 388 |
|
376 |
const char* moduleShellPrompt = "PowerManagement"; |
|
377 |
|
|
378 | 389 |
/** @} */ |
379 | 390 |
|
380 | 391 |
/*===========================================================================*/ |
... | ... | |
857 | 868 |
static ut_mpr121data_t _utAlldMpr121Data= { |
858 | 869 |
/* MPR121 driver */ &moduleLldTouch, |
859 | 870 |
/* timeout */ MICROSECONDS_PER_SECOND, |
860 |
/* event source */ &aos.events.io.source,
|
|
871 |
/* event source */ &aos.events.io, |
|
861 | 872 |
/* event flags */ (1 << MODULE_GPIO_EXTCHANNEL_TOUCHINT), |
862 | 873 |
}; |
863 | 874 |
aos_unittest_t moduleUtAlldMpr121 = { |
... | ... | |
1119 | 1130 |
static ut_vcnl4020data_t _utAlldVcnl4020Data = { |
1120 | 1131 |
/* driver */ NULL, |
1121 | 1132 |
/* timeout */ MICROSECONDS_PER_SECOND, |
1122 |
/* event source */ &aos.events.io.source,
|
|
1133 |
/* event source */ &aos.events.io, |
|
1123 | 1134 |
/* event flags */ 0, |
1124 | 1135 |
}; |
1125 | 1136 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
modules/PowerManagement_1-1/module.h | ||
---|---|---|
422 | 422 |
*/ |
423 | 423 |
#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP ((eventflags_t)1 << MODULE_GPIO_EXTCHANNEL_SYSUARTUP) |
424 | 424 |
|
425 |
/** |
|
426 |
* @brief PD signal for SSSP. |
|
427 |
*/ |
|
428 |
extern apalControlGpio_t moduleSsspPd; |
|
429 |
|
|
430 |
/** |
|
431 |
* @brief SYNC signal for SSSP. |
|
432 |
*/ |
|
433 |
extern apalControlGpio_t moduleSsspSync; |
|
434 |
|
|
425 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
435 | 426 |
/** |
436 | 427 |
* @brief Shell prompt text. |
437 | 428 |
*/ |
438 | 429 |
extern const char* moduleShellPrompt; |
430 |
#endif |
|
439 | 431 |
|
440 | 432 |
/** |
441 | 433 |
* @brief Unit test initialization hook. |
442 | 434 |
*/ |
443 | 435 |
#define MODULE_INIT_TESTS() { \ |
444 | 436 |
/* add unit-test shell commands */ \ |
445 |
aosShellAddCommand(aos.shell, &moduleUtAdcVsys.shellcmd); \
|
|
446 |
aosShellAddCommand(aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
447 |
aosShellAddCommand(aos.shell, &moduleUtAlldBq24103a.shellcmd); \
|
|
448 |
aosShellAddCommand(aos.shell, &moduleUtAlldBq27500.shellcmd); \
|
|
449 |
aosShellAddCommand(aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \
|
|
450 |
aosShellAddCommand(aos.shell, &moduleUtAlldIna219.shellcmd); \
|
|
451 |
aosShellAddCommand(aos.shell, &moduleUtAlldMpr121.shellcmd); \
|
|
452 |
aosShellAddCommand(aos.shell, &moduleUtAlldPca9544a.shellcmd); \
|
|
453 |
aosShellAddCommand(aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd); \
|
|
454 |
aosShellAddCommand(aos.shell, &moduleUtAlldLed.shellcmd); \
|
|
455 |
aosShellAddCommand(aos.shell, &moduleUtAlldTps62113.shellcmd); \
|
|
456 |
aosShellAddCommand(aos.shell, &moduleUtAlldTps62113Ina219.shellcmd); \
|
|
457 |
aosShellAddCommand(aos.shell, &moduleUtAlldVcnl4020.shellcmd); \
|
|
437 |
aosShellAddCommand(&aos.shell, &moduleUtAdcVsys.shellcmd); \
|
|
438 |
aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd); \
|
|
439 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq24103a.shellcmd); \
|
|
440 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500.shellcmd); \
|
|
441 |
aosShellAddCommand(&aos.shell, &moduleUtAlldBq27500Bq24103a.shellcmd); \
|
|
442 |
aosShellAddCommand(&aos.shell, &moduleUtAlldIna219.shellcmd); \
|
|
443 |
aosShellAddCommand(&aos.shell, &moduleUtAlldMpr121.shellcmd); \
|
|
444 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPca9544a.shellcmd); \
|
|
445 |
aosShellAddCommand(&aos.shell, &moduleUtAlldPklcs1212e4001.shellcmd); \
|
|
446 |
aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd); \
|
|
447 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113.shellcmd); \
|
|
448 |
aosShellAddCommand(&aos.shell, &moduleUtAlldTps62113Ina219.shellcmd); \
|
|
449 |
aosShellAddCommand(&aos.shell, &moduleUtAlldVcnl4020.shellcmd); \
|
|
458 | 450 |
} |
459 | 451 |
|
460 | 452 |
/** |
... | ... | |
489 | 481 |
} |
490 | 482 |
|
491 | 483 |
/** |
492 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
493 |
*/ |
|
494 |
#define MODULE_SSP_STARTUP_OUTRO_IO_EVENT(mask, flags) { \ |
|
495 |
/* ignore all events */ \ |
|
496 |
(void)mask; \ |
|
497 |
(void)flags; \ |
|
498 |
} |
|
499 |
|
|
500 |
/** |
|
501 | 484 |
* @brief Periphery communication interface deinitialization hook. |
502 | 485 |
*/ |
503 | 486 |
#define MODULE_SHUTDOWN_PERIPHERY_COMM() { \ |
... | ... | |
515 | 498 |
|
516 | 499 |
/*===========================================================================*/ |
517 | 500 |
/** |
501 |
* @name Startup Shutdown Synchronization Protocol (SSSP) |
|
502 |
* @{ |
|
503 |
*/ |
|
504 |
/*===========================================================================*/ |
|
505 |
|
|
506 |
/** |
|
507 |
* @brief PD signal GPIO. |
|
508 |
*/ |
|
509 |
extern apalControlGpio_t moduleSsspGpioPd; |
|
510 |
|
|
511 |
/** |
|
512 |
* @brief SYNC signal GPIO. |
|
513 |
*/ |
|
514 |
extern apalControlGpio_t moduleSsspGpioSync; |
|
515 |
|
|
516 |
/** |
|
517 |
* @brief Event flags for PD signal events. |
|
518 |
*/ |
|
519 |
#define MODULE_SSSP_EVENTFLAGS_PD MODULE_OS_IOEVENTFLAGS_SYSPD |
|
520 |
|
|
521 |
/** |
|
522 |
* @brief Event flags for Sync signal events. |
|
523 |
*/ |
|
524 |
#define MODULE_SSSP_EVENTFLAGS_SYNC MODULE_OS_IOEVENTFLAGS_SYSSYNC |
|
525 |
|
|
526 |
/** |
|
527 |
* @brief Hook to handle IO events during SSSP startup synchronization. |
|
528 |
*/ |
|
529 |
#define MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK(mask, flags) { \ |
|
530 |
/* ignore all events */ \ |
|
531 |
(void)mask; \ |
|
532 |
(void)flags; \ |
|
533 |
} |
|
534 |
|
|
535 |
/** @} */ |
|
536 |
|
|
537 |
/*===========================================================================*/ |
|
538 |
/** |
|
518 | 539 |
* @name Low-level drivers |
519 | 540 |
* @{ |
520 | 541 |
*/ |
os/amiroos.h | ||
---|---|---|
54 | 54 |
|
55 | 55 |
/** @} */ |
56 | 56 |
|
57 |
/* core headers */
|
|
57 |
/* subsystems headers */
|
|
58 | 58 |
#include <aosconf.h> |
59 | 59 |
#include <hal.h> |
60 |
#if defined(HAL_USE_QEI) && (HAL_USE_QEI == TRUE) |
|
60 | 61 |
#include <hal_qei.h> |
62 |
#endif |
|
61 | 63 |
#include <ch.h> |
62 | 64 |
|
65 |
/* configuration check */ |
|
63 | 66 |
#if !defined(_AMIRO_OS_CFG_) |
64 | 67 |
#error "invalid AMiRo-OS configuration file" |
65 | 68 |
#endif |
66 | 69 |
#if (_AMIRO_OS_CFG_VERSION_MAJOR_ != AMIROOS_VERSION_MAJOR) || (_AMIRO_OS_CFG_VERSION_MINOR_ < AMIROOS_VERSION_MINOR) |
67 | 70 |
#error "incompatible AMiRo-OS configuration file" |
68 | 71 |
#endif |
69 |
|
|
70 | 72 |
#include "core/inc/aos_confcheck.h" |
73 |
|
|
74 |
/* core headers */ |
|
71 | 75 |
#include "core/inc/aos_debug.h" |
72 | 76 |
#include <core/inc/aos_iostream.h> |
73 | 77 |
#include "core/inc/aos_shell.h" |
os/core/inc/aos_confcheck.h | ||
---|---|---|
25 | 25 |
* Kernel parameters and options |
26 | 26 |
*/ |
27 | 27 |
|
28 |
#ifndef AMIROOS_CFG_SSSP_MASTER |
|
29 |
#error "AMIROOS_CFG_SSSP_MASTER not defined in aosconf.h" |
|
30 |
#endif |
|
31 |
|
|
32 |
#ifndef AMIROOS_CFG_SSSP_SYSSYNCPERIOD |
|
33 |
#error "AMIROOS_CFG_SSSP_SYSSYNCPERIOD not defined in aosconf.h" |
|
34 |
#endif |
|
35 |
|
|
36 | 28 |
#ifndef AMIROOS_CFG_DBG |
37 | 29 |
#error "AMIROOS_CFG_DBG not defined in aosconf.h" |
38 | 30 |
#endif |
... | ... | |
50 | 42 |
#endif |
51 | 43 |
|
52 | 44 |
/* |
45 |
* SSSP parameters and options |
|
46 |
*/ |
|
47 |
|
|
48 |
#ifndef AMIROOS_CFG_SSSP_MASTER |
|
49 |
#error "AMIROOS_CFG_SSSP_MASTER not defined in aosconf.h" |
|
50 |
#endif |
|
51 |
|
|
52 |
#ifndef AMIROOS_CFG_SSSP_SYSSYNCPERIOD |
|
53 |
#error "AMIROOS_CFG_SSSP_SYSSYNCPERIOD not defined in aosconf.h" |
|
54 |
#endif |
|
55 |
|
|
56 |
/* |
|
53 | 57 |
* System shell options |
54 | 58 |
*/ |
55 | 59 |
|
os/core/inc/aos_system.h | ||
---|---|---|
103 | 103 |
* @brief AMiRo-OS base system structure. |
104 | 104 |
*/ |
105 | 105 |
typedef struct aos_system { |
106 |
|
|
106 | 107 |
/** |
107 |
* @brief Current SSSP stage of the system.
|
|
108 |
* @brief SSSP relevant data.
|
|
108 | 109 |
*/ |
109 |
aos_ssspstage_t ssspStage; |
|
110 |
struct { |
|
111 |
/** |
|
112 |
* @brief Current SSSP stage of the system. |
|
113 |
*/ |
|
114 |
aos_ssspstage_t stage; |
|
115 |
} sssp; |
|
110 | 116 |
|
111 | 117 |
/** |
112 | 118 |
* @brief System I/O stream. |
... | ... | |
119 | 125 |
struct { |
120 | 126 |
|
121 | 127 |
/** |
122 |
* @brief I/O related events.
|
|
128 |
* @brief I/O event source.
|
|
123 | 129 |
*/ |
124 |
struct { |
|
125 |
/** |
|
126 |
* @brief I/O event source. |
|
127 |
*/ |
|
128 |
event_source_t source; |
|
129 |
|
|
130 |
/** |
|
131 |
* @brief Event flags emitted when a PD signal interrupt occurs. |
|
132 |
*/ |
|
133 |
eventflags_t flagsSignalPd; |
|
134 |
|
|
135 |
/** |
|
136 |
* @brief Event flags emitted when a Sync signal interrupt occurs. |
|
137 |
*/ |
|
138 |
eventflags_t flagsSignalSync; |
|
139 |
} io; |
|
130 |
event_source_t io; |
|
140 | 131 |
|
141 | 132 |
/** |
142 |
* @brief Operating system events.
|
|
133 |
* @brief OS event source.
|
|
143 | 134 |
*/ |
144 |
struct { |
|
145 |
/** |
|
146 |
* @brief OS event source. |
|
147 |
*/ |
|
148 |
event_source_t source; |
|
149 |
} os; |
|
135 |
event_source_t os; |
|
150 | 136 |
} events; |
151 | 137 |
|
152 | 138 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
153 | 139 |
/** |
154 | 140 |
* @brief Pointer to the shell object. |
155 | 141 |
*/ |
156 |
aos_shell_t* shell;
|
|
142 |
aos_shell_t shell; |
|
157 | 143 |
#endif |
158 | 144 |
|
159 | 145 |
} aos_system_t; |
... | ... | |
171 | 157 |
#ifdef __cplusplus |
172 | 158 |
extern "C" { |
173 | 159 |
#endif |
174 |
void aosSysInit(EXTDriver* extDrv, EXTConfig* extCfg, apalControlGpio_t* gpioPd, apalControlGpio_t* gpioSync, eventflags_t flagsSignalPd, eventflags_t evtFlagsSync, const char* shellPrompt); |
|
160 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
|
161 |
void aosSysInit(const char* shellPrompt); |
|
162 |
#else |
|
163 |
void aosSysInit(void); |
|
164 |
#endif |
|
175 | 165 |
void aosSysStart(void); |
176 | 166 |
eventmask_t aosSysSsspStartupOsInitSyncCheck(event_listener_t* syncEvtListener); |
177 | 167 |
void aosSysGetUptimeX(aos_timestamp_t* ut); |
os/core/src/aos_iostream.c | ||
---|---|---|
21 | 21 |
#include <aos_debug.h> |
22 | 22 |
#include <chprintf.h> |
23 | 23 |
|
24 |
|
|
25 |
|
|
26 | 24 |
/** |
27 | 25 |
* @brief Implementation of the BaseAsynchronousChannel write() method (inherited from BaseSequentialStream). |
28 | 26 |
*/ |
os/core/src/aos_main.cpp | ||
---|---|---|
29 | 29 |
/** |
30 | 30 |
* @brief Event mask to identify I/O events. |
31 | 31 |
*/ |
32 |
#define _IOEVENT_MASK EVENT_MASK(0)
|
|
32 |
#define IOEVENT_MASK EVENT_MASK(0)
|
|
33 | 33 |
|
34 | 34 |
/** |
35 | 35 |
* @brief Event mask to identify OS events. |
36 | 36 |
*/ |
37 |
#define _OSEVENT_MASK EVENT_MASK(1)
|
|
37 |
#define OSEVENT_MASK EVENT_MASK(1)
|
|
38 | 38 |
|
39 | 39 |
/** |
40 | 40 |
* @brief Listener object for I/O events. |
... | ... | |
75 | 75 |
*/ |
76 | 76 |
static inline void _unexpectedEventError(eventmask_t mask, eventflags_t flags) |
77 | 77 |
{ |
78 |
aosprintf("unexpected/unknown event recieved. mask: 0x%08X; flags: 0x%08X\n", mask, flags); |
|
78 |
#if (AMIROOS_CFG_DBG == true) |
|
79 |
aosprintf("unexpected/unknown event received. mask: 0x%08X; flags: 0x%08X\n", mask, flags); |
|
80 |
#else |
|
81 |
(void)mask; |
|
82 |
(void)flags; |
|
83 |
#endif |
|
79 | 84 |
return; |
80 | 85 |
} |
81 | 86 |
|
... | ... | |
136 | 141 |
#endif |
137 | 142 |
|
138 | 143 |
// AMiRo-OS and custom OS additions (if any) |
139 |
aosSysInit(&MODULE_HAL_EXT, |
|
140 |
&moduleHalExtConfig, |
|
141 |
&moduleSsspPd, |
|
142 |
&moduleSsspSync, |
|
143 |
MODULE_OS_IOEVENTFLAGS_SYSPD, |
|
144 |
MODULE_OS_IOEVENTFLAGS_SYSSYNC, |
|
145 |
moduleShellPrompt); |
|
144 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
|
145 |
aosSysInit(moduleShellPrompt); |
|
146 |
#else |
|
147 |
aosSysInit(); |
|
148 |
#endif |
|
146 | 149 |
#ifdef MODULE_INIT_OS_EXTRA |
147 | 150 |
MODULE_INIT_OS_EXTRA(); |
148 | 151 |
#endif |
... | ... | |
172 | 175 |
#endif |
173 | 176 |
|
174 | 177 |
/* event associations */ |
175 |
chEvtRegisterMask(&aos.events.io.source, &_eventListenerIO, _IOEVENT_MASK);
|
|
176 |
chEvtRegisterMask(&aos.events.os.source, &_eventListenerOS, _OSEVENT_MASK);
|
|
178 |
chEvtRegisterMask(&aos.events.io, &_eventListenerIO, IOEVENT_MASK);
|
|
179 |
chEvtRegisterMask(&aos.events.os, &_eventListenerOS, OSEVENT_MASK);
|
|
177 | 180 |
|
178 | 181 |
#if defined(AMIROOS_CFG_MAIN_INIT_HOOK_5) |
179 | 182 |
#if defined(AMIROOS_CFG_MAIN_INIT_HOOK_5_ARGS) |
... | ... | |
199 | 202 |
aosShellChannelInit(&_stdshellchannel, (BaseAsynchronousChannel*)&MODULE_HAL_PROGIF); |
200 | 203 |
aosShellChannelInputEnable(&_stdshellchannel); |
201 | 204 |
aosShellChannelOutputEnable(&_stdshellchannel); |
202 |
aosShellStreamAddChannel(&aos.shell->stream, &_stdshellchannel);
|
|
205 |
aosShellStreamAddChannel(&aos.shell.stream, &_stdshellchannel);
|
|
203 | 206 |
#endif |
204 | 207 |
#endif |
205 | 208 |
|
... | ... | |
236 | 239 |
#endif |
237 | 240 |
#endif |
238 | 241 |
|
239 |
/* SSSP startup outro (end of startup stage 2) synchronization */
|
|
242 |
/* SSSP startup OS synchronization phase (end of startup stage 2) */
|
|
240 | 243 |
while ((eventmask = aosSysSsspStartupOsInitSyncCheck(&_eventListenerIO)) != 0) { |
241 | 244 |
/* |
242 | 245 |
* This code is executed if the received event was not about the SYS_SYNC control signal. |
... | ... | |
245 | 248 |
// unexpected IO events |
246 | 249 |
if (eventmask & _eventListenerIO.events) { |
247 | 250 |
eventflags = chEvtGetAndClearFlags(&_eventListenerIO); |
248 |
#ifdef MODULE_SSP_STARTUP_OUTRO_IO_EVENT
|
|
249 |
MODULE_SSP_STARTUP_OUTRO_IO_EVENT(eventmask, eventflags);
|
|
251 |
#ifdef MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK
|
|
252 |
MODULE_SSSP_STARTUP_OSINIT_OUTRO_IOEVENT_HOOK(eventmask, eventflags);
|
|
250 | 253 |
#else |
251 | 254 |
_unexpectedEventError(eventmask, eventflags); |
252 | 255 |
#endif |
... | ... | |
256 | 259 |
eventflags = chEvtGetAndClearFlags(&_eventListenerOS); |
257 | 260 |
_unexpectedEventError(eventmask, eventflags); |
258 | 261 |
} |
259 |
#if (AMIROOS_CFG_DBG == true) |
|
260 | 262 |
// unknown event (must never occur, thus disabled for release builds) |
261 | 263 |
else { |
262 |
eventflags = 0; |
|
263 | 264 |
_unexpectedEventError(eventmask, eventflags); |
264 | 265 |
} |
265 |
#endif |
|
266 | 266 |
} |
267 | 267 |
|
268 | 268 |
#if defined(AMIROOS_CFG_MAIN_INIT_HOOK_8) |
... | ... | |
309 | 309 |
|
310 | 310 |
switch (eventmask) { |
311 | 311 |
// if this was an I/O event |
312 |
case _IOEVENT_MASK:
|
|
312 |
case IOEVENT_MASK: |
|
313 | 313 |
// evaluate flags |
314 | 314 |
eventflags = chEvtGetAndClearFlags(&_eventListenerIO); |
315 | 315 |
// PD event |
316 |
if (eventflags & MODULE_OS_IOEVENTFLAGS_SYSPD) {
|
|
316 |
if (eventflags & MODULE_SSSP_EVENTFLAGS_PD) {
|
|
317 | 317 |
shutdown = AOS_SHUTDOWN_PASSIVE; |
318 | 318 |
} |
319 | 319 |
// all other events |
... | ... | |
325 | 325 |
break; |
326 | 326 |
|
327 | 327 |
// if this was an OS event |
328 |
case _OSEVENT_MASK:
|
|
328 |
case OSEVENT_MASK: |
|
329 | 329 |
// evaluate flags |
330 | 330 |
eventflags = chEvtGetAndClearFlags(&_eventListenerOS); |
331 | 331 |
switch (eventflags) { |
os/core/src/aos_system.c | ||
---|---|---|
54 | 54 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */ |
55 | 55 |
|
56 | 56 |
/** |
57 |
* @brief PD signal GPIO. |
|
58 |
*/ |
|
59 |
static apalControlGpio_t* _gpioPd; |
|
60 |
|
|
61 |
/** |
|
62 |
* @brief Sync signal GPIO. |
|
63 |
*/ |
|
64 |
static apalControlGpio_t* _gpioSync; |
|
65 |
|
|
66 |
/** |
|
67 | 57 |
* @brief Timer to accumulate system uptime. |
68 | 58 |
*/ |
69 | 59 |
static virtual_timer_t _systimer; |
... | ... | |
92 | 82 |
|
93 | 83 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
94 | 84 |
/** |
95 |
* @brief System shell. |
|
96 |
*/ |
|
97 |
static aos_shell_t _shell; |
|
98 |
|
|
99 |
/** |
|
100 | 85 |
* @brief Shell thread working area. |
101 | 86 |
*/ |
102 | 87 |
THD_WORKING_AREA(_shell_wa, AMIROOS_CFG_SHELL_STACKSIZE); |
... | ... | |
153 | 138 |
/** |
154 | 139 |
* @brief Global system object. |
155 | 140 |
*/ |
156 |
aos_system_t aos = { |
|
157 |
/* SSSP stage */ AOS_SSSP_STARTUP_2_1, |
|
158 |
/* I/O stream */ { |
|
159 |
/* channel */ NULL, |
|
160 |
}, |
|
161 |
/* event */ { |
|
162 |
/* I/O */ { |
|
163 |
/* source */ { |
|
164 |
/* next listener */ NULL, |
|
165 |
}, |
|
166 |
/* flagsSignalPd */ 0, |
|
167 |
/* flagsSignalSync */ 0, |
|
168 |
}, |
|
169 |
/* OS */ { |
|
170 |
/* source */ { |
|
171 |
/* next listener */ NULL, |
|
172 |
} |
|
173 |
}, |
|
174 |
}, |
|
175 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
|
176 |
/* shell */ &_shell, |
|
177 |
#endif |
|
178 |
}; |
|
141 |
aos_system_t aos; |
|
179 | 142 |
|
180 | 143 |
/** |
181 | 144 |
* @brief Print a separator line. |
... | ... | |
328 | 291 |
if (argc > 3) { |
329 | 292 |
// handle the option |
330 | 293 |
if (strcmp(argv[3], "text") == 0) { |
331 |
aos.shell->config &= ~AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
294 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
332 | 295 |
retval = AOS_OK; |
333 | 296 |
} |
334 | 297 |
else if (strcmp(argv[3], "minimal") == 0) { |
335 |
aos.shell->config |= AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
298 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
336 | 299 |
retval = AOS_OK; |
337 | 300 |
} |
338 | 301 |
else if (strcmp(argv[3], "notime") == 0) { |
339 |
aos.shell->config &= ~(AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME);
|
|
302 |
aos.shell.config &= ~(AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME);
|
|
340 | 303 |
retval = AOS_OK; |
341 | 304 |
} |
342 | 305 |
else if (strcmp(argv[3], "uptime") == 0) { |
343 |
aos.shell->config &= ~AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
344 |
aos.shell->config |= AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
306 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
307 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
345 | 308 |
retval = AOS_OK; |
346 | 309 |
} |
347 | 310 |
else if (strcmp(argv[3], "date&time") == 0) { |
348 |
aos.shell->config &= ~AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
349 |
aos.shell->config |= AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
311 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
312 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
350 | 313 |
retval = AOS_OK; |
351 | 314 |
} |
352 | 315 |
else { |
... | ... | |
360 | 323 |
// there must be a further argument |
361 | 324 |
if (argc > 3) { |
362 | 325 |
if (strcmp(argv[3], "casesensitive") == 0) { |
363 |
aos.shell->config |= AOS_SHELL_CONFIG_MATCH_CASE;
|
|
326 |
aos.shell.config |= AOS_SHELL_CONFIG_MATCH_CASE;
|
|
364 | 327 |
retval = AOS_OK; |
365 | 328 |
} |
366 | 329 |
else if (strcmp(argv[3], "caseinsensitive") == 0) { |
367 |
aos.shell->config &= ~AOS_SHELL_CONFIG_MATCH_CASE;
|
|
330 |
aos.shell.config &= ~AOS_SHELL_CONFIG_MATCH_CASE;
|
|
368 | 331 |
retval = AOS_OK; |
369 | 332 |
} |
370 | 333 |
} |
... | ... | |
374 | 337 |
else { |
375 | 338 |
chprintf(stream, "current shell configuration:\n"); |
376 | 339 |
chprintf(stream, " prompt text: %s\n", |
377 |
(aos.shell->prompt != NULL) ? aos.shell->prompt : "n/a");
|
|
340 |
(aos.shell.prompt != NULL) ? aos.shell.prompt : "n/a");
|
|
378 | 341 |
char time[10]; |
379 |
switch (aos.shell->config & (AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME)) {
|
|
342 |
switch (aos.shell.config & (AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME)) {
|
|
380 | 343 |
case AOS_SHELL_CONFIG_PROMPT_UPTIME: |
381 | 344 |
strcpy(time, "uptime"); break; |
382 | 345 |
case AOS_SHELL_CONFIG_PROMPT_DATETIME: |
... | ... | |
385 | 348 |
strcpy(time, "no time"); break; |
386 | 349 |
} |
387 | 350 |
chprintf(stream, " prompt style: %s, %s\n", |
388 |
(aos.shell->config & AOS_SHELL_CONFIG_PROMPT_MINIMAL) ? "minimal" : "text",
|
|
351 |
(aos.shell.config & AOS_SHELL_CONFIG_PROMPT_MINIMAL) ? "minimal" : "text",
|
|
389 | 352 |
time); |
390 | 353 |
chprintf(stream, " input method: %s\n", |
391 |
(aos.shell->config & AOS_SHELL_CONFIG_INPUT_OVERWRITE) ? "replace" : "insert");
|
|
354 |
(aos.shell.config & AOS_SHELL_CONFIG_INPUT_OVERWRITE) ? "replace" : "insert");
|
|
392 | 355 |
chprintf(stream, " text matching: %s\n", |
393 |
(aos.shell->config & AOS_SHELL_CONFIG_MATCH_CASE) ? "case sensitive" : "case insensitive");
|
|
356 |
(aos.shell.config & AOS_SHELL_CONFIG_MATCH_CASE) ? "case sensitive" : "case insensitive");
|
|
394 | 357 |
retval = AOS_OK; |
395 | 358 |
} |
396 | 359 |
} |
... | ... | |
536 | 499 |
// handle argument |
537 | 500 |
else { |
538 | 501 |
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--hibernate") == 0) { |
539 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_HIBERNATE);
|
|
502 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_HIBERNATE); |
|
540 | 503 |
chThdTerminate(currp); |
541 | 504 |
return AOS_OK; |
542 | 505 |
} |
543 | 506 |
else if (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--deepsleep") == 0) { |
544 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP);
|
|
507 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP); |
|
545 | 508 |
chThdTerminate(currp); |
546 | 509 |
return AOS_OK; |
547 | 510 |
} |
548 | 511 |
else if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--transportation") == 0) { |
549 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION);
|
|
512 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION); |
|
550 | 513 |
chThdTerminate(currp); |
551 | 514 |
return AOS_OK; |
552 | 515 |
} |
553 | 516 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--restart") == 0) { |
554 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_RESTART);
|
|
517 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_RESTART); |
|
555 | 518 |
chThdTerminate(currp); |
556 | 519 |
return AOS_OK; |
557 | 520 |
} |
... | ... | |
598 | 561 |
static void _signalPdCallback(EXTDriver* extp, expchannel_t channel) |
599 | 562 |
{ |
600 | 563 |
(void)extp; |
601 |
(void)channel; |
|
602 | 564 |
|
603 | 565 |
chSysLockFromISR(); |
604 |
chEvtBroadcastFlagsI(&aos.events.io.source, aos.events.io.flagsSignalPd);
|
|
566 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel));
|
|
605 | 567 |
chSysUnlockFromISR(); |
606 | 568 |
|
607 | 569 |
return; |
... | ... | |
616 | 578 |
static void _signalSyncCallback(EXTDriver* extp, expchannel_t channel) |
617 | 579 |
{ |
618 | 580 |
(void)extp; |
619 |
(void)channel; |
|
620 | 581 |
|
621 | 582 |
#if (AMIROOS_CFG_SSSP_MASTER == true) |
622 | 583 |
chSysLockFromISR(); |
623 |
chEvtBroadcastFlagsI(&aos.events.io.source, aos.events.io.flagsSignalSync);
|
|
584 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel));
|
|
624 | 585 |
chSysUnlockFromISR(); |
625 | 586 |
#else |
626 | 587 |
apalControlGpioState_t s_state; |
... | ... | |
630 | 591 |
// get current uptime |
631 | 592 |
aosSysGetUptimeX(&uptime); |
632 | 593 |
// read signal S |
633 |
apalControlGpioGet(_gpioSync, &s_state);
|
|
594 |
apalControlGpioGet(&moduleSsspGpioSync, &s_state);
|
|
634 | 595 |
// if S was toggled from on to off during SSSP operation phase |
635 |
if (aos.ssspStage == AOS_SSSP_OPERATION && s_state == APAL_GPIO_OFF) {
|
|
596 |
if (aos.sssp.stage == AOS_SSSP_OPERATION && s_state == APAL_GPIO_OFF) {
|
|
636 | 597 |
// align the uptime with the synchronization period |
637 | 598 |
if (uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD < AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2) { |
638 | 599 |
_uptime -= uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD; |
... | ... | |
641 | 602 |
} |
642 | 603 |
} |
643 | 604 |
// broadcast event |
644 |
chEvtBroadcastFlagsI(&aos.events.io.source, aos.events.io.flagsSignalSync);
|
|
605 |
chEvtBroadcastFlagsI(&aos.events.io, (1 << channel));
|
|
645 | 606 |
chSysUnlockFromISR(); |
646 | 607 |
#endif |
647 | 608 |
|
... | ... | |
686 | 647 |
|
687 | 648 |
chSysLockFromISR(); |
688 | 649 |
// read and toggle signal S |
689 |
apalControlGpioGet(_gpioSync, &s_state);
|
|
650 |
apalControlGpioGet(&moduleSsspGpioSync, &s_state);
|
|
690 | 651 |
s_state = (s_state == APAL_GPIO_ON) ? APAL_GPIO_OFF : APAL_GPIO_ON; |
691 |
apalControlGpioSet(_gpioSync, s_state);
|
|
652 |
apalControlGpioSet(&moduleSsspGpioSync, s_state);
|
|
692 | 653 |
// if S was toggled from off to on |
693 | 654 |
if (s_state == APAL_GPIO_ON) { |
694 | 655 |
// reconfigure the timer precisely, because the logically falling edge (next interrupt) snychronizes the system time |
... | ... | |
711 | 672 |
* @brief AMiRo-OS system initialization. |
712 | 673 |
* @note Must be called from the system control thread (usually main thread). |
713 | 674 |
* |
714 |
* @param[in] extDrv Pointer to the interrupt driver. |
|
715 |
* @param[in] extCfg Configuration for the interrupt driver. |
|
716 |
* @param[in] gpioPd GPIO of the PD signal. |
|
717 |
* @param[in] gpioSync GPIO of the Sync signal |
|
718 |
* @param[in] evtFlagsPd Event flags to be set when a PD interrupt occurs. |
|
719 |
* @param[in] evtFlagsSync Event flags to be set when a Sync interrupt occurs. |
|
720 | 675 |
* @param[in] shellPrompt String to be printed as prompt of the system shell. |
721 |
* @param[in] stdio Default (usually physically) interface for I/O like shell. |
|
722 | 676 |
*/ |
723 |
void aosSysInit(EXTDriver* extDrv, |
|
724 |
EXTConfig* extCfg, |
|
725 |
apalControlGpio_t* gpioPd, |
|
726 |
apalControlGpio_t* gpioSync, |
|
727 |
eventflags_t evtFlagsPd, |
|
728 |
eventflags_t evtFlagsSync, |
|
729 |
const char* shellPrompt) |
|
677 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
|
678 |
void aosSysInit(const char* shellPrompt) |
|
679 |
#else |
|
680 |
void aosSysInit(void) |
|
681 |
#endif |
|
730 | 682 |
{ |
731 |
// check arguments |
|
732 |
aosDbgCheck(extDrv != NULL); |
|
733 |
aosDbgCheck(extCfg != NULL); |
|
734 |
aosDbgCheck(gpioPd != NULL); |
|
735 |
aosDbgCheck(gpioSync != NULL); |
|
736 |
|
|
737 | 683 |
// set control thread to maximum priority |
738 | 684 |
chThdSetPriority(AOS_THD_CTRLPRIO); |
739 | 685 |
|
740 | 686 |
// set local variables |
741 |
_gpioPd = gpioPd; |
|
742 |
_gpioSync = gpioSync; |
|
743 | 687 |
chVTObjectInit(&_systimer); |
744 | 688 |
_synctime = 0; |
745 | 689 |
_uptime = 0; |
... | ... | |
749 | 693 |
#endif |
750 | 694 |
|
751 | 695 |
// set aos configuration |
752 |
aos.ssspStage = AOS_SSSP_STARTUP_2_1; |
|
696 |
aos.sssp.stage = AOS_SSSP_STARTUP_2_1; |
|
697 |
aos.sssp.moduleId = 0; |
|
753 | 698 |
aosIOStreamInit(&aos.iostream); |
754 |
chEvtObjectInit(&aos.events.io.source); |
|
755 |
chEvtObjectInit(&aos.events.os.source); |
|
756 |
aos.events.io.flagsSignalPd = evtFlagsPd; |
|
757 |
aos.events.io.flagsSignalSync = evtFlagsSync; |
|
699 |
chEvtObjectInit(&aos.events.io); |
|
700 |
chEvtObjectInit(&aos.events.os); |
|
758 | 701 |
|
759 | 702 |
// setup external interrupt system |
760 |
extCfg->channels[gpioPd->gpio->pad].cb = _signalPdCallback;
|
|
761 |
extCfg->channels[gpioSync->gpio->pad].cb = _signalSyncCallback;
|
|
762 |
extStart(extDrv, extCfg);
|
|
703 |
moduleHalExtConfig.channels[moduleSsspGpioPd.gpio->pad].cb = _signalPdCallback;
|
|
704 |
moduleHalExtConfig.channels[moduleSsspGpioSync.gpio->pad].cb = _signalSyncCallback;
|
|
705 |
extStart(&MODULE_HAL_EXT, &moduleHalExtConfig);
|
|
763 | 706 |
|
764 | 707 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
765 | 708 |
// init shell |
766 |
aosShellInit(aos.shell, |
|
767 |
&aos.events.os.source,
|
|
709 |
aosShellInit(&aos.shell,
|
|
710 |
&aos.events.os, |
|
768 | 711 |
shellPrompt, |
769 | 712 |
_shell_line, |
770 | 713 |
AMIROOS_CFG_SHELL_LINEWIDTH, |
771 | 714 |
_shell_arglist, |
772 | 715 |
AMIROOS_CFG_SHELL_MAXARGS); |
773 | 716 |
// add system commands |
774 |
aosShellAddCommand(aos.shell, &_shellcmd_config); |
|
775 |
aosShellAddCommand(aos.shell, &_shellcmd_info); |
|
776 |
aosShellAddCommand(aos.shell, &_shellcmd_shutdown); |
|
717 |
aosShellAddCommand(&aos.shell, &_shellcmd_config);
|
|
718 |
aosShellAddCommand(&aos.shell, &_shellcmd_info);
|
|
719 |
aosShellAddCommand(&aos.shell, &_shellcmd_shutdown);
|
|
777 | 720 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
778 |
aosShellAddCommand(aos.shell, &_shellcmd_kerneltest); |
|
721 |
aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest);
|
|
779 | 722 |
#endif |
780 |
#else |
|
781 |
(void)shellPrompt; |
|
782 | 723 |
#endif |
783 | 724 |
|
784 | 725 |
return; |
... | ... | |
790 | 731 |
inline void aosSysStart(void) |
791 | 732 |
{ |
792 | 733 |
// update the system SSSP stage |
793 |
aos.ssspStage = AOS_SSSP_OPERATION;
|
|
734 |
aos.sssp.stage = AOS_SSSP_OPERATION;
|
|
794 | 735 |
|
795 | 736 |
// print system information; |
796 | 737 |
_printSystemInfo((BaseSequentialStream*)&aos.iostream); |
... | ... | |
798 | 739 |
|
799 | 740 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
800 | 741 |
// start system shell thread |
801 |
aos.shell->thread = chThdCreateStatic(_shell_wa, sizeof(_shell_wa), AMIROOS_CFG_SHELL_THREADPRIO, aosShellThread, aos.shell);
|
|
742 |
aos.shell.thread = chThdCreateStatic(_shell_wa, sizeof(_shell_wa), AMIROOS_CFG_SHELL_THREADPRIO, aosShellThread, &aos.shell);
|
|
802 | 743 |
#endif |
803 | 744 |
|
804 | 745 |
return; |
... | ... | |
822 | 763 |
apalControlGpioState_t s; |
823 | 764 |
|
824 | 765 |
// update the system SSSP stage |
825 |
aos.ssspStage = AOS_SSSP_STARTUP_2_2;
|
|
766 |
aos.sssp.stage = AOS_SSSP_STARTUP_2_2;
|
|
826 | 767 |
|
827 | 768 |
// deactivate the sync signal to indicate that the module is ready (SSSPv1 stage 2.1 of startup phase) |
828 |
apalControlGpioSet(_gpioSync, APAL_GPIO_OFF);
|
|
769 |
apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_OFF);
|
|
829 | 770 |
|
830 | 771 |
// wait for any event to occur (do not apply any filter in order not to miss any event) |
831 | 772 |
m = chEvtWaitOne(ALL_EVENTS); |
832 | 773 |
f = chEvtGetAndClearFlags(syncEvtListener); |
833 |
apalControlGpioGet(_gpioSync, &s);
|
|
774 |
apalControlGpioGet(&moduleSsspGpioSync, &s);
|
|
834 | 775 |
|
835 | 776 |
// if the event was a system event, |
836 | 777 |
// and it was fired because of the SysSync control signal, |
837 | 778 |
// and the SysSync control signal has been deactivated |
838 | 779 |
if (m & syncEvtListener->events && |
839 |
f == aos.events.io.flagsSignalSync &&
|
|
780 |
f == MODULE_SSSP_EVENTFLAGS_SYNC &&
|
|
840 | 781 |
s == APAL_GPIO_OFF) { |
841 | 782 |
chSysLock(); |
842 | 783 |
#if (AMIROOS_CFG_SSSP_MASTER == true) |
... | ... | |
922 | 863 |
#endif |
923 | 864 |
|
924 | 865 |
// update the system SSSP stage |
925 |
aos.ssspStage = AOS_SSSP_SHUTDOWN_1_1;
|
|
866 |
aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_1;
|
|
926 | 867 |
|
927 | 868 |
// activate the SYS_PD control signal only, if this module initiated the shutdown |
928 | 869 |
chSysLock(); |
929 | 870 |
if (shutdown != AOS_SHUTDOWN_PASSIVE) { |
930 |
apalControlGpioSet(_gpioPd, APAL_GPIO_ON);
|
|
871 |
apalControlGpioSet(&moduleSsspGpioPd, APAL_GPIO_ON);
|
|
931 | 872 |
} |
932 | 873 |
// activate the SYS_SYNC signal |
933 |
apalControlGpioSet(_gpioSync, APAL_GPIO_ON);
|
|
874 |
apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_ON);
|
|
934 | 875 |
chSysUnlock(); |
935 | 876 |
|
936 | 877 |
switch (shutdown) { |
937 | 878 |
case AOS_SHUTDOWN_PASSIVE: |
938 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN);
|
|
879 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN); |
|
939 | 880 |
aosprintf("shutdown request received...\n"); |
940 | 881 |
break; |
941 | 882 |
case AOS_SHUTDOWN_HIBERNATE: |
942 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_HIBERNATE);
|
|
883 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_HIBERNATE); |
|
943 | 884 |
aosprintf("shutdown to hibernate mode...\n"); |
944 | 885 |
break; |
945 | 886 |
case AOS_SHUTDOWN_DEEPSLEEP: |
946 |
chEvtBroadcastFlags(&aos.events.os.source, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP);
|
|
887 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP); |
|
947 | 888 |
aosprintf("shutdown to deepsleep mode...\n"); |
948 | 889 |
break; |
949 | 890 |
case AOS_SHUTDOWN_TRANSPORTATION: |
Also available in: Unified diff