Browse Source

lm4f/uart: Implemented a function to get the current databits setting for a UART

pull/1483/head
dragonmux 2 years ago
committed by Piotr Esden-Tempski
parent
commit
78ace36308
  1. 1
      include/libopencm3/lm4f/uart.h
  2. 6
      lib/lm4f/uart.c

1
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);

6
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
*

Loading…
Cancel
Save