|
|
@@ -76,8 +76,8 @@
|
|
|
allows the user to configure dynamically the driver callbacks.
|
|
|
|
|
|
[..]
|
|
|
- Use Function @ref HAL_UART_RegisterCallback() to register a user callback.
|
|
|
- Function @ref HAL_UART_RegisterCallback() allows to register following callbacks:
|
|
|
+ Use Function HAL_UART_RegisterCallback() to register a user callback.
|
|
|
+ Function HAL_UART_RegisterCallback() allows to register following callbacks:
|
|
|
(+) TxHalfCpltCallback : Tx Half Complete Callback.
|
|
|
(+) TxCpltCallback : Tx Complete Callback.
|
|
|
(+) RxHalfCpltCallback : Rx Half Complete Callback.
|
|
|
@@ -93,9 +93,9 @@
|
|
|
and a pointer to the user callback function.
|
|
|
|
|
|
[..]
|
|
|
- Use function @ref HAL_UART_UnRegisterCallback() to reset a callback to the default
|
|
|
+ Use function HAL_UART_UnRegisterCallback() to reset a callback to the default
|
|
|
weak (surcharged) function.
|
|
|
- @ref HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
|
|
|
+ HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
|
|
|
and the Callback ID.
|
|
|
This function allows to reset following callbacks:
|
|
|
(+) TxHalfCpltCallback : Tx Half Complete Callback.
|
|
|
@@ -112,16 +112,16 @@
|
|
|
|
|
|
[..]
|
|
|
For specific callback RxEventCallback, use dedicated registration/reset functions:
|
|
|
- respectively @ref HAL_UART_RegisterRxEventCallback() , @ref HAL_UART_UnRegisterRxEventCallback().
|
|
|
+ respectively HAL_UART_RegisterRxEventCallback() , HAL_UART_UnRegisterRxEventCallback().
|
|
|
|
|
|
[..]
|
|
|
- By default, after the @ref HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
|
|
|
+ By default, after the HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
|
|
|
all callbacks are set to the corresponding weak (surcharged) functions:
|
|
|
- examples @ref HAL_UART_TxCpltCallback(), @ref HAL_UART_RxHalfCpltCallback().
|
|
|
+ examples HAL_UART_TxCpltCallback(), HAL_UART_RxHalfCpltCallback().
|
|
|
Exception done for MspInit and MspDeInit functions that are respectively
|
|
|
- reset to the legacy weak (surcharged) functions in the @ref HAL_UART_Init()
|
|
|
- and @ref HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
|
|
|
- If not, MspInit or MspDeInit are not null, the @ref HAL_UART_Init() and @ref HAL_UART_DeInit()
|
|
|
+ reset to the legacy weak (surcharged) functions in the HAL_UART_Init()
|
|
|
+ and HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
|
|
|
+ If not, MspInit or MspDeInit are not null, the HAL_UART_Init() and HAL_UART_DeInit()
|
|
|
keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
|
|
|
|
|
|
[..]
|
|
|
@@ -130,8 +130,8 @@
|
|
|
in HAL_UART_STATE_READY or HAL_UART_STATE_RESET state, thus registered (user)
|
|
|
MspInit/DeInit callbacks can be used during the Init/DeInit.
|
|
|
In that case first register the MspInit/MspDeInit user callbacks
|
|
|
- using @ref HAL_UART_RegisterCallback() before calling @ref HAL_UART_DeInit()
|
|
|
- or @ref HAL_UART_Init() function.
|
|
|
+ using HAL_UART_RegisterCallback() before calling HAL_UART_DeInit()
|
|
|
+ or HAL_UART_Init() function.
|
|
|
|
|
|
[..]
|
|
|
When The compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 0 or
|
|
|
@@ -173,21 +173,20 @@
|
|
|
/** @defgroup UART_Private_Constants UART Private Constants
|
|
|
* @{
|
|
|
*/
|
|
|
-#define USART_CR1_FIELDS ((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | \
|
|
|
- USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8 )) /*!< UART or USART CR1 fields of parameters set by UART_SetConfig API */
|
|
|
+#define USART_CR1_FIELDS ((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE | \
|
|
|
+ USART_CR1_OVER8)) /*!< UART or USART CR1 fields of parameters set by UART_SetConfig API */
|
|
|
|
|
|
-#define USART_CR3_FIELDS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE | USART_CR3_ONEBIT)) /*!< UART or USART CR3 fields of parameters set by UART_SetConfig API */
|
|
|
+#define USART_CR3_FIELDS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE |\
|
|
|
+ USART_CR3_ONEBIT)) /*!< UART or USART CR3 fields of parameters set by UART_SetConfig API */
|
|
|
|
|
|
|
|
|
#define UART_BRR_MIN 0x10U /* UART BRR minimum authorized value */
|
|
|
#define UART_BRR_MAX 0x0000FFFFU /* UART BRR maximum authorized value */
|
|
|
-
|
|
|
/**
|
|
|
* @}
|
|
|
*/
|
|
|
|
|
|
/* Private macros ------------------------------------------------------------*/
|
|
|
-/* Private variables ---------------------------------------------------------*/
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
/** @addtogroup UART_Private_Functions
|
|
|
* @{
|
|
|
@@ -213,6 +212,8 @@ static void UART_RxISR_16BIT(UART_HandleTypeDef *huart);
|
|
|
* @}
|
|
|
*/
|
|
|
|
|
|
+/* Private variables ---------------------------------------------------------*/
|
|
|
+/* Exported Constants --------------------------------------------------------*/
|
|
|
/* Exported functions --------------------------------------------------------*/
|
|
|
|
|
|
/** @defgroup UART_Exported_Functions UART Exported Functions
|
|
|
@@ -1040,7 +1041,8 @@ HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart)
|
|
|
(+) HAL_UART_AbortTransmitCpltCallback()
|
|
|
(+) HAL_UART_AbortReceiveCpltCallback()
|
|
|
|
|
|
- (#) A Rx Event Reception Callback (Rx event notification) is available for Non_Blocking modes of enhanced reception services:
|
|
|
+ (#) A Rx Event Reception Callback (Rx event notification) is available for Non_Blocking modes of enhanced
|
|
|
+ reception services:
|
|
|
(+) HAL_UARTEx_RxEventCallback()
|
|
|
|
|
|
(#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
|
|
|
@@ -1279,7 +1281,7 @@ HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData
|
|
|
__HAL_UNLOCK(huart);
|
|
|
|
|
|
/* Enable the Transmit Data Register Empty interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
|
|
|
return HAL_OK;
|
|
|
}
|
|
|
@@ -1315,13 +1317,13 @@ HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData,
|
|
|
huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
|
|
|
/* Check that USART RTOEN bit is set */
|
|
|
- if(READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
|
|
|
+ if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
|
|
|
{
|
|
|
/* Enable the UART Receiver Timeout Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
|
|
|
}
|
|
|
|
|
|
- return(UART_Start_Receive_IT(huart, pData, Size));
|
|
|
+ return (UART_Start_Receive_IT(huart, pData, Size));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1393,7 +1395,7 @@ HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pDat
|
|
|
|
|
|
/* Enable the DMA transfer for transmit request by setting the DMAT bit
|
|
|
in the UART CR3 register */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
return HAL_OK;
|
|
|
}
|
|
|
@@ -1431,13 +1433,13 @@ HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData
|
|
|
huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
|
|
|
/* Check that USART RTOEN bit is set */
|
|
|
- if(READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
|
|
|
+ if (READ_BIT(huart->Instance->CR2, USART_CR2_RTOEN) != 0U)
|
|
|
{
|
|
|
/* Enable the UART Receiver Timeout Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RTOIE);
|
|
|
}
|
|
|
|
|
|
- return(UART_Start_Receive_DMA(huart, pData, Size));
|
|
|
+ return (UART_Start_Receive_DMA(huart, pData, Size));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1461,17 +1463,17 @@ HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
|
|
|
(gstate == HAL_UART_STATE_BUSY_TX))
|
|
|
{
|
|
|
/* Disable the UART DMA Tx request */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
}
|
|
|
if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) &&
|
|
|
(rxstate == HAL_UART_STATE_BUSY_RX))
|
|
|
{
|
|
|
/* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Disable the UART DMA Rx request */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
}
|
|
|
|
|
|
__HAL_UNLOCK(huart);
|
|
|
@@ -1491,7 +1493,7 @@ HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
|
|
|
if (huart->gState == HAL_UART_STATE_BUSY_TX)
|
|
|
{
|
|
|
/* Enable the UART DMA Tx request */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
}
|
|
|
if (huart->RxState == HAL_UART_STATE_BUSY_RX)
|
|
|
{
|
|
|
@@ -1499,11 +1501,11 @@ HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
|
|
|
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
|
|
|
|
|
|
/* Re-enable PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Enable the UART DMA Rx request */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
}
|
|
|
|
|
|
__HAL_UNLOCK(huart);
|
|
|
@@ -1532,7 +1534,7 @@ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
|
|
|
if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT)) &&
|
|
|
(gstate == HAL_UART_STATE_BUSY_TX))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Abort the UART DMA Tx channel */
|
|
|
if (huart->hdmatx != NULL)
|
|
|
@@ -1556,7 +1558,7 @@ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
|
|
|
if ((HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR)) &&
|
|
|
(rxstate == HAL_UART_STATE_BUSY_RX))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -1594,19 +1596,19 @@ HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
|
|
|
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
}
|
|
|
|
|
|
/* Disable the UART DMA Tx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
|
|
|
if (huart->hdmatx != NULL)
|
|
|
@@ -1631,7 +1633,7 @@ HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
|
|
|
/* Disable the UART DMA Rx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -1689,12 +1691,12 @@ HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
|
|
|
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable TXEIE and TCIE interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
|
|
|
/* Disable the UART DMA Tx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
|
|
|
if (huart->hdmatx != NULL)
|
|
|
@@ -1741,19 +1743,19 @@ HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
|
|
|
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
}
|
|
|
|
|
|
/* Disable the UART DMA Rx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -1810,13 +1812,13 @@ HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
|
|
|
uint32_t abortcplt = 1U;
|
|
|
|
|
|
/* Disable interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
}
|
|
|
|
|
|
/* If DMA Tx and/or DMA Rx Handles are associated to UART Handle, DMA Abort complete callbacks should be initialised
|
|
|
@@ -1854,7 +1856,7 @@ HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
|
|
|
{
|
|
|
/* Disable DMA Tx at UART level */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
|
|
|
if (huart->hdmatx != NULL)
|
|
|
@@ -1877,7 +1879,7 @@ HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
|
|
|
/* Disable the UART DMA Rx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -1954,12 +1956,12 @@ HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
|
|
|
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
|
|
|
/* Disable the UART DMA Tx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
|
|
|
if (huart->hdmatx != NULL)
|
|
|
@@ -2038,19 +2040,19 @@ HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
|
|
|
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
|
|
|
}
|
|
|
|
|
|
/* Disable the UART DMA Rx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -2229,7 +2231,7 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
/* Disable the UART DMA Rx request if enabled */
|
|
|
if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* Abort the UART DMA Rx channel */
|
|
|
if (huart->hdmarx != NULL)
|
|
|
@@ -2290,9 +2292,9 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
|
|
|
/* Check current reception Mode :
|
|
|
If Reception till IDLE event has been selected : */
|
|
|
- if ( (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
- &&((isrflags & USART_ISR_IDLE) != 0U)
|
|
|
- &&((cr1its & USART_ISR_IDLE) != 0U))
|
|
|
+ if ((huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
+ && ((isrflags & USART_ISR_IDLE) != 0U)
|
|
|
+ && ((cr1its & USART_ISR_IDLE) != 0U))
|
|
|
{
|
|
|
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
|
|
|
|
|
|
@@ -2304,8 +2306,8 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
(DMA cplt callback will be called).
|
|
|
Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
|
|
|
uint16_t nb_remaining_rx_data = (uint16_t) __HAL_DMA_GET_COUNTER(huart->hdmarx);
|
|
|
- if ( (nb_remaining_rx_data > 0U)
|
|
|
- &&(nb_remaining_rx_data < huart->RxXferSize))
|
|
|
+ if ((nb_remaining_rx_data > 0U)
|
|
|
+ && (nb_remaining_rx_data < huart->RxXferSize))
|
|
|
{
|
|
|
/* Reception is not complete */
|
|
|
huart->RxXferCount = nb_remaining_rx_data;
|
|
|
@@ -2314,18 +2316,18 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
if (huart->hdmarx->Init.Mode != DMA_CIRCULAR)
|
|
|
{
|
|
|
/* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Disable the DMA transfer for the receiver request by resetting the DMAR bit
|
|
|
in the UART CR3 register */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* At end of Rx process, restore huart->RxState to Ready */
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
|
|
|
/* Last bytes received, so no need as the abort is immediate */
|
|
|
(void)HAL_DMA_Abort(huart->hdmarx);
|
|
|
@@ -2336,7 +2338,7 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
#else
|
|
|
/*Call legacy weak Rx Event callback*/
|
|
|
HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount));
|
|
|
-#endif
|
|
|
+#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
@@ -2346,14 +2348,14 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
/* Check received length : If all expected data are received, do nothing.
|
|
|
Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
|
|
|
uint16_t nb_rx_data = huart->RxXferSize - huart->RxXferCount;
|
|
|
- if ( (huart->RxXferCount > 0U)
|
|
|
- &&(nb_rx_data > 0U) )
|
|
|
+ if ((huart->RxXferCount > 0U)
|
|
|
+ && (nb_rx_data > 0U))
|
|
|
{
|
|
|
/* Disable the UART Parity Error Interrupt and RXNE interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
|
|
|
/* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Rx process is completed, restore huart->RxState to Ready */
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -2362,14 +2364,14 @@ void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
|
|
|
/* Clear RxISR function pointer */
|
|
|
huart->RxISR = NULL;
|
|
|
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
|
|
/*Call registered Rx complete callback*/
|
|
|
huart->RxEventCallback(huart, nb_rx_data);
|
|
|
#else
|
|
|
/*Call legacy weak Rx Event callback*/
|
|
|
HAL_UARTEx_RxEventCallback(huart, nb_rx_data);
|
|
|
-#endif
|
|
|
+#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
@@ -2669,7 +2671,7 @@ HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart)
|
|
|
huart->gState = HAL_UART_STATE_BUSY;
|
|
|
|
|
|
/* Enable USART mute mode by setting the MME bit in the CR1 register */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_MME);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_MME);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
|
|
|
@@ -2689,7 +2691,7 @@ HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart)
|
|
|
huart->gState = HAL_UART_STATE_BUSY;
|
|
|
|
|
|
/* Disable USART mute mode by clearing the MME bit in the CR1 register */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_MME);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_MME);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
|
|
|
@@ -2718,10 +2720,10 @@ HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
|
|
|
huart->gState = HAL_UART_STATE_BUSY;
|
|
|
|
|
|
/* Clear TE and RE bits */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
|
|
|
|
|
|
/* Enable the USART's transmit interface by setting the TE bit in the USART CR1 register */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_TE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TE);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
|
|
|
@@ -2741,10 +2743,10 @@ HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
|
|
|
huart->gState = HAL_UART_STATE_BUSY;
|
|
|
|
|
|
/* Clear TE and RE bits */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
|
|
|
|
|
|
/* Enable the USART's receive interface by setting the RE bit in the USART CR1 register */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_RE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_RE);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
|
|
|
@@ -3146,8 +3148,8 @@ HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_
|
|
|
{
|
|
|
/* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error)
|
|
|
interrupts for the interrupt process */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -3166,8 +3168,8 @@ HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_
|
|
|
|
|
|
/* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error)
|
|
|
interrupts for the interrupt process */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -3209,7 +3211,7 @@ HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pDat
|
|
|
huart->RxState = HAL_UART_STATE_BUSY_RX;
|
|
|
|
|
|
/* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Set the Rx ISR function pointer according to the data word length */
|
|
|
if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
|
|
|
@@ -3224,7 +3226,7 @@ HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pDat
|
|
|
__HAL_UNLOCK(huart);
|
|
|
|
|
|
/* Enable the UART Parity Error interrupt and Data Register Not Empty interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
|
|
|
return HAL_OK;
|
|
|
}
|
|
|
|
|
|
@@ -3269,8 +3271,8 @@ HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pDa
|
|
|
|
|
|
__HAL_UNLOCK(huart);
|
|
|
|
|
|
- /* Restore huart->gState to ready */
|
|
|
- huart->gState = HAL_UART_STATE_READY;
|
|
|
+ /* Restore huart->RxState to ready */
|
|
|
+ huart->RxState = HAL_UART_STATE_READY;
|
|
|
|
|
|
return HAL_ERROR;
|
|
|
}
|
|
|
@@ -3278,14 +3280,14 @@ HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pDa
|
|
|
__HAL_UNLOCK(huart);
|
|
|
|
|
|
/* Enable the UART Parity Error Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
|
|
|
/* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Enable the DMA transfer for the receiver request by setting the DMAR bit
|
|
|
in the UART CR3 register */
|
|
|
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
return HAL_OK;
|
|
|
}
|
|
|
@@ -3299,7 +3301,7 @@ HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pDa
|
|
|
static void UART_EndTxTransfer(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable TXEIE and TCIE interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
|
|
|
|
|
|
/* At end of Tx process, restore huart->gState to Ready */
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
@@ -3314,13 +3316,13 @@ static void UART_EndTxTransfer(UART_HandleTypeDef *huart)
|
|
|
static void UART_EndRxTransfer(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* In case of reception waiting for IDLE event, disable also the IDLE IE interrupt source */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
}
|
|
|
|
|
|
/* At end of Rx process, restore huart->RxState to Ready */
|
|
|
@@ -3348,10 +3350,10 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
|
|
|
|
|
|
/* Disable the DMA transfer for transmit request by resetting the DMAT bit
|
|
|
in the UART CR3 register */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
|
|
|
|
|
|
/* Enable the UART Transmit Complete Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
}
|
|
|
/* DMA Circular mode */
|
|
|
else
|
|
|
@@ -3399,12 +3401,12 @@ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
|
|
|
huart->RxXferCount = 0U;
|
|
|
|
|
|
/* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Disable the DMA transfer for the receiver request by resetting the DMAR bit
|
|
|
in the UART CR3 register */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
|
|
|
|
|
|
/* At end of Rx process, restore huart->RxState to Ready */
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -3412,7 +3414,7 @@ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
|
|
|
/* If Reception till IDLE event has been selected, Disable IDLE Interrupt */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -3456,10 +3458,10 @@ static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
|
|
|
{
|
|
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
|
|
/*Call registered Rx Event callback*/
|
|
|
- huart->RxEventCallback(huart, huart->RxXferSize/2U);
|
|
|
+ huart->RxEventCallback(huart, huart->RxXferSize / 2U);
|
|
|
#else
|
|
|
/*Call legacy weak Rx Event callback*/
|
|
|
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize/2U);
|
|
|
+ HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize / 2U);
|
|
|
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
|
|
}
|
|
|
else
|
|
|
@@ -3714,10 +3716,10 @@ static void UART_TxISR_8BIT(UART_HandleTypeDef *huart)
|
|
|
if (huart->TxXferCount == 0U)
|
|
|
{
|
|
|
/* Disable the UART Transmit Data Register Empty Interrupt */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
|
|
|
/* Enable the UART Transmit Complete Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -3745,10 +3747,10 @@ static void UART_TxISR_16BIT(UART_HandleTypeDef *huart)
|
|
|
if (huart->TxXferCount == 0U)
|
|
|
{
|
|
|
/* Disable the UART Transmit Data Register Empty Interrupt */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TXEIE);
|
|
|
|
|
|
/* Enable the UART Transmit Complete Interrupt */
|
|
|
- SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
+ ATOMIC_SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -3770,7 +3772,7 @@ static void UART_TxISR_16BIT(UART_HandleTypeDef *huart)
|
|
|
static void UART_EndTransmit_IT(UART_HandleTypeDef *huart)
|
|
|
{
|
|
|
/* Disable the UART Transmit Complete Interrupt */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_TCIE);
|
|
|
|
|
|
/* Tx process is ended, restore huart->gState to Ready */
|
|
|
huart->gState = HAL_UART_STATE_READY;
|
|
|
@@ -3808,10 +3810,10 @@ static void UART_RxISR_8BIT(UART_HandleTypeDef *huart)
|
|
|
if (huart->RxXferCount == 0U)
|
|
|
{
|
|
|
/* Disable the UART Parity Error Interrupt and RXNE interrupts */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
|
|
|
/* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Rx process is completed, restore huart->RxState to Ready */
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -3823,16 +3825,24 @@ static void UART_RxISR_8BIT(UART_HandleTypeDef *huart)
|
|
|
If Reception till IDLE event has been selected : */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
+ /* Set reception type to Standard */
|
|
|
+ huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
+
|
|
|
/* Disable IDLE interrupt */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
|
|
|
+ if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) == SET)
|
|
|
+ {
|
|
|
+ /* Clear IDLE Flag */
|
|
|
+ __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
|
|
|
+ }
|
|
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
|
|
/*Call registered Rx Event callback*/
|
|
|
huart->RxEventCallback(huart, huart->RxXferSize);
|
|
|
#else
|
|
|
/*Call legacy weak Rx Event callback*/
|
|
|
HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
|
|
|
-#endif
|
|
|
+#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -3845,7 +3855,6 @@ static void UART_RxISR_8BIT(UART_HandleTypeDef *huart)
|
|
|
HAL_UART_RxCpltCallback(huart);
|
|
|
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
|
|
}
|
|
|
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -3880,10 +3889,10 @@ static void UART_RxISR_16BIT(UART_HandleTypeDef *huart)
|
|
|
if (huart->RxXferCount == 0U)
|
|
|
{
|
|
|
/* Disable the UART Parity Error Interrupt and RXNE interrupt*/
|
|
|
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
|
|
|
|
|
|
/* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
|
|
|
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
|
|
|
|
|
|
/* Rx process is completed, restore huart->RxState to Ready */
|
|
|
huart->RxState = HAL_UART_STATE_READY;
|
|
|
@@ -3895,16 +3904,24 @@ static void UART_RxISR_16BIT(UART_HandleTypeDef *huart)
|
|
|
If Reception till IDLE event has been selected : */
|
|
|
if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
|
|
{
|
|
|
+ /* Set reception type to Standard */
|
|
|
+ huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
+
|
|
|
/* Disable IDLE interrupt */
|
|
|
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
+ ATOMIC_CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
|
|
|
|
|
|
+ if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) == SET)
|
|
|
+ {
|
|
|
+ /* Clear IDLE Flag */
|
|
|
+ __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_IDLEF);
|
|
|
+ }
|
|
|
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
|
|
/*Call registered Rx Event callback*/
|
|
|
huart->RxEventCallback(huart, huart->RxXferSize);
|
|
|
#else
|
|
|
/*Call legacy weak Rx Event callback*/
|
|
|
HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
|
|
|
-#endif
|
|
|
+#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -3917,7 +3934,6 @@ static void UART_RxISR_16BIT(UART_HandleTypeDef *huart)
|
|
|
HAL_UART_RxCpltCallback(huart);
|
|
|
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
|
|
}
|
|
|
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
|
|
|
}
|
|
|
}
|
|
|
else
|