cc3200: Reenable active interrupts when waking from suspended mode.
This commit is contained in:
parent
0090c714ba
commit
4be44014ab
@ -50,5 +50,5 @@
|
|||||||
.af = PIN_MODE_0, \
|
.af = PIN_MODE_0, \
|
||||||
.strength = PIN_STRENGTH_4MA, \
|
.strength = PIN_STRENGTH_4MA, \
|
||||||
.mode = GPIO_DIR_MODE_IN, \
|
.mode = GPIO_DIR_MODE_IN, \
|
||||||
.used = false \
|
.isused = false, \
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ mp_obj_t mpcallback_new (mp_obj_t parent, mp_obj_t handler, const mp_cb_methods_
|
|||||||
self->handler = handler;
|
self->handler = handler;
|
||||||
self->parent = parent;
|
self->parent = parent;
|
||||||
self->methods = (mp_cb_methods_t *)methods;
|
self->methods = (mp_cb_methods_t *)methods;
|
||||||
|
self->isenabled = true;
|
||||||
// remove any old callback if present
|
// remove any old callback if present
|
||||||
mpcallback_remove(self->parent);
|
mpcallback_remove(self->parent);
|
||||||
mp_obj_list_append(&MP_STATE_PORT(mpcallback_obj_list), self);
|
mp_obj_list_append(&MP_STATE_PORT(mpcallback_obj_list), self);
|
||||||
@ -79,6 +80,16 @@ mpcallback_obj_t *mpcallback_find (mp_obj_t parent) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mpcallback_wake_all (void) {
|
||||||
|
// re-enable all active callback objects one by one
|
||||||
|
for (mp_uint_t i = 0; i < MP_STATE_PORT(mpcallback_obj_list).len; i++) {
|
||||||
|
mpcallback_obj_t *callback_obj = ((mpcallback_obj_t *)(MP_STATE_PORT(mpcallback_obj_list).items[i]));
|
||||||
|
if (callback_obj->isenabled) {
|
||||||
|
callback_obj->methods->enable(callback_obj->parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mpcallback_remove (const mp_obj_t parent) {
|
void mpcallback_remove (const mp_obj_t parent) {
|
||||||
mpcallback_obj_t *callback_obj;
|
mpcallback_obj_t *callback_obj;
|
||||||
if ((callback_obj = mpcallback_find(parent))) {
|
if ((callback_obj = mpcallback_find(parent))) {
|
||||||
@ -158,6 +169,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(callback_init_obj, 1, callback_init);
|
|||||||
STATIC mp_obj_t callback_enable (mp_obj_t self_in) {
|
STATIC mp_obj_t callback_enable (mp_obj_t self_in) {
|
||||||
mpcallback_obj_t *self = self_in;
|
mpcallback_obj_t *self = self_in;
|
||||||
self->methods->enable(self->parent);
|
self->methods->enable(self->parent);
|
||||||
|
self->isenabled = true;
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(callback_enable_obj, callback_enable);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(callback_enable_obj, callback_enable);
|
||||||
@ -167,6 +179,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(callback_enable_obj, callback_enable);
|
|||||||
STATIC mp_obj_t callback_disable (mp_obj_t self_in) {
|
STATIC mp_obj_t callback_disable (mp_obj_t self_in) {
|
||||||
mpcallback_obj_t *self = self_in;
|
mpcallback_obj_t *self = self_in;
|
||||||
self->methods->disable(self->parent);
|
self->methods->disable(self->parent);
|
||||||
|
self->isenabled = false;
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(callback_disable_obj, callback_disable);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(callback_disable_obj, callback_disable);
|
||||||
|
@ -49,6 +49,7 @@ typedef struct {
|
|||||||
mp_obj_t parent;
|
mp_obj_t parent;
|
||||||
mp_obj_t handler;
|
mp_obj_t handler;
|
||||||
mp_cb_methods_t *methods;
|
mp_cb_methods_t *methods;
|
||||||
|
bool isenabled;
|
||||||
} mpcallback_obj_t;
|
} mpcallback_obj_t;
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -63,6 +64,7 @@ extern const mp_obj_type_t pyb_callback_type;
|
|||||||
void mpcallback_init0 (void);
|
void mpcallback_init0 (void);
|
||||||
mp_obj_t mpcallback_new (mp_obj_t parent, mp_obj_t handler, const mp_cb_methods_t *methods);
|
mp_obj_t mpcallback_new (mp_obj_t parent, mp_obj_t handler, const mp_cb_methods_t *methods);
|
||||||
mpcallback_obj_t *mpcallback_find (mp_obj_t parent);
|
mpcallback_obj_t *mpcallback_find (mp_obj_t parent);
|
||||||
|
void mpcallback_wake_all (void);
|
||||||
void mpcallback_remove (const mp_obj_t parent);
|
void mpcallback_remove (const mp_obj_t parent);
|
||||||
void mpcallback_handler (mp_obj_t self_in);
|
void mpcallback_handler (mp_obj_t self_in);
|
||||||
uint mpcallback_translate_priority (uint priority);
|
uint mpcallback_translate_priority (uint priority);
|
||||||
|
@ -199,13 +199,10 @@ void pin_verify_af (uint af) {
|
|||||||
|
|
||||||
void pin_config (pin_obj_t *self, uint af, uint mode, uint type, uint strength) {
|
void pin_config (pin_obj_t *self, uint af, uint mode, uint type, uint strength) {
|
||||||
// configure the pin in analog mode
|
// configure the pin in analog mode
|
||||||
self->af = af;
|
self->af = af, self->mode = mode, self->type = type, self->strength = strength;
|
||||||
self->mode = mode;
|
|
||||||
self->type = type;
|
|
||||||
self->strength = strength;
|
|
||||||
pin_obj_configure ((const pin_obj_t *)self);
|
pin_obj_configure ((const pin_obj_t *)self);
|
||||||
// mark the pin as used
|
// mark the pin as used
|
||||||
self->used = true;
|
self->isused = true;
|
||||||
// register it with the sleep module
|
// register it with the sleep module
|
||||||
pybsleep_add ((const mp_obj_t)self, (WakeUpCB_t)pin_obj_configure);
|
pybsleep_add ((const mp_obj_t)self, (WakeUpCB_t)pin_obj_configure);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ typedef struct {
|
|||||||
uint8_t af;
|
uint8_t af;
|
||||||
uint8_t strength;
|
uint8_t strength;
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
bool used;
|
bool isused;
|
||||||
} pin_obj_t;
|
} pin_obj_t;
|
||||||
|
|
||||||
extern const mp_obj_type_t pin_type;
|
extern const mp_obj_type_t pin_type;
|
||||||
|
@ -322,12 +322,12 @@ STATIC NORETURN void pybsleep_suspend_enter (void) {
|
|||||||
nvic_reg_store->int_priority[i] = base_reg_addr[i];
|
nvic_reg_store->int_priority[i] = base_reg_addr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switch off the heartbeat led (this makes sure it will blink as soon as we wake up)
|
||||||
|
mperror_heartbeat_switch_off();
|
||||||
|
|
||||||
// park the gpio pins
|
// park the gpio pins
|
||||||
pybsleep_iopark();
|
pybsleep_iopark();
|
||||||
|
|
||||||
// turn-off the heartbeat led
|
|
||||||
mperror_heartbeat_switch_off();
|
|
||||||
|
|
||||||
// store the cpu registers
|
// store the cpu registers
|
||||||
sleep_store();
|
sleep_store();
|
||||||
|
|
||||||
@ -384,12 +384,15 @@ void pybsleep_suspend_exit (void) {
|
|||||||
// ungate the clock to the shared spi bus
|
// ungate the clock to the shared spi bus
|
||||||
MAP_PRCMPeripheralClkEnable(PRCM_SSPI, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
|
MAP_PRCMPeripheralClkEnable(PRCM_SSPI, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
|
||||||
|
|
||||||
// reinitialize simplelink's bus
|
// reinitialize simplelink's interface
|
||||||
sl_IfOpen (NULL, 0);
|
sl_IfOpen (NULL, 0);
|
||||||
|
|
||||||
// restore the configuration of all active peripherals
|
// restore the configuration of all active peripherals
|
||||||
pybsleep_obj_wakeup();
|
pybsleep_obj_wakeup();
|
||||||
|
|
||||||
|
// reconfigure all the previously enabled interrupts
|
||||||
|
mpcallback_wake_all();
|
||||||
|
|
||||||
// trigger a sw interrupt
|
// trigger a sw interrupt
|
||||||
MAP_IntPendSet(INT_PRCM);
|
MAP_IntPendSet(INT_PRCM);
|
||||||
|
|
||||||
@ -450,11 +453,11 @@ STATIC void pybsleep_iopark (void) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!pin->used) {
|
// enable a weak pull-down if the pin is unused
|
||||||
// enable the pull-down in unused pins
|
if (!pin->isused) {
|
||||||
MAP_PinConfigSet(pin->pin_num, pin->strength, PIN_TYPE_STD_PD);
|
MAP_PinConfigSet(pin->pin_num, pin->strength, PIN_TYPE_STD_PD);
|
||||||
}
|
}
|
||||||
// make the pin an input
|
// make it an input
|
||||||
MAP_PinDirModeSet(pin->pin_num, PIN_DIR_MODE_IN);
|
MAP_PinDirModeSet(pin->pin_num, PIN_DIR_MODE_IN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -610,8 +613,9 @@ STATIC mp_obj_t pyb_sleep_hibernate (mp_obj_t self_in) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wlan_stop(SL_STOP_TIMEOUT);
|
wlan_stop(SL_STOP_TIMEOUT);
|
||||||
mperror_heartbeat_switch_off();
|
|
||||||
pybsleep_flash_powerdown();
|
pybsleep_flash_powerdown();
|
||||||
|
// must be done just before entering hibernate mode
|
||||||
|
pybsleep_iopark();
|
||||||
MAP_PRCMHibernateEnter();
|
MAP_PRCMHibernateEnter();
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ STATIC void pyb_uart_print(void (*print)(void *env, const char *fmt, ...), void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \method init(baudrate, bits=8, parity=None, stop=1, *, timeout=1000, timeout_char=0, read_buf_len=128)
|
/// \method init(baudrate, bits=8, parity=None, stop=1, *, timeout=1000, timeout_char=0)
|
||||||
///
|
///
|
||||||
/// Initialise the UART bus with the given parameters:
|
/// Initialise the UART bus with the given parameters:
|
||||||
///
|
///
|
||||||
|
@ -110,7 +110,7 @@ static telnet_data_t telnet_data;
|
|||||||
static const char* telnet_welcome_msg = "Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n";
|
static const char* telnet_welcome_msg = "Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n";
|
||||||
static const char* telnet_request_user = "Login as:";
|
static const char* telnet_request_user = "Login as:";
|
||||||
static const char* telnet_request_password = "Password:";
|
static const char* telnet_request_password = "Password:";
|
||||||
static const char* telnet_invalid_loggin = "\r\nInvalid credentials, try again\r\n";
|
static const char* telnet_invalid_loggin = "\r\nInvalid credentials, try again.\r\n";
|
||||||
static const char* telnet_loggin_success = "\r\nLogin succeeded!\r\nType \"help()\" for more information.\r\n";
|
static const char* telnet_loggin_success = "\r\nLogin succeeded!\r\nType \"help()\" for more information.\r\n";
|
||||||
static const uint8_t telnet_options_user[] = // IAC WONT ECHO IAC WONT SUPPRESS_GO_AHEAD IAC WILL LINEMODE
|
static const uint8_t telnet_options_user[] = // IAC WONT ECHO IAC WONT SUPPRESS_GO_AHEAD IAC WILL LINEMODE
|
||||||
{ 255, 252, 1, 255, 252, 3, 255, 251, 34 };
|
{ 255, 252, 1, 255, 252, 3, 255, 251, 34 };
|
||||||
@ -217,10 +217,8 @@ void telnet_run (void) {
|
|||||||
break;
|
break;
|
||||||
case E_TELNET_STE_SUB_LOGGIN_SUCCESS:
|
case E_TELNET_STE_SUB_LOGGIN_SUCCESS:
|
||||||
if (E_TELNET_RESULT_OK == telnet_send_non_blocking((void *)telnet_loggin_success, strlen(telnet_loggin_success))) {
|
if (E_TELNET_RESULT_OK == telnet_send_non_blocking((void *)telnet_loggin_success, strlen(telnet_loggin_success))) {
|
||||||
// clear the current line
|
// clear the current line and force the prompt
|
||||||
telnet_reset_buffer();
|
telnet_reset_buffer();
|
||||||
// fake an "enter" key pressed to display the prompt
|
|
||||||
telnet_data.rxBuffer[telnet_data.rxWindex++] = '\r';
|
|
||||||
telnet_data.state= E_TELNET_STE_LOGGED_IN;
|
telnet_data.state= E_TELNET_STE_LOGGED_IN;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -478,7 +476,10 @@ static void telnet_reset (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void telnet_reset_buffer (void) {
|
static void telnet_reset_buffer (void) {
|
||||||
|
// erase any characters present in the current line
|
||||||
memset (telnet_data.rxBuffer, '\b', TELNET_RX_BUFFER_SIZE / 2);
|
memset (telnet_data.rxBuffer, '\b', TELNET_RX_BUFFER_SIZE / 2);
|
||||||
telnet_data.rxWindex = TELNET_RX_BUFFER_SIZE / 2;
|
telnet_data.rxWindex = TELNET_RX_BUFFER_SIZE / 2;
|
||||||
|
// fake an "enter" key pressed to display the prompt
|
||||||
|
telnet_data.rxBuffer[telnet_data.rxWindex++] = '\r';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user