Revision e4379628
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))
|
|
70 |
#define AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_RESTART ((eventflags_t)(1 << 4))
|
|
66 | 71 |
|
67 | 72 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__) |
68 | 73 |
|
core/src/aos_main.cpp | ||
---|---|---|
1254 | 1254 |
eventflags = chEvtGetAndClearFlags(&_eventListenerOS); |
1255 | 1255 |
switch (eventflags) { |
1256 | 1256 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) |
1257 |
case AOS_SYSTEM_EVENTFLAGS_HIBERNATE: |
|
1257 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_HIBERNATE:
|
|
1258 | 1258 |
shutdown = AOS_SHUTDOWN_HIBERNATE; |
1259 | 1259 |
break; |
1260 |
case AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP: |
|
1260 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_DEEPSLEEP:
|
|
1261 | 1261 |
shutdown = AOS_SHUTDOWN_DEEPSLEEP; |
1262 | 1262 |
break; |
1263 |
case AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION: |
|
1263 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_TRANSPORTATION:
|
|
1264 | 1264 |
shutdown = AOS_SHUTDOWN_TRANSPORTATION; |
1265 | 1265 |
break; |
1266 |
case AOS_SYSTEM_EVENTFLAGS_RESTART: |
|
1266 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_RESTART:
|
|
1267 | 1267 |
shutdown = AOS_SHUTDOWN_RESTART; |
1268 | 1268 |
break; |
1269 | 1269 |
#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
1270 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN: |
|
1270 |
case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK:
|
|
1271 | 1271 |
shutdown = AOS_SHUTDOWN_DEFAULT; |
1272 | 1272 |
break; |
1273 | 1273 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
core/src/aos_shell.c | ||
---|---|---|
1637 | 1637 |
{ |
1638 | 1638 |
eventflags = chEvtGetAndClearFlags(&((aos_shell_t*)shell)->os.eventListener); |
1639 | 1639 |
// handle shutdown/restart events |
1640 |
if (eventflags & AOS_SYSTEM_EVENTFLAGS_SHUTDOWN) { |
|
1640 |
if (eventflags & AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK) {
|
|
1641 | 1641 |
chThdTerminate(((aos_shell_t*)shell)->thread); |
1642 | 1642 |
} else { |
1643 | 1643 |
// print an error message |
core/src/aos_system.c | ||
---|---|---|
594 | 594 |
// handle argument |
595 | 595 |
else { |
596 | 596 |
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--hibernate") == 0) { |
597 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_HIBERNATE); |
|
597 |
// broadcast shutdown event |
|
598 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_HIBERNATE); |
|
599 |
// set terminate flag so no further prompt will be printed |
|
598 | 600 |
chThdTerminate(chThdGetSelfX()); |
599 | 601 |
return AOS_OK; |
600 | 602 |
} |
601 | 603 |
else if (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--deepsleep") == 0) { |
602 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP); |
|
604 |
// broadcast shutdown event |
|
605 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_DEEPSLEEP); |
|
606 |
// set terminate flag so no further prompt will be printed |
|
603 | 607 |
chThdTerminate(chThdGetSelfX()); |
604 | 608 |
return AOS_OK; |
605 | 609 |
} |
606 | 610 |
else if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--transportation") == 0) { |
607 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION); |
|
611 |
// broadcast shutdown event |
|
612 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_TRANSPORTATION); |
|
613 |
// set terminate flag so no further prompt will be printed |
|
608 | 614 |
chThdTerminate(chThdGetSelfX()); |
609 | 615 |
return AOS_OK; |
610 | 616 |
} |
611 | 617 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--restart") == 0) { |
612 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_RESTART); |
|
618 |
// broadcast shutdown event |
|
619 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_RESTART); |
|
620 |
// set terminate flag so no further prompt will be printed |
|
613 | 621 |
chThdTerminate(chThdGetSelfX()); |
614 | 622 |
return AOS_OK; |
615 | 623 |
} |
... | ... | |
622 | 630 |
(void)argv; |
623 | 631 |
(void)argc; |
624 | 632 |
|
625 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN); |
|
633 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_MASK);
|
|
626 | 634 |
chThdTerminate(chThdGetSelfX()); |
627 | 635 |
return AOS_OK; |
628 | 636 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
629 | 637 |
} |
630 | 638 |
|
631 | 639 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
640 |
|
|
632 | 641 |
/** |
633 | 642 |
* @brief Callback function for the kernel:test shell command. |
634 | 643 |
* |
... | ... | |
1039 | 1048 |
|
1040 | 1049 |
switch (shutdown) { |
1041 | 1050 |
case AOS_SHUTDOWN_PASSIVE: |
1042 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN); |
|
1051 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN_PASSIVE);
|
|
1043 | 1052 |
aosprintf("shutdown request received...\n"); |
1044 | 1053 |
break; |
1045 | 1054 |
case AOS_SHUTDOWN_HIBERNATE: |
1046 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_HIBERNATE); |
|
1047 | 1055 |
aosprintf("shutdown to hibernate mode...\n"); |
1048 | 1056 |
break; |
1049 | 1057 |
case AOS_SHUTDOWN_DEEPSLEEP: |
1050 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_DEEPSLEEP); |
|
1051 | 1058 |
aosprintf("shutdown to deepsleep mode...\n"); |
1052 | 1059 |
break; |
1053 | 1060 |
case AOS_SHUTDOWN_TRANSPORTATION: |
1054 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_TRANSPORTATION); |
|
1055 | 1061 |
aosprintf("shutdown to transportation mode...\n"); |
1056 | 1062 |
break; |
1057 | 1063 |
case AOS_SHUTDOWN_RESTART: |
1058 |
chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_RESTART); |
|
1059 | 1064 |
aosprintf("restarting system...\n"); |
1060 | 1065 |
break; |
1061 | 1066 |
// must never occur |
Also available in: Unified diff