/**
* @brief Enables or disables the swap Tx/Rx pins.
* @param USARTx: where x can be 1 or 2 to select the USART peripheral.
* @param NewState: new state of the USARTx TX/RX pins pinout.
* This parameter can be:
* @arg ENABLE: The TX and RX pins functions are swapped.
* @arg DISABLE: TX/RX pins are used as defined in standard pinout
* @note This function has to be called before calling USART_Cmd() function.
* @retval None
*/
void USART_SWAPPinCmd(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 SWAP feature by setting the SWAP bit in the CR2 register */
USARTx->CR2 |= USART_CR2_SWAP;
}
else
{
/* Disable the SWAP feature by clearing the SWAP bit in the CR2 register */
USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_SWAP);
}
}
/**
* @brief Enables or disables the swap Tx/Rx pins.
* @param USARTx: where x can be 1 or 2 to select the USART peripheral.
* @param NewState: new state of the USARTx TX/RX pins pinout.
* This parameter can be:
* @arg ENABLE: The TX and RX pins functions are swapped.
* @arg DISABLE: TX/RX pins are used as defined in standard pinout
* @note This function has to be called before calling USART_Cmd() function.
* @retval None
*/
void USART_SWAPPinCmd(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 SWAP feature by setting the SWAP bit in the CR2 register */
USARTx->CR2 |= USART_CR2_SWAP;
}
else
{
/* Disable the SWAP feature by clearing the SWAP bit in the CR2 register */
USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_SWAP);
}
}
一周热门 更多>