/**
* @brief 使能或失能USART的.---Enables or disables the USART's 8x oversampling mode.
* @param USARTx: ---Select the USART or the UART peripheral.
* 这个参数可以是下面的值之一 : USART1, USART2, USART3, UART4 or UART5.
* This parameter can be one of the following values: USART1, USART2, USART3, UART4 or UART5.
* @param NewState: new state of the USART one bit sampling methode.
* This parameter can be: ENABLE or DISABLE.
* @note
* This function has to be called before calling USART_Init()
* function in order to have correct baudrate Divider value.
* @retval None
*/
void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the 8x Oversampling mode by setting the OVER8 bit in the CR1 register */
USARTx->CR1 |= CR1_OVER8_Set;
}
else
{
/* Disable the 8x Oversampling mode by clearing the OVER8 bit in the CR1 register */
USARTx->CR1 &= CR1_OVER8_Reset;
}
}
/**
* @brief Enables or disables the USART's one bit sampling methode.
* @param USARTx: Select the USART or the UART peripheral.
*
* This parameter can be one of the following values: USART1, USART2, USART3, UART4 or UART5.
* @param NewState: new state of the USART one bit sampling methode.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the one bit method by setting the ONEBITE bit in the CR3 register */
USARTx->CR3 |= CR3_ONEBITE_Set;
}
else
{
/* Disable tthe one bit method by clearing the ONEBITE bit in the CR3 register */
USARTx->CR3 &= CR3_ONEBITE_Reset;
}
}
/*************************************************************************************************
* @fun: void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
* @brief Enables or disables the USART's 8x oversampling mode.
* 启用或禁用USART 8倍过采样模式
* @param USARTx: Select the USART or the UART peripheral.
* 选择的USART或UART的外设。
* This parameter can be one of the following values:
* 此参数可为下列值之一:
* USART1, USART2, USART3, UART4 or UART5.
* @param NewState: new state of the USART one bit sampling methode.
* This parameter can be: ENABLE or DISABLE.
* USART位采样方法的新状态,此参数可以是:启用或禁用
* @note
* This function has to be called before calling USART_Init()
* function in order to have correct baudrate Divider value.
* 调用此函数之前,必须调用USART_Init函数确定恰当的波特率分频值
* @retval None
************************************************************************************************/
void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState)
{
/* Check the parameters
检查参数 */
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the 8x Oversampling mode by setting the OVER8 bit in the CR1 register
置位CR1寄存器 OVER8 位启用8倍过采样模式 */
USARTx->CR1 |= CR1_OVER8_Set;
}
else
{
/* Disable the 8x Oversampling mode by clearing the OVER8 bit in the CR1 register
复位CR1寄存器 OVER8 位禁用8倍过采样模式 */
USARTx->CR1 &= CR1_OVER8_Reset;
/*************************************************************************************************
* @fun: void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState)
* @brief Enables or disables the USART's one bit sampling methode.
* 启用或禁用USART位采样方法
* @param USARTx: Select the USART or the UART peripheral.
* 选择的USART或UART的外设。
* This parameter can be one of the following values:
* 此参数可为下列值之一:
* USART1, USART2, USART3, UART4 or UART5.
* @param NewState: new state of the USART one bit sampling methode.
* This parameter can be: ENABLE or DISABLE.
* USART位采样方法的新状态,此参数可以是:启用或禁用
* @retval None
************************************************************************************************/
void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState)
{
/* Check the parameters
检查参数 */
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
/* Enable the one bit method by setting the ONEBITE bit in the CR3 register
置位CR3寄存器 ONEBITE 位启用位采样方法 */
USARTx->CR3 |= CR3_ONEBITE_Set;
}
else
{
/* Disable tthe one bit method by clearing the ONEBITE bit in the CR3 register
复位CR3寄存器 ONEBITE 位禁用位采样方法 */
USARTx->CR3 &= CR3_ONEBITE_Reset;
}
}