Skip to content

Commit e15f819

Browse files
author
Daniel Campora
committed
cc3200: Keep WLAN enabled during the soft reset.
1 parent 9d3588f commit e15f819

2 files changed

Lines changed: 29 additions & 31 deletions

File tree

cc3200/mods/pybsleep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef enum {
5454
} pybsleep_wake_reason_t;
5555

5656
typedef void (*WakeUpCB_t)(const mp_obj_t self);
57+
typedef void (*DeinitCB_t)(const mp_obj_t self);
5758

5859
/******************************************************************************
5960
DECLARE EXPORTED VARIABLES

cc3200/mptask.c

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static const char fresh_boot_py[] = "# boot.py -- run on boot-up\r\n"
9898
******************************************************************************/
9999

100100
void TASK_Micropython (void *pvParameters) {
101-
// Initialize the garbage collector with the top of our stack
101+
// initialize the garbage collector with the top of our stack
102102
uint32_t sp = gc_helper_get_sp();
103103
gc_collect_init (sp);
104104
bool safeboot = false;
@@ -111,7 +111,7 @@ void TASK_Micropython (void *pvParameters) {
111111
// GC init
112112
gc_init(&_boot, &_eheap);
113113

114-
// Micro Python init
114+
// MicroPython init
115115
mp_init();
116116
mp_obj_list_init(mp_sys_path, 0);
117117
mp_obj_list_init(mp_sys_argv, 0);
@@ -131,6 +131,9 @@ void TASK_Micropython (void *pvParameters) {
131131
rng_init0();
132132
#endif
133133

134+
// we are alive, so let the world know it
135+
mperror_enable_heartbeat();
136+
134137
// configure stdio uart pins with the correct af
135138
// param 3 ("mode") is DON'T CARE" for AFs others than GPIO
136139
pin_config ((pin_obj_t *)&pin_GPIO1, PIN_MODE_3, 0, PIN_TYPE_STD, PIN_STRENGTH_2MA);
@@ -142,26 +145,28 @@ void TASK_Micropython (void *pvParameters) {
142145
};
143146
pyb_stdio_uart = pyb_uart_type.make_new((mp_obj_t)&pyb_uart_type, MP_ARRAY_SIZE(args), 0, args);
144147

145-
mperror_enable_heartbeat();
148+
pybsleep_reset_cause_t rstcause = pybsleep_get_reset_cause();
149+
if (rstcause < PYB_SLP_SOFT_RESET) {
150+
if (rstcause == PYB_SLP_HIB_RESET) {
151+
// when waking up from hibernate we just want
152+
// to enable simplelink and leave it as is
153+
wlan_first_start();
154+
}
155+
else {
156+
// only if not comming out of hibernate or a soft reset
157+
mptask_enter_ap_mode();
158+
#ifndef DEBUG
159+
safeboot = PRCMIsSafeBootRequested();
160+
#endif
161+
}
146162

147-
if (pybsleep_get_reset_cause() < PYB_SLP_HIB_RESET) {
148-
// only if not comming out of hibernate or a soft reset
149-
mptask_enter_ap_mode();
150-
#ifndef DEBUG
151-
safeboot = PRCMIsSafeBootRequested();
152-
#endif
153-
} else {
154-
// when waking up from hibernate we just want
155-
// to enable simplelink and leave it as is
156-
wlan_first_start();
163+
// enable telnet and ftp
164+
servers_start();
157165
}
158166

159167
// initialize the serial flash file system
160168
mptask_init_sflash_filesystem();
161169

162-
// enable telnet and ftp servers
163-
servers_start();
164-
165170
// append the SFLASH paths to the system path
166171
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_SFLASH));
167172
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_SFLASH_slash_LIB));
@@ -185,14 +190,14 @@ void TASK_Micropython (void *pvParameters) {
185190
}
186191
}
187192

188-
// Now we initialise sub-systems that need configuration from boot.py,
193+
// now we initialise sub-systems that need configuration from boot.py,
189194
// or whose initialisation can be safely deferred until after running
190195
// boot.py.
191196

192-
// At this point everything is fully configured and initialised.
197+
// at this point everything is fully configured and initialised.
193198

194199
if (!safeboot) {
195-
// Run the main script from the current directory.
200+
// run the main script from the current directory.
196201
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
197202
const char *main_py;
198203
if (MP_STATE_PORT(pyb_config_main) == MP_OBJ_NULL) {
@@ -214,8 +219,8 @@ void TASK_Micropython (void *pvParameters) {
214219
}
215220
}
216221

217-
// Main script is finished, so now go into REPL mode.
218-
// The REPL mode can change, or it can request a soft reset.
222+
// main script is finished, so now go into REPL mode.
223+
// the REPL mode can change, or it can request a soft reset.
219224
for ( ; ; ) {
220225
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
221226
if (pyexec_raw_repl() != 0) {
@@ -233,22 +238,14 @@ void TASK_Micropython (void *pvParameters) {
233238
// soft reset
234239
pybsleep_signal_soft_reset();
235240

241+
printf("WiPy: soft reset\n");
242+
236243
sflash_disk_flush();
237244

238245
#if MICROPY_HW_HAS_SDCARD
239246
pybsd_deinit();
240247
#endif
241248

242-
printf("WiPy: soft reset\n");
243-
244-
// disable wlan
245-
wlan_stop(SL_STOP_TIMEOUT_LONG);
246-
247-
// de-initialize the stdio uart
248-
if (pyb_stdio_uart) {
249-
pyb_uart_deinit(pyb_stdio_uart);
250-
}
251-
252249
goto soft_reset;
253250
}
254251

0 commit comments

Comments
 (0)