From 9b04a8130effa8d8266e52a3699a1b7c0212f02d Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Thu, 13 Aug 2020 13:53:38 +0200 Subject: [PATCH] hw26: add factory reset function - check rs232 for break condition duration to invoke factory reset or recovery boot. same logic as reset button. - check rs232 break condition followed by command - 'f': factory reset - 'r': recovery boot --- board/nm/nmhw21/board.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index 7a32bbcaa4..b82882cab0 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -1235,9 +1235,6 @@ static int check_button(int time, bool button) state = INIT; } - /* TODO: Remove printf, puts */ - /* printf("button: state %d button %d -> ", state, button); */ - switch (state) { case INIT: if (button) { @@ -1293,13 +1290,9 @@ static int check_button(int time, bool button) break; } - /* printf("act %d\n", act); */ - return act; } -#if 0 - static int check_break_length(int time, bool rx_line) { /* @@ -1328,9 +1321,6 @@ static int check_break_length(int time, bool rx_line) wait_time = BREAK_DEB_TIME; } - /* TODO: Remove */ - /* printf("break length: state %d have_break_cond %d duration %d -> ", state, have_break_cond, duration); */ - switch (state) { case WAIT_BREAK: if (rx_line) { @@ -1400,13 +1390,9 @@ static int check_break_length(int time, bool rx_line) break; } - /* printf("act %d\n", act); */ - return act; } -#endif - static int check_break_command(int time, int has_input, int c) { /* @@ -1435,9 +1421,6 @@ static int check_break_command(int time, int has_input, int c) static int wait_time; - /* TODO: remove */ - /* printf("break command: state %d, input %d %02x -> ", state, has_input, c); */ - if (time == 0) { state = WAIT_BREAK; wait_time = BREAK_WAIT_TIME; @@ -1506,13 +1489,11 @@ static int check_break_command(int time, int has_input, int c) break; } - /* printf("act %d\n", act); */ - return act; } static void check_reset_button(void) - { +{ /* * Runs state machines of all reset sources to find out if one detects * an action. @@ -1541,12 +1522,16 @@ static void check_reset_button(void) } /* run processing state machines */ - a_[0] = NONE; - a_[1] = NONE; - a_[2] = NONE; a_[0] = check_button(counter, button); - /* a_[1] = check_break_length(counter, rx_line); */ - a_[2] = check_break_command(counter, has_input, c); + if (hw_type == 26) { + /* break function are only present on hw26 */ + a_[1] = check_break_length(counter, rx_line); + a_[2] = check_break_command(counter, has_input, c); + } + else { + a_[1] = NONE; + a_[2] = NONE; + } /* if all SMs are sure there is not action, stop here */ if ((a_[0] == NONE) && (a_[1] == NONE) && (a_[2] == NONE)) {