8000 atmel-samd: Fixup autoreset after switching boot to running once. · sparkfun/circuitpython@b1925b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1925b1

Browse files
committed
atmel-samd: Fixup autoreset after switching boot to running once.
1 parent 3f5028c commit b1925b1

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

atmel-samd/autoreload.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ void autoreload_start() {
6464

6565
void autoreload_stop() {
6666
autoreload_delay_ms = 0;
67+
reload_next_character = false;
6768
}

atmel-samd/bindings/samd/__init__.c

Lines changed: 2 additions & 2 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ MP_DEFINE_CONST_FUN_OBJ_0(samd_enable_autoreload_obj, samd_enable_autoreload);
4747

4848
//| .. method:: disable_autoreload()
4949
//|
50-
//| Disable autoreload based on USB file write activity until the next reload
51-
//| or until `enable_autoreload` is called.
50+
//| Disable autoreload based on USB file write activity until
51+
//| `enable_autoreload` is called.
5252
//|
5353
STATIC mp_obj_t samd_disable_autoreload(void) {
5454
autoreload_disable();

atmel-samd/main.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ void reset_mp(void) {
118118
reset_status_led();
119119
new_status_color(0x8f008f);
120120
autoreload_stop();
121-
autoreload_enable();
122121

123122
// Sync the file systems in case any used RAM from the GC to cache. As soon
124123
// as we re-init the GC all bets are off on the cache.
@@ -249,6 +248,8 @@ bool start_mp(safe_mode_t safe_mode) {
249248
mp_hal_stdout_tx_str("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
250249
} else if (safe_mode != NO_SAFE_MODE) {
251250
mp_hal_stdout_tx_str("Running in safe mode! Auto-reload is off.\r\n");
251+
} else if (!autoreload_is_enabled()) {
252+
mp_hal_stdout_tx_str("Auto-reload is off.\r\n");
252253
}
253254
}
254255
#endif
@@ -320,10 +321,12 @@ bool start_mp(safe_mode_t safe_mode) {
320321
mp_hal_stdout_tx_str("\r\n\r\n");
321322
}
322323

323-
if (!cdc_enabled_at_start && autoreload_is_enabled()) {
324-
mp_hal_stdout_tx_str("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
325-
} else {
326-
mp_hal_stdout_tx_str("Auto-reload is off.\r\n");
324+
if (!cdc_enabled_at_start) {
325+
if (autoreload_is_enabled()) {
326+
mp_hal_stdout_tx_str("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\r\n");
327+
} else {
328+
mp_hal_stdout_tx_str("Auto-reload is off.\r\n");
329+
}
327330
}
328331
if (safe_mode != NO_SAFE_MODE) {
329332
mp_hal_stdout_tx_str("\r\nYou are running in safe mode which means something really bad happened.\r\n");
@@ -618,13 +621,17 @@ int main(void) {
618621
for (;;) {
619622
if (!skip_repl) {
620623
// The REPL mode can change, or it can request a reload.
624+
bool autoreload_on = autoreload_is_enabled();
621625
autoreload_disable();
622626
new_status_color(REPL_RUNNING);
623627
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
624628
exit_code = pyexec_raw_repl();
625629
} else {
626630
exit_code = pyexec_friendly_repl();
627631
}
632+
if (autoreload_on) {
633+
autoreload_enable();
634+
}
628635
reset_samd21();
629636
reset_mp();
630637
}

atmel-samd/mphalport.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ int receive_usb(void) {
131131
return 0;
132132
}
133133

134-
// Disable autoreload if someone is using the repl.
135-
autoreload_disable();
136-
137134
// Copy from head.
138135
cpu_irq_disable();
139136
int data = usb_rx_buf[usb_rx_buf_head];

0 commit comments

Comments
 (0)
0