From 35a5d44399204eb0b72786828436b586cd6e9930 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 13 Jan 2017 15:39:50 -0800 Subject: atmel-samd: Ensure pin state for first script run because we don't know the post-bootloader state. Also, color the status LED purple for ValueErrors which are used to indicate a pin in use. --- atmel-samd/main.c | 7 ++++--- atmel-samd/rgb_led_colors.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 89de725ec..5285a8c6e 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -305,6 +305,8 @@ bool start_mp(void) { new_status_color(NAME_ERROR); } else if (mp_obj_is_subclass_fast(result.exception_type, &mp_type_OSError)) { new_status_color(OS_ERROR); + } else if (mp_obj_is_subclass_fast(result.exception_type, &mp_type_ValueError)) { + new_status_color(VALUE_ERROR); } else { new_status_color(OTHER_ERROR); } @@ -424,7 +426,6 @@ int main(int argc, char **argv) { // stack so the GC can account for objects that may be referenced by the // stack between here and where gc_collect is called. stack_top = (char*)&stack_dummy; - reset_mp(); // Initialise the local flash filesystem after the gc in case we need to // grab memory from it. Create it if needed, mount in on /flash, and set it @@ -454,9 +455,9 @@ int main(int argc, char **argv) { if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { mp_hal_stdout_tx_str("soft reboot\r\n"); - reset_samd21(); - reset_mp(); } + reset_samd21(); + reset_mp(); first_run = false; skip_repl = start_mp(); } else if (exit_code != 0) { diff --git a/atmel-samd/rgb_led_colors.h b/atmel-samd/rgb_led_colors.h index cfdb93690..525b8c545 100644 --- a/atmel-samd/rgb_led_colors.h +++ b/atmel-samd/rgb_led_colors.h @@ -29,4 +29,5 @@ #define SYNTAX_ERROR CYAN #define NAME_ERROR WHITE #define OS_ERROR ORANGE +#define VALUE_ERROR PURPLE #define OTHER_ERROR YELLOW -- cgit v1.2.3