stm32/usart: Implemented a function to get the current databits setting for a USART
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
189017b25c
commit
0241982fb4
@@ -100,6 +100,7 @@ BEGIN_DECLS
|
||||
|
||||
void usart_set_baudrate(uint32_t usart, uint32_t baud);
|
||||
void usart_set_databits(uint32_t usart, uint32_t bits);
|
||||
uint32_t usart_get_databits(uint32_t usart);
|
||||
void usart_set_stopbits(uint32_t usart, uint32_t stopbits);
|
||||
void usart_set_parity(uint32_t usart, uint32_t parity);
|
||||
void usart_set_mode(uint32_t usart, uint32_t mode);
|
||||
|
||||
@@ -95,6 +95,27 @@ void usart_set_databits(uint32_t usart, uint32_t bits)
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief USART Get Word Length.
|
||||
|
||||
The word length is set to 8 or 9 bits. Note that the last bit will be a parity
|
||||
bit if parity is enabled, in which case the data length will be 7 or 8 bits
|
||||
respectively.
|
||||
|
||||
@param[in] usart unsigned 32 bit. USART block register address base @ref
|
||||
usart_reg_base
|
||||
@returns unsigned 32 bit Word length in bits 8 or 9.
|
||||
*/
|
||||
|
||||
uint32_t usart_get_databits(uint32_t usart)
|
||||
{
|
||||
const uint32_t reg32 = USART_CR1(usart) & USART_CR1_M;
|
||||
if (reg32)
|
||||
return 9;
|
||||
else
|
||||
return 8;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief USART Set Stop Bit(s).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user