Skip to content

Conversation

@Santynolo
Copy link

Summary
This PR implements build flags for disabling IRQHandlers used in the uart.c file in the SrcWrapper/src/stm32 folder allowing the user to write and use their own implementations of different USARTx_IRQHandler definitions while keeping HardwareSerial functionality in other USART/UART peripherals.

New build flags
I propose implementing the following build flags:

  • HAL_DISABLE_USART1_IRQHANDLER
  • HAL_DISABLE_USART2_IRQHANDLER
  • HAL_DISABLE_USART3_IRQHANDLER
  • HAL_DISABLE_UART4_IRQHANDLER
  • HAL_DISABLE_USART4_5_IRQHANDLER
  • HAL_DISABLE_USART4_IRQHANDLER
  • HAL_DISABLE_USART5_IRQHANDLER
  • HAL_DISABLE_USART6_IRQHANDLER
  • HAL_DISABLE_LPUART1_IRQHANDLER
  • HAL_DISABLE_UART7_IRQHANDLER
  • HAL_DISABLE_UART8_IRQHANDLER
  • HAL_DISABLE_UART9_IRQHANDLER
  • HAL_DISABLE_UART10_IRQHANDLER
  • HAL_DISABLE_USART10_IRQHANDLER
  • HAL_DISABLE_USART11_IRQHANDLER
  • HAL_DISABLE_UART12_IRQHANDLER
  • HAL_DISABLE_UART_WAKEUPCALLBACK

A build flag for each IRQHandler.
Why
This change would allow using custom implementations of for example, the USART2 and USART3 peripherals in synchronous mode (using a clock signal), while leaving the USART1 interface or others as a HardwareSerial port for printing to a serial monitor, or for use by libraries that use the standard Print class for debugging.

Here's an example of a build flag (in platformio) and a standard USART3_IRQHandler user definition (that compiles).
image
image

This code compiles (and the USART3_IRQHandler triggers correctly) with no errors (that i know of), and allows using USART1 as the Serial port and printing with no issues.
This is my first PR, please suggest improvements.
Implementation
I have implemented this by surrounding all of the IRQHandlers defined in uart.c in #ifndef [FLAG]
image
NOTE that this can break or cause unexpected behaviour if this build flag is defined and the user attempts to use the corresponding HardwareSerial class. Trying to use HardwareSerial on the USART2 while the build flag HAL_DISABLE_USART2_IRQHANDLER is defined will cause crashes and other behaviour i'm sure (Have not attempted). So i would suggest warning about this on the Wiki if this PR is merged.
Fixes

Fixes #2899

@Santynolo
Copy link
Author

I have accidentally added an extra commit (Merge branch 'stm32duino:main' into hal-irqhandler-flagdisabling) that i do not know how to remove.

…ing"

This reverts commit 67866e9, reversing
changes made to 2a84e95.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant