From 9462148a8ae4942831a91fb77c6e429280bbcb21 Mon Sep 17 00:00:00 2001 From: cap9qd <33727568+cap9qd@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:53:03 -0600 Subject: [PATCH] Updates to break out wakeup reasons. Per https://github.com/libretiny-eu/libretiny/issues/234 --- cores/beken-72xx/base/api/lt_device.c | 6 ++-- cores/common/base/api/lt_device.c | 8 +++-- cores/common/base/api/lt_device.h | 45 ++++++++++++++++----------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/cores/beken-72xx/base/api/lt_device.c b/cores/beken-72xx/base/api/lt_device.c index 200802724..01cbcba0e 100644 --- a/cores/beken-72xx/base/api/lt_device.c +++ b/cores/beken-72xx/base/api/lt_device.c @@ -31,10 +31,12 @@ lt_reboot_reason_t lt_get_reboot_reason() { case RESET_SOURCE_CRASH_UNUSED: case RESET_SOURCE_CRASH_PER_XAT0: return REBOOT_REASON_CRASH; + case RESET_SOURCE_DEEPPS_USB: + return REBOOT_REASON_SLEEP_USB; case RESET_SOURCE_DEEPPS_GPIO: + return REBOOT_REASON_SLEEP_GPIO; case RESET_SOURCE_DEEPPS_RTC: - case RESET_SOURCE_DEEPPS_USB: - return REBOOT_REASON_SLEEP; + return REBOOT_REASON_SLEEP_RTC; default: return REBOOT_REASON_UNKNOWN; } diff --git a/cores/common/base/api/lt_device.c b/cores/common/base/api/lt_device.c index 983ddadad..af8cd6875 100644 --- a/cores/common/base/api/lt_device.c +++ b/cores/common/base/api/lt_device.c @@ -62,8 +62,12 @@ const char *lt_get_reboot_reason_name(lt_reboot_reason_t reason) { return "WDT Reset"; case REBOOT_REASON_CRASH: return "Crash"; - case REBOOT_REASON_SLEEP: - return "Sleep Wakeup"; + case REBOOT_REASON_SLEEP_GPIO: + return "Sleep Wakeup (GPIO)"; + case REBOOT_REASON_SLEEP_RTC: + return "Sleep Wakeup (RTC)"; + case REBOOT_REASON_SLEEP_USB: + return "Sleep Wakeup (USB)"; case REBOOT_REASON_DEBUGGER: return "Debugger"; default: diff --git a/cores/common/base/api/lt_device.h b/cores/common/base/api/lt_device.h index 5074c2820..bb77a9a3c 100644 --- a/cores/common/base/api/lt_device.h +++ b/cores/common/base/api/lt_device.h @@ -4,32 +4,39 @@ #include -#define RESET_REASON_UNKNOWN REBOOT_REASON_UNKNOWN -#define RESET_REASON_POWER REBOOT_REASON_POWER -#define RESET_REASON_BROWNOUT REBOOT_REASON_BROWNOUT -#define RESET_REASON_HARDWARE REBOOT_REASON_HARDWARE -#define RESET_REASON_SOFTWARE REBOOT_REASON_SOFTWARE -#define RESET_REASON_WATCHDOG REBOOT_REASON_WATCHDOG -#define RESET_REASON_CRASH REBOOT_REASON_CRASH -#define RESET_REASON_SLEEP REBOOT_REASON_SLEEP -#define RESET_REASON_MAX REBOOT_REASON_MAX +#define RESET_REASON_UNKNOWN REBOOT_REASON_UNKNOWN +#define RESET_REASON_POWER REBOOT_REASON_POWER +#define RESET_REASON_BROWNOUT REBOOT_REASON_BROWNOUT +#define RESET_REASON_HARDWARE REBOOT_REASON_HARDWARE +#define RESET_REASON_SOFTWARE REBOOT_REASON_SOFTWARE +#define RESET_REASON_WATCHDOG REBOOT_REASON_WATCHDOG +#define RESET_REASON_CRASH REBOOT_REASON_CRASH +#define RESET_REASON_SLEEP_GPIO REBOOT_REASON_SLEEP_GPIO +#define RESET_REASON_SLEEP_RTC REBOOT_REASON_SLEEP_RTC +#define RESET_REASON_SLEEP_USB REBOOT_REASON_SLEEP_USB +#define RESET_REASON_MAX REBOOT_REASON_MAX /** * @brief Reset reason enumeration. */ typedef enum { - REBOOT_REASON_UNKNOWN = 1, - REBOOT_REASON_POWER = 2, - REBOOT_REASON_BROWNOUT = 3, - REBOOT_REASON_HARDWARE = 4, - REBOOT_REASON_SOFTWARE = 5, - REBOOT_REASON_WATCHDOG = 6, - REBOOT_REASON_CRASH = 7, - REBOOT_REASON_SLEEP = 8, - REBOOT_REASON_DEBUGGER = 9, - REBOOT_REASON_MAX = 10, + REBOOT_REASON_UNKNOWN = 1, + REBOOT_REASON_POWER = 2, + REBOOT_REASON_BROWNOUT = 3, + REBOOT_REASON_HARDWARE = 4, + REBOOT_REASON_SOFTWARE = 5, + REBOOT_REASON_WATCHDOG = 6, + REBOOT_REASON_CRASH = 7, + REBOOT_REASON_SLEEP_GPIO = 8, + REBOOT_REASON_SLEEP_RTC = 9, + REBOOT_REASON_SLEEP_USB = 10, + REBOOT_REASON_DEBUGGER = 11, + REBOOT_REASON_MAX = 12, } lt_reboot_reason_t; +//RESET_REASON_SLEEP depricated +#define RESET_REASON_SLEEP REBOOT_REASON_SLEEP_GPIO + /** * @brief Debugging mode enumeration. */