stm32/common: Implement support for DE and changing the oversampling mode
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
7e4a6334a1
commit
9480f493b9
@@ -292,6 +292,16 @@
|
||||
#define USART_CR1_UE (1 << 0)
|
||||
/**@}*/
|
||||
|
||||
/* CR1_OVER8 values */
|
||||
/****************************************************************************/
|
||||
/** @defgroup usart_cr1_oversampling USART Oversampling Mode Selection
|
||||
@ingroup STM32F_usart_defines
|
||||
|
||||
@{*/
|
||||
#define USART_OVERSAMPLING_8 USART_CR1_OVER8
|
||||
#define USART_OVERSAMPLING_16 0U
|
||||
/**@}*/
|
||||
|
||||
/*------------------------------------------------*/
|
||||
/** @defgroup usart_cr2_values USART_CR2 Values
|
||||
@ingroup usart_defines
|
||||
@@ -630,4 +640,7 @@ void usart_disable_rx_timeout(uint32_t usart);
|
||||
void usart_enable_rx_timeout_interrupt(uint32_t usart);
|
||||
void usart_disable_rx_timeout_interrupt(uint32_t usart);
|
||||
|
||||
void usart_enable_diver_enable(uint32_t usart, bool invert);
|
||||
void usart_set_oversampling(uint32_t usart, uint32_t mode);
|
||||
|
||||
END_DECLS
|
||||
|
||||
@@ -302,5 +302,29 @@ bool usart_get_flag(uint32_t usart, uint32_t flag)
|
||||
return ((USART_ISR(usart) & flag) != 0);
|
||||
}
|
||||
|
||||
/** @brief USART Enable the Driver Enable signal out of the RTS pin
|
||||
*
|
||||
* @param[in] usart unsigned 32 bit. USART block register address base @ref
|
||||
* usart_reg_base
|
||||
*/
|
||||
void usart_enable_diver_enable(uint32_t usart, bool invert)
|
||||
{
|
||||
uint32_t reg = USART_CR3(usart);
|
||||
if (invert) {
|
||||
reg |= USART_CR3_DEP;
|
||||
} else {
|
||||
reg &= ~USART_CR3_DEP;
|
||||
}
|
||||
reg |= USART_CR3_DEM;
|
||||
USART_CR3(usart) = reg;
|
||||
}
|
||||
|
||||
void usart_set_oversampling(uint32_t usart, uint32_t mode)
|
||||
{
|
||||
if (mode)
|
||||
USART_CR1(usart) |= USART_CR1_OVER8;
|
||||
else
|
||||
USART_CR1(usart) &= ~USART_CR1_OVER8;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
Reference in New Issue
Block a user