[HAL][UART] Fix check on UART Rx state in HAL_UART_RegisterRxEventCallback() and HAL_UART_UnRegisterRxEventCallback() to allow user Rx Event Callback registration when a transmit is ongoing
diff --git a/Src/stm32f0xx_hal_uart.c b/Src/stm32f0xx_hal_uart.c index a352509..da48f4d 100644 --- a/Src/stm32f0xx_hal_uart.c +++ b/Src/stm32f0xx_hal_uart.c
@@ -1002,10 +1002,7 @@ return HAL_ERROR; } - /* Process locked */ - __HAL_LOCK(huart); - - if (huart->gState == HAL_UART_STATE_READY) + if (huart->RxState == HAL_UART_STATE_READY) { huart->RxEventCallback = pCallback; } @@ -1016,9 +1013,6 @@ status = HAL_ERROR; } - /* Release Lock */ - __HAL_UNLOCK(huart); - return status; } @@ -1032,10 +1026,7 @@ { HAL_StatusTypeDef status = HAL_OK; - /* Process locked */ - __HAL_LOCK(huart); - - if (huart->gState == HAL_UART_STATE_READY) + if (huart->RxState == HAL_UART_STATE_READY) { huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak UART Rx Event Callback */ } @@ -1046,8 +1037,6 @@ status = HAL_ERROR; } - /* Release Lock */ - __HAL_UNLOCK(huart); return status; }