lm4f/uart: Implemented a function to get the current parity setting for a UART
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
f0262cb4a9
commit
10cfbd7652
@@ -448,6 +448,7 @@ uint8_t uart_get_databits(uint32_t uart);
|
|||||||
void uart_set_stopbits(uint32_t uart, uint8_t stopbits);
|
void uart_set_stopbits(uint32_t uart, uint8_t stopbits);
|
||||||
uint8_t uart_get_stopbits(uint32_t uart);
|
uint8_t uart_get_stopbits(uint32_t uart);
|
||||||
void uart_set_parity(uint32_t uart, enum uart_parity parity);
|
void uart_set_parity(uint32_t uart, enum uart_parity parity);
|
||||||
|
enum uart_parity uart_get_parity(uint32_t uart);
|
||||||
void uart_set_mode(uint32_t uart, uint32_t mode);
|
void uart_set_mode(uint32_t uart, uint32_t mode);
|
||||||
void uart_set_flow_control(uint32_t uart, enum uart_flowctl flow);
|
void uart_set_flow_control(uint32_t uart, enum uart_flowctl flow);
|
||||||
void uart_enable(uint32_t uart);
|
void uart_enable(uint32_t uart);
|
||||||
|
|||||||
@@ -214,6 +214,26 @@ void uart_set_parity(uint32_t uart, enum uart_parity parity)
|
|||||||
UART_LCRH(uart) = reg32;
|
UART_LCRH(uart) = reg32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum uart_parity uart_get_parity(uint32_t uart)
|
||||||
|
{
|
||||||
|
const uint32_t reg32 = UART_LCRH(uart);
|
||||||
|
/* Check if parity is even enabled */
|
||||||
|
if (!(reg32 & UART_LCRH_PEN))
|
||||||
|
return UART_PARITY_NONE;
|
||||||
|
/* Check for sticky modes */
|
||||||
|
if (reg32 & UART_LCRH_SPS) {
|
||||||
|
if (reg32 & UART_LCRH_EPS) {
|
||||||
|
return UART_PARITY_STICK_0;
|
||||||
|
}
|
||||||
|
return UART_PARITY_STICK_1;
|
||||||
|
} else {
|
||||||
|
if (reg32 & UART_LCRH_EPS) {
|
||||||
|
return UART_PARITY_EVEN;
|
||||||
|
}
|
||||||
|
return UART_PARITY_ODD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the flow control scheme
|
* \brief Set the flow control scheme
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user