From c923fb3e12b61eb59e6baad8c8762d98fc401049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 24 Feb 2020 22:09:58 +0100 Subject: [PATCH] Add baudrate change function to uart driver --- stm-firmware/include/stm-periph/uart.h | 2 ++ stm-firmware/stm-periph/uart.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/stm-firmware/include/stm-periph/uart.h b/stm-firmware/include/stm-periph/uart.h index b5c7c77..8fa856f 100644 --- a/stm-firmware/include/stm-periph/uart.h +++ b/stm-firmware/include/stm-periph/uart.h @@ -48,6 +48,8 @@ struct stm_uart { int uart_init(struct stm_uart *uart); +void uart_change_brr(struct stm_uart *uart, uint32_t brr); + void uart_disable(struct stm_uart *uart); void uart_send_char(struct stm_uart *uart, char c); diff --git a/stm-firmware/stm-periph/uart.c b/stm-firmware/stm-periph/uart.c index 5bc44b3..88e5cd0 100644 --- a/stm-firmware/stm-periph/uart.c +++ b/stm-firmware/stm-periph/uart.c @@ -86,6 +86,14 @@ int uart_init(struct stm_uart *uart) return 0; } +void uart_change_brr(struct stm_uart *uart, uint32_t brr) +{ + if (!uart || !uart->uart_dev) + return; + + uart->uart_dev->BRR = brr; +} + void uart_disable(struct stm_uart *uart) { if (!uart)