You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a build flag to disable specific USART IRQ handlers defined in the core #2899
Is your feature request/improvement related to a problem? Please describe.
Without a way to undefine specific USARTx_IRQHandlers defined in the core, custom implementations of USART while keeping Serial functionality in others is not possible.
Describe the solution you'd like
I would like an additional build flag like "HAL_DISABLE_USART2IRQHANDLER" to disable specific USARTx_IRQHandler functions that are defined in the core, so they can be defined in the user's code instead, while keeping other USARTx_IRQHandler definitions to be able to use HardwareSerial on them.
Additional context
Here's a photo of the USART2_IRQHandler. For example, i would like to disable this specific handler, so i can use my own definition in my code, to write a custom use case, and be able to leave USART1 as is, so i can use HardwareSerial to print messages to the monitor.
Here is my suggested implementation: (I do not know if this will cause issues)
Thanks. This could also be implemented in other IRQHandlers, for example to disable specific ADC IRQHandlers, without disabling the entire ADC arduino implementation.
I have a custom USART2 and USART3 implementation that uses a clock signal. I need access to the IRQHandlers because the way they're implemented in the core it only services UART, and not USART.
Here you can see that the core is using HAL_UART_IRQHandler instead of HAL_USART_IRQHandler. This causes a hang on my MCU (STM32G431RBT6). The only way i found to fix this hang is to undefine this snippet and use my own implementation here:
(Ignore the fact it's USART3 for now it's the quickest example i had)
This fixes the hang and my MCU is no longer reset by the watchdog.
I also need to keep the HardwareSerial class working because i use USART1 as my debugging serial port, and i use another library that needs the class for debugging. (SimpleFOC)
Another possible fix would be a build flag that leaves the USART2_IRQHandler definition, but allows it to switch from HAL_UART_IRQHandler to HAL_USART_IRQHandler
Activity
fpistm commentedon Jan 23, 2026
Hi @Santynolo
I see why but don't like the fact to mix Arduino and pure HAL.
Anyway feel free to provide a PR.
Santynolo commentedon Jan 23, 2026
I would like to but i'm wondering if my suggested implementation can cause issues. If not i'll do it
fpistm commentedon Jan 23, 2026
What is your goal exactly?
Santynolo commentedon Jan 23, 2026
I have a custom USART2 and USART3 implementation that uses a clock signal. I need access to the IRQHandlers because the way they're implemented in the core it only services UART, and not USART.
Here you can see that the core is using
HAL_UART_IRQHandlerinstead ofHAL_USART_IRQHandler. This causes a hang on my MCU (STM32G431RBT6). The only way i found to fix this hang is to undefine this snippet and use my own implementation here:(Ignore the fact it's USART3 for now it's the quickest example i had)
This fixes the hang and my MCU is no longer reset by the watchdog.
I also need to keep the HardwareSerial class working because i use USART1 as my debugging serial port, and i use another library that needs the class for debugging. (SimpleFOC)
Another possible fix would be a build flag that leaves the
USART2_IRQHandlerdefinition, but allows it to switch fromHAL_UART_IRQHandlertoHAL_USART_IRQHandler