stm32f30x-hal
stm32f30x-hal copied to clipboard
SPI frequency may not be exactly as configured
Depending on fpclk, there are only a few selectable SPI frequencies. However, the SPI init function allows selection of an arbitrary frequency, and then rounds to the closest available.
This seems great from an API design standpoint, but could be surprising to someone not familiar with the low-level details of an STM32F3's clock tree. Furthermore, there might be cases where the programmer wants to ensure that the actual frequency falls into certain bounds.
This could be done by allowing the user to specify Option
al max_freq
and min_freq
parameters in addition to (or instead of) the single target freq
. For ergonomics and backwards compatibility, perhaps this is an additional spi initialization function (i.e. spi1()
and spi1_freq_bounds()
)