If i start an UART receive with an interrupt looking for the next inbound byte/char;
HAL_UART_Receive_IT(&huart1, &UART1_Data, 1);
how can i cancel the receive before receiving the next byte/char?
I'd imagine you could flag it yourself and handle in the callback.
when you say flag it, do you mean force an interrupt by setting a interrupt bit in the uart and then handling the interrupt?
I mean on your side, presumably you're going to want it to receive again at some point, and if you don't keep servicing it you'll have it overrun.
Flag that you want to cancel, eat the byte if you don't want it, and don't light off another.
Why are you looking to cancel it? Do you have some secondary buffering, or are you using this method to pull and process data a byte at a time.
did you fix it ?
would you like to use the DAM rx functions ?
I get an interrupt on each and every character.
Updating this thread. My original post and other similar posts have been heard by the HAL developers.
New HAL functions were added recently for UARTs including;
/* Transfer Abort functions */HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
as of the time of this update, not all HAL series have been updated, but will be as each new series FW is released.
I will test HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart) in my original project shortly.
Retrieving data ...