Fix premature RX interrupt during serial configuration

This commit is contained in:
Georgii Surkov 2024-02-08 15:18:58 +03:00
parent 534fe2fb26
commit ded9b121ba
No known key found for this signature in database
GPG key ID: 44A24455F6ADB5E7

View file

@ -730,6 +730,13 @@ static void furi_hal_serial_async_rx_configure(
FuriHalSerialHandle* handle,
FuriHalSerialAsyncRxCallback callback,
void* context) {
// Handle must be configured before enabling RX interrupt
// as it might be triggered right away on a misconfigured handle
furi_hal_serial[handle->id].rx_byte_callback = callback;
furi_hal_serial[handle->id].handle = handle;
furi_hal_serial[handle->id].rx_dma_callback = NULL;
furi_hal_serial[handle->id].context = context;
if(handle->id == FuriHalSerialIdUsart) {
if(callback) {
furi_hal_serial_usart_deinit_dma_rx();
@ -753,10 +760,6 @@ static void furi_hal_serial_async_rx_configure(
LL_LPUART_DisableIT_RXNE_RXFNE(LPUART1);
}
}
furi_hal_serial[handle->id].rx_byte_callback = callback;
furi_hal_serial[handle->id].handle = handle;
furi_hal_serial[handle->id].rx_dma_callback = NULL;
furi_hal_serial[handle->id].context = context;
}
void furi_hal_serial_async_rx_start(