From 0e96d1b3f1cdcac48ef966d8517dea38dfff8cec Mon Sep 17 00:00:00 2001 From: danicampora Date: Wed, 18 Mar 2015 21:49:48 +0100 Subject: [PATCH] cc3200: Add parameter to wlan_stop() for custom timeout values. --- cc3200/mods/modpyb.c | 7 ++----- cc3200/mods/modwlan.c | 4 ++-- cc3200/mods/modwlan.h | 3 ++- cc3200/mods/pybpin.c | 4 ++-- cc3200/mods/pybsleep.c | 2 +- cc3200/mptask.c | 5 ++--- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cc3200/mods/modpyb.c b/cc3200/mods/modpyb.c index 714019ceb9..66e9342325 100644 --- a/cc3200/mods/modpyb.c +++ b/cc3200/mods/modpyb.c @@ -82,11 +82,8 @@ extern OsiTaskHandle xSimpleLinkSpawnTaskHndl; /// Resets the pyboard in a manner similar to pushing the external RESET /// button. STATIC mp_obj_t pyb_hard_reset(void) { -#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP) - // disable wlan services - wlan_stop_servers(); -#endif - wlan_stop(); + // disable wlan + wlan_stop(SL_STOP_TIMEOUT_LONG); // perform a SoC reset PRCMSOCReset(); return mp_const_none; diff --git a/cc3200/mods/modwlan.c b/cc3200/mods/modwlan.c index 6ba0d6173a..d20fa3d5f0 100644 --- a/cc3200/mods/modwlan.c +++ b/cc3200/mods/modwlan.c @@ -529,7 +529,7 @@ void wlan_update(void) { } // call this function to disable the complete WLAN subsystem before a system reset -void wlan_stop (void) { +void wlan_stop (uint32_t timeout) { if (wlan_obj.mode >= 0) { #if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP) // Stop all other processes using the wlan engine @@ -539,7 +539,7 @@ void wlan_stop (void) { #endif sl_LockObjLock (&wlan_LockObj, SL_OS_WAIT_FOREVER); wlan_obj.mode = -1; - sl_Stop(SL_STOP_TIMEOUT); + sl_Stop(MAX(timeout, SL_STOP_TIMEOUT)); } } diff --git a/cc3200/mods/modwlan.h b/cc3200/mods/modwlan.h index 0ad29d855d..d8c7a4f88e 100644 --- a/cc3200/mods/modwlan.h +++ b/cc3200/mods/modwlan.h @@ -33,6 +33,7 @@ #define SIMPLELINK_SPAWN_TASK_PRIORITY 3 #define SIMPLELINK_TASK_STACK_SIZE 2048 #define SL_STOP_TIMEOUT 35 +#define SL_STOP_TIMEOUT_LONG 255 /****************************************************************************** DEFINE TYPES @@ -56,7 +57,7 @@ extern void wlan_init0 (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); -extern void wlan_stop (void); +extern void wlan_stop (uint32_t timeout); extern void wlan_get_mac (uint8_t *macAddress); extern void wlan_get_ip (uint32_t *ip); extern void wlan_stop_servers (void); diff --git a/cc3200/mods/pybpin.c b/cc3200/mods/pybpin.c index 04825d52b8..aba4f65fed 100644 --- a/cc3200/mods/pybpin.c +++ b/cc3200/mods/pybpin.c @@ -331,12 +331,12 @@ STATIC void pin_extint_enable (mp_obj_t self_in) { MAP_PRCMHibernateWakeupSourceDisable(hib_pin); } } - // if idx is invalid, the the pin supports active interrupts for sure + // if idx is invalid, the pin supports active interrupts for sure if (idx >= PYBPIN_NUM_WAKE_PINS || pybpin_wake_pin[idx].active) { MAP_GPIOIntClear(self->port, self->bit); MAP_GPIOIntEnable(self->port, self->bit); } - // in case in was enabled before + // in case it was enabled before else if (idx < PYBPIN_NUM_WAKE_PINS && !pybpin_wake_pin[idx].active) { MAP_GPIOIntDisable(self->port, self->bit); } diff --git a/cc3200/mods/pybsleep.c b/cc3200/mods/pybsleep.c index 2a519f5e94..52dafd9d41 100644 --- a/cc3200/mods/pybsleep.c +++ b/cc3200/mods/pybsleep.c @@ -613,7 +613,7 @@ STATIC mp_obj_t pyb_sleep_hibernate (mp_obj_t self_in) { return mp_const_none; } } - wlan_stop(); + wlan_stop(SL_STOP_TIMEOUT); pybsleep_flash_powerdown(); MAP_PRCMHibernateEnter(); return mp_const_none; diff --git a/cc3200/mptask.c b/cc3200/mptask.c index 8697301e18..2dcc5a9153 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -246,9 +246,8 @@ soft_reset_exit: // wait for all bus transfers to complete HAL_Delay(50); - // disable wlan services - wlan_stop_servers(); - wlan_stop(); + // disable wlan + wlan_stop(SL_STOP_TIMEOUT_LONG); // de-initialize the stdio uart if (pyb_stdio_uart) {