Add HAL_DISABLE_UxARTx_IRQHANDLER build flags #2902
+2,067
−2,038
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements build flags for disabling
IRQHandlers used in theuart.cfile in theSrcWrapper/src/stm32folder allowing the user to write and use their own implementations of differentUSARTx_IRQHandlerdefinitions while keepingHardwareSerialfunctionality in other USART/UART peripherals.New build flags
I propose implementing the following build flags:
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).


This code compiles (and the

USART3_IRQHandlertriggers 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 inuart.cin#ifndef [FLAG]NOTE that this can break or cause unexpected behaviour if this build flag is defined and the user attempts to use the corresponding
HardwareSerialclass. Trying to use HardwareSerial on the USART2 while the build flagHAL_DISABLE_USART2_IRQHANDLERis 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