diff options
Diffstat (limited to 'chip/g/uart.c')
-rw-r--r-- | chip/g/uart.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/chip/g/uart.c b/chip/g/uart.c index 0ae55c8eb0..2ce2c20ca3 100644 --- a/chip/g/uart.c +++ b/chip/g/uart.c @@ -13,7 +13,13 @@ #include "uartn.h" #include "util.h" -static uint8_t done_uart_init_yet; +enum init_values { + INIT_NOT_START, + INIT_IN_PROGRESS, + INIT_DONE +}; + +static enum init_values done_uart_init_yet; #define USE_UART_INTERRUPTS (!(defined(CONFIG_CUSTOMIZED_RO) && \ defined(SECTION_IS_RO))) @@ -21,9 +27,17 @@ static uint8_t done_uart_init_yet; #define UARTN 0 #endif +static int uart_init_check_pinhold(void) +{ + if (!GREAD(PINMUX, HOLD) && done_uart_init_yet == INIT_IN_PROGRESS) + done_uart_init_yet = INIT_DONE; + return done_uart_init_yet == INIT_DONE; +} + int uart_init_done(void) { - return done_uart_init_yet; + return (done_uart_init_yet == INIT_DONE) || + uart_init_check_pinhold(); } void uart_tx_start(void) @@ -108,6 +122,5 @@ void uart_init(void) #ifdef UART_EC uartn_init(UART_EC); #endif - - done_uart_init_yet = 1; + done_uart_init_yet = INIT_IN_PROGRESS; } |