Skip to content

Commit

Permalink
atmel-samd: Ensure pin state for first script run because we don't
Browse files Browse the repository at this point in the history
know the post-bootloader state.

Also, color the status LED purple for ValueErrors which are used to
indicate a pin in use.
  • Loading branch information
tannewt committed Jan 13, 2017
1 parent 6c858c7 commit 35a5d44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions atmel-samd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions atmel-samd/rgb_led_colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
#define SYNTAX_ERROR CYAN
#define NAME_ERROR WHITE
#define OS_ERROR ORANGE
#define VALUE_ERROR PURPLE
#define OTHER_ERROR YELLOW

0 comments on commit 35a5d44

Please sign in to comment.