add the STM32WL SUGGHZSPI to the SPI library #1803
Closed
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.
The raison d'être for the STM32WL series is its internal SUBGHZSPI peripheral. SUBGHZSPI may have its own chapter in the Reference Manual separate from other SPI peripherals, but SUBGHZSPI is identical in operation to other SPI peripherals:
However, despite this, the SPI implementation of Arduino_Core_STM32 does not presently support SUBGHZSPI. This PR tweaks the existing implementation to make this possible.
The Arduino Way (tm) of implementing SPI is to insist that the user provides the pin names of the peripheral. Using a database of all possible peripherals stored as part of the firmware, Arduino then evaluates these at run time to map them back to the peripheral. (Chacun à son goût)
To make that method work with SUBGHZSPI, this PR creates three virtual digital pins: SUBGHZSPI_MOSI, SUBGHZSPI_MISO, and SUBGHZSPI_SCLK. These pins are added to the pin databases for the STM32WL variants.
The only difference between SUBGHZSPI and other SPI peripherals is that its pins are hard-wired to the internal peripheral, rather than using the GPIO Alternate Function multiplexer. This condition is signaled by having the "int function" member of the PinMap struct be negative. Then, .libraries/SrcWrapper/src/stm32/pinmap.c detects this in pin_function() and omits the inappropriate GPIO AF code.