stm32/boardctrl: Add constants for reset mode values.

And use the same boardctrl.h header for both the application and mboot so
these constants are consistent.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2021-04-28 10:30:17 +10:00
parent 647fa63f9c
commit a72b8443ca
4 changed files with 26 additions and 13 deletions

View File

@@ -57,8 +57,8 @@ STATIC uint update_reset_mode(uint reset_mode) {
}
mp_hal_delay_ms(20);
if (i % 30 == 29) {
if (++reset_mode > 3) {
reset_mode = 1;
if (++reset_mode > BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM) {
reset_mode = BOARDCTRL_RESET_MODE_NORMAL;
}
led_state(2, reset_mode & 1);
led_state(3, reset_mode & 2);
@@ -97,8 +97,8 @@ STATIC uint update_reset_mode(uint reset_mode) {
if (!switch_get()) {
break;
}
if (++reset_mode > 3) {
reset_mode = 1;
if (++reset_mode > BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM) {
reset_mode = BOARDCTRL_RESET_MODE_NORMAL;
}
}
// Flash the selected reset mode
@@ -124,7 +124,7 @@ void boardctrl_before_soft_reset_loop(boardctrl_state_t *state) {
#if !MICROPY_HW_USES_BOOTLOADER
// Update the reset_mode via the default
// method which uses the board switch/button and LEDs.
state->reset_mode = update_reset_mode(1);
state->reset_mode = update_reset_mode(BOARDCTRL_RESET_MODE_NORMAL);
#endif
}
@@ -142,7 +142,8 @@ void boardctrl_top_soft_reset_loop(boardctrl_state_t *state) {
}
int boardctrl_run_boot_py(boardctrl_state_t *state) {
bool run_boot_py = state->reset_mode == 1 || state->reset_mode == 3;
bool run_boot_py = state->reset_mode == BOARDCTRL_RESET_MODE_NORMAL
|| state->reset_mode == BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM;
if (run_boot_py) {
// Run boot.py, if it exists.
@@ -174,7 +175,8 @@ int boardctrl_run_boot_py(boardctrl_state_t *state) {
}
int boardctrl_run_main_py(boardctrl_state_t *state) {
bool run_main_py = (state->reset_mode == 1 || state->reset_mode == 3)
bool run_main_py = (state->reset_mode == BOARDCTRL_RESET_MODE_NORMAL
|| state->reset_mode == BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM)
&& pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL;
if (run_main_py) {
@@ -205,5 +207,5 @@ void boardctrl_start_soft_reset(boardctrl_state_t *state) {
void boardctrl_end_soft_reset(boardctrl_state_t *state) {
// Set reset_mode to normal boot.
state->reset_mode = 1;
state->reset_mode = BOARDCTRL_RESET_MODE_NORMAL;
}