diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-12-09 23:50:58 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-12-09 23:50:58 +0100 |
commit | 7d03a941be6e9226e71cb5f5b4f7949e06bbfb02 (patch) | |
tree | cde9218dbe97837f972c426552c463f5f2a6a256 /fw/fe310/eos/uart.c | |
parent | 9c8f5a5e8f11e4a5012d55b96afae290242b8fdd (diff) |
improved init process
Diffstat (limited to 'fw/fe310/eos/uart.c')
-rw-r--r-- | fw/fe310/eos/uart.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fw/fe310/eos/uart.c b/fw/fe310/eos/uart.c index 7c676ba..30f76d9 100644 --- a/fw/fe310/eos/uart.c +++ b/fw/fe310/eos/uart.c @@ -4,6 +4,7 @@ #include "encoding.h" #include "platform.h" +#include "prci_driver.h" #include "eos.h" #include "interrupt.h" @@ -43,9 +44,28 @@ int eos_uart_init(uint8_t wakeup_cause) { eos_evtq_set_handler(EOS_EVT_UART, uart_handle_evt); eos_intr_set(INT_UART0_BASE, IRQ_PRIORITY_UART, uart_handle_intr); + UART0_REG(UART_REG_TXCTRL) |= UART_TXEN; + UART0_REG(UART_REG_RXCTRL) |= UART_RXEN; + + eos_uart_speed(EOS_UART_SPEED); + eos_uart_start(); + return EOS_OK; } +void eos_uart_start(void) { + GPIO_REG(GPIO_IOF_SEL) &= ~IOF0_UART0_MASK; + GPIO_REG(GPIO_IOF_EN) |= IOF0_UART0_MASK; +} + +void eos_uart_stop(void) { + GPIO_REG(GPIO_IOF_EN) &= ~IOF0_UART0_MASK; +} + +void eos_uart_speed(uint32_t baud_rate) { + UART0_REG(UART_REG_DIV) = PRCI_get_cpu_freq() / baud_rate - 1; +} + void eos_uart_set_handler(unsigned char type, eos_uart_handler_t handler) { if (type && (type <= EOS_UART_MAX_ETYPE)) uart_handler[type - 1] = handler; } |