Merge pull request #62 from glennrub/raw_repl_support

nrf5: Updating main.c to support RAW REPL.
This commit is contained in:
Daniel Tralamazza 2017-06-03 22:53:16 +02:00 committed by GitHub
commit e619b837c0
2 changed files with 14 additions and 3 deletions

View File

@ -43,6 +43,8 @@ const char * nrf5_help_text =
HELP_TEXT_SD HELP_TEXT_SD
#endif #endif
"Control commands:\n" "Control commands:\n"
" CTRL-A -- on a blank line, enter raw REPL mode\n"
" CTRL-B -- on a blank line, enter normal REPL mode\n"
" CTRL-D -- on a blank line, do a soft reset of the board\n" " CTRL-D -- on a blank line, do a soft reset of the board\n"
" CTRL-E -- on a blank line, enter paste mode\n" " CTRL-E -- on a blank line, enter paste mode\n"
"\n" "\n"

View File

@ -83,6 +83,7 @@ extern uint32_t _heap_end;
int main(int argc, char **argv) { int main(int argc, char **argv) {
soft_reset:
mp_stack_set_top(&_ram_end); mp_stack_set_top(&_ram_end);
// Stack limit should be less than real stack size, so we have a chance // Stack limit should be less than real stack size, so we have a chance
@ -197,9 +198,15 @@ pin_init0();
#endif #endif
for (;;) { for (;;) {
ret_code = pyexec_friendly_repl(); if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
if (ret_code != 0) { if (pyexec_raw_repl() != 0) {
break; break;
}
} else {
ret_code = pyexec_friendly_repl();
if (ret_code != 0) {
break;
}
} }
} }
@ -207,6 +214,8 @@ pin_init0();
if (ret_code == PYEXEC_FORCED_EXIT) { if (ret_code == PYEXEC_FORCED_EXIT) {
NVIC_SystemReset(); NVIC_SystemReset();
} else {
goto soft_reset;
} }
return 0; return 0;