cc3200: Implement Sleep.wake_reason()
This commit is contained in:
parent
71d482df47
commit
f54bdecff2
|
@ -380,7 +380,7 @@ void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) {
|
|||
//*****************************************************************************
|
||||
|
||||
__attribute__ ((section (".boot")))
|
||||
void wlan_init0 (void) {
|
||||
void wlan_pre_init (void) {
|
||||
// create the wlan lock
|
||||
ASSERT(OSI_OK == sl_LockObjCreate(&wlan_LockObj, "WlanLock"));
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ extern _SlLockObj_t wlan_LockObj;
|
|||
/******************************************************************************
|
||||
DECLARE PUBLIC FUNCTIONS
|
||||
******************************************************************************/
|
||||
extern void wlan_init0 (void);
|
||||
extern void wlan_pre_init (void);
|
||||
extern modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ssid_len, uint8_t sec,
|
||||
const char *key, uint8_t key_len, uint8_t channel);
|
||||
extern void wlan_first_start (void);
|
||||
|
|
|
@ -123,6 +123,7 @@ STATIC nvic_reg_store_t *nvic_reg_store;
|
|||
STATIC pybsleep_data_t pybsleep_data = {NULL, NULL, NULL, 0};
|
||||
volatile arm_cm4_core_regs_t vault_arm_registers;
|
||||
STATIC pybsleep_reset_cause_t pybsleep_reset_cause = PYB_SLP_PWRON_RESET;
|
||||
STATIC pybsleep_reset_cause_t pybsleep_wake_reason = PYB_SLP_WAKED_PWRON;
|
||||
|
||||
/******************************************************************************
|
||||
DECLARE PRIVATE FUNCTIONS
|
||||
|
@ -179,6 +180,17 @@ void pybsleep_init0 (void) {
|
|||
}
|
||||
else {
|
||||
pybsleep_reset_cause = PYB_SLP_HIB_RESET;
|
||||
// set the correct wake reason
|
||||
switch (MAP_PRCMHibernateWakeupCauseGet()) {
|
||||
case PRCM_HIB_WAKEUP_CAUSE_SLOW_CLOCK:
|
||||
pybsleep_wake_reason = PYB_SLP_WAKED_BY_RTC;
|
||||
break;
|
||||
case PRCM_HIB_WAKEUP_CAUSE_GPIO:
|
||||
pybsleep_wake_reason = PYB_SLP_WAKED_BY_GPIO;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -410,15 +422,18 @@ STATIC void PRCMInterruptHandler (void) {
|
|||
switch (MAP_PRCMLPDSWakeupCauseGet()) {
|
||||
case PRCM_LPDS_HOST_IRQ:
|
||||
mpcallback_handler(pybsleep_data.wlan_lpds_wake_cb);
|
||||
pybsleep_wake_reason = PYB_SLP_WAKED_BY_WLAN;
|
||||
break;
|
||||
case PRCM_LPDS_GPIO:
|
||||
mpcallback_handler(pybsleep_data.gpio_lpds_wake_cb);
|
||||
pybsleep_wake_reason = PYB_SLP_WAKED_BY_GPIO;
|
||||
break;
|
||||
case PRCM_LPDS_TIMER:
|
||||
// disable the timer as a wake-up source
|
||||
pybsleep_data.timer_wake_pwrmode &= ~PYB_PWR_MODE_LPDS;
|
||||
MAP_PRCMLPDSWakeupSourceDisable(PRCM_LPDS_TIMER);
|
||||
mpcallback_handler(pybsleep_data.timer_lpds_wake_cb);
|
||||
pybsleep_wake_reason = PYB_SLP_WAKED_BY_RTC;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -630,7 +645,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_sleep_reset_cause_obj, pyb_sleep_reset_caus
|
|||
/// \function wake_reason()
|
||||
/// Returns the wake up reson from ldps or hibernate
|
||||
STATIC mp_obj_t pyb_sleep_wake_reason (mp_obj_t self_in) {
|
||||
return mp_const_none;
|
||||
return MP_OBJ_NEW_SMALL_INT(pybsleep_wake_reason);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_sleep_wake_reason_obj, pyb_sleep_wake_reason);
|
||||
|
||||
|
@ -646,13 +661,13 @@ STATIC const mp_map_elem_t pybsleep_locals_dict_table[] = {
|
|||
{ MP_OBJ_NEW_QSTR(MP_QSTR_ACTIVE), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_ACTIVE) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SUSPENDED), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_LPDS) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_HIBERNATING), MP_OBJ_NEW_SMALL_INT(PYB_PWR_MODE_HIBERNATE) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_PWR_ON_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_PWRON_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_POWER_ON), MP_OBJ_NEW_SMALL_INT(PYB_SLP_PWRON_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_HARD_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_HARD_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_WDT_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WDT_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_HIB_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_HIB_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SOFT_RESET), MP_OBJ_NEW_SMALL_INT(PYB_SLP_SOFT_RESET) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_WLAN_WAKE), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WAKED_BY_WLAN) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_PIN_WAKE), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WAKED_BY_PIN) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_PIN_WAKE), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WAKED_BY_GPIO) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_RTC_WAKE), MP_OBJ_NEW_SMALL_INT(PYB_SLP_WAKED_BY_RTC) },
|
||||
};
|
||||
|
||||
|
|
|
@ -42,19 +42,17 @@ typedef enum {
|
|||
PYB_SLP_HARD_RESET,
|
||||
PYB_SLP_WDT_RESET,
|
||||
PYB_SLP_HIB_RESET,
|
||||
PYB_SLP_SOFT_RESET,
|
||||
|
||||
PYB_SLP_SOFT_RESET
|
||||
} pybsleep_reset_cause_t;
|
||||
|
||||
typedef enum {
|
||||
PYB_SLP_WAKED_PWRON = 0,
|
||||
PYB_SLP_WAKED_BY_WLAN,
|
||||
PYB_SLP_WAKED_BY_PIN,
|
||||
PYB_SLP_WAKED_BY_GPIO,
|
||||
PYB_SLP_WAKED_BY_RTC
|
||||
|
||||
} pybsleep_wake_reason_t;
|
||||
|
||||
typedef void (*WakeUpCB_t)(const mp_obj_t self);
|
||||
typedef void (*DeinitCB_t)(const mp_obj_t self);
|
||||
|
||||
/******************************************************************************
|
||||
DECLARE EXPORTED VARIABLES
|
||||
|
|
|
@ -273,7 +273,7 @@ STATIC void mptask_pre_init (void) {
|
|||
pybsleep_pre_init();
|
||||
|
||||
// this one allocates mameory for the WLAN semaphore
|
||||
wlan_init0();
|
||||
wlan_pre_init();
|
||||
|
||||
#if MICROPY_HW_HAS_SDCARD
|
||||
pybsd_init0();
|
||||
|
|
|
@ -305,7 +305,7 @@ Q(wake_reason)
|
|||
Q(ACTIVE)
|
||||
Q(SUSPENDED)
|
||||
Q(HIBERNATING)
|
||||
Q(PWR_ON_RESET)
|
||||
Q(POWER_ON)
|
||||
Q(HARD_RESET)
|
||||
Q(WDT_RESET)
|
||||
Q(HIB_RESET)
|
||||
|
|
Loading…
Reference in New Issue