I'm referring to this message:
Code: Select all
#error "SD1 requires USART1 but it is already used"
...and similar checks involving [font=Courier New]STM32_USART*_IS_USED[/font].
Is this just a safeguard to prevent accidentally enabling the same peripheral for different drivers — which could result in unexpected memory usage or calling functions from different drivers on the same hardware peripheral? Or is there a deeper, low-level hardware limitation that prevents such usage?
In my case, the device can be connected to different external modules via a serial interface, each using a completely different protocol. Some of these protocols are best implemented using the Serial Driver (variable-length packets), while others are more efficient and better suited for the UART Driver (fixed-length packets).
I want to support both drivers, but only one will be used at a time depending on the connected device. The configuration is stored in EEPROM and applied after reboot. I can guarantee that functions from different drivers will not be called simultaneously on the same peripheral. The additional memory used by having both driver structures is acceptable in my case.
I can manually patch the HAL checks, but I want to be sure this won’t cause any unintended side effects when using these drivers in such way.