Closed dergentk closed 9 months ago
ST Internal Reference: 158193
Hi @dergentk,
First excuse this late answer. Indeed, you are right, the check should be done on RxState
and not on gState
. This will be fixed and integrated in a future release. Thank you for reporting this and thank you fir your contribution.
With regards,
Description It is impossible to set an RxEventCallback (with
HAL_UART_RegisterRxEventCallback
) if a transmit is active on the port.How To Reproduce start a UART transmit with
HAL_UART_Transmit_IT
. then immediately thereafter callHAL_UART_RegisterRxEventCallback
. That call will fail.Analysis This is caused by the fact that
HAL_UART_RegisterRxEventCallback
checks the value of thegState
field instead of theRxState
like all other receive releated functions do. I don't see a reason for this difference. As far is I can tell the RxEventCallback is unrelated to transmit so checkinggState
appears to be a mistake.My Solution Changing
gState
inHAL_UART_RegisterRxEventCallback
andHAL_UART_UnregisterRxEventCallback
toRxState
makes the problem go away, as expected. And it did not cause unwanted side effects in my testing.