Skip to content

Add a build flag to disable specific USART IRQ handlers defined in the core #2899

Description

@Santynolo

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.

Image

Here is my suggested implementation: (I do not know if this will cause issues)

Image

Thanks. This could also be implemented in other IRQHandlers, for example to disable specific ADC IRQHandlers, without disabling the entire ADC arduino implementation.

Activity

  1. fpistm commented on Jan 23, 2026

    @fpistm
    Member

    Hi @Santynolo
    I see why but don't like the fact to mix Arduino and pure HAL.
    Anyway feel free to provide a PR.

  2. Santynolo commented on Jan 23, 2026

    @Santynolo
    Author

    I would like to but i'm wondering if my suggested implementation can cause issues. If not i'll do it

  3. fpistm commented on Jan 23, 2026

    @fpistm
    Member

    What is your goal exactly?

  4. Santynolo commented on Jan 23, 2026

    @Santynolo
    Author

    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.

    Image

    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:

    Image

    (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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions