[HAL][UART] Fix incorrect gState check in HAL_UART_RegisterRxEventCallback/HAL_UART_UnRegisterRxEventCallback to allow user Rx Event Callback registration when a transmit is ongoing
diff --git a/Src/stm32f7xx_hal_uart.c b/Src/stm32f7xx_hal_uart.c index beb7fd1..a16b9ff 100644 --- a/Src/stm32f7xx_hal_uart.c +++ b/Src/stm32f7xx_hal_uart.c
@@ -942,10 +942,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; } @@ -956,9 +953,6 @@ status = HAL_ERROR; } - /* Release Lock */ - __HAL_UNLOCK(huart); - return status; } @@ -972,10 +966,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 */ } @@ -986,8 +977,6 @@ status = HAL_ERROR; } - /* Release Lock */ - __HAL_UNLOCK(huart); return status; }