From f0262cb4a949711811bc89450b877a15d8321c1f Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 23 Aug 2022 03:14:45 +0100 Subject: [PATCH] lm4f/uart: Implemented a function to get the current stop bits setting for a UART --- include/libopencm3/lm4f/uart.h | 1 + lib/lm4f/uart.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/libopencm3/lm4f/uart.h b/include/libopencm3/lm4f/uart.h index 3f3aa661..fbde2229 100644 --- a/include/libopencm3/lm4f/uart.h +++ b/include/libopencm3/lm4f/uart.h @@ -446,6 +446,7 @@ 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); +uint8_t uart_get_stopbits(uint32_t uart); void uart_set_parity(uint32_t uart, enum uart_parity parity); void uart_set_mode(uint32_t uart, uint32_t mode); void uart_set_flow_control(uint32_t uart, enum uart_flowctl flow); diff --git a/lib/lm4f/uart.c b/lib/lm4f/uart.c index 725c52cb..62c19cb9 100644 --- a/lib/lm4f/uart.c +++ b/lib/lm4f/uart.c @@ -172,6 +172,13 @@ void uart_set_stopbits(uint32_t uart, uint8_t stopbits) } } +uint8_t uart_get_stopbits(uint32_t uart) +{ + if (UART_LCRH(uart) & UART_LCRH_STP2) + return 2; + return 1; +} + /** * \brief Set UART parity *