stm32f30x-hal icon indicating copy to clipboard operation
stm32f30x-hal copied to clipboard

SPI frequency may not be exactly as configured

Open austinglaser opened this issue 6 years ago • 0 comments

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 Optional 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())

austinglaser avatar Feb 27 '18 20:02 austinglaser