diff --git a/include/libopencm3/lm4f/uart.h b/include/libopencm3/lm4f/uart.h index f36556ee..3f3aa661 100644 --- a/include/libopencm3/lm4f/uart.h +++ b/include/libopencm3/lm4f/uart.h @@ -444,6 +444,7 @@ BEGIN_DECLS void uart_set_baudrate(uint32_t uart, uint32_t baud); void uart_set_databits(uint32_t uart, uint8_t databits); +uint8_t uart_get_databits(uint32_t uart); void uart_set_stopbits(uint32_t uart, uint8_t stopbits); void uart_set_parity(uint32_t uart, enum uart_parity parity); void uart_set_mode(uint32_t uart, uint32_t mode); diff --git a/lib/lm4f/uart.c b/lib/lm4f/uart.c index 542ae3b7..725c52cb 100644 --- a/lib/lm4f/uart.c +++ b/lib/lm4f/uart.c @@ -151,6 +151,12 @@ void uart_set_databits(uint32_t uart, uint8_t databits) UART_LCRH(uart) = reg32; } +uint8_t uart_get_databits(uint32_t uart) +{ + const uint8_t bits = (UART_LCRH(uart) & UART_LCRH_WLEN_MASK) >> 5; + return bits + 5; +} + /** * \brief Set UART stopbits *