diff options
Diffstat (limited to 'chip/lm4/uart.c')
-rw-r--r-- | chip/lm4/uart.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c index 04ccd7ba8e..bb08aa1477 100644 --- a/chip/lm4/uart.c +++ b/chip/lm4/uart.c @@ -11,6 +11,7 @@ #include "gpio.h" #include "lpc.h" #include "registers.h" +#include "system.h" #include "task.h" #include "uart.h" #include "util.h" @@ -26,6 +27,12 @@ int uart_init_done(void) void uart_tx_start(void) { + /* If interrupt is already enabled, nothing to do */ + if (LM4_UART_IM(0) & 0x20) + return; + + /* Do not allow deep sleep while transmit in progress */ + disable_sleep(SLEEP_MASK_UART); /* * Re-enable the transmit interrupt, then forcibly trigger the * interrupt. This works around a hardware problem with the @@ -39,6 +46,9 @@ void uart_tx_start(void) void uart_tx_stop(void) { LM4_UART_IM(0) &= ~0x20; + + /* Re-allow deep sleep */ + enable_sleep(SLEEP_MASK_UART); } int uart_tx_stopped(void) @@ -176,11 +186,16 @@ void uart_init(void) { uint32_t mask = 0; - /* Enable UART0 and Host UART in run, sleep, and deep sleep modes. */ + /* + * Enable UART0 in run, sleep, and deep sleep modes. Enable the Host + * UART in run and sleep modes. + */ mask |= 1; - mask |= (1 << CONFIG_UART_HOST); + clock_enable_peripheral(CGC_OFFSET_UART, mask, CGC_MODE_DSLEEP); - clock_enable_peripheral(CGC_OFFSET_UART, mask, CGC_MODE_ALL); + mask |= (1 << CONFIG_UART_HOST); + clock_enable_peripheral(CGC_OFFSET_UART, mask, + CGC_MODE_RUN | CGC_MODE_SLEEP); gpio_config_module(MODULE_UART, 1); |