2018-01-10 14:22:25 UTC
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
if (frequency > STM32_SPI_CLK_MAX)
frequency = STM32_SPI_CLK_MAX;
This looks incorrect and not necassery at all:
1. e.g. for STM32F4xx we have number of SPI's which are working on different buses and have different maximum speed
2. at least for STM32F4xxx SPI1 which is quickest this value is defined as:
#define STM32_SPI_CLK_MAX 37500000UL
Which is incorrect too. I think it came from overview document ("SPI1 can communicate at up to 37.5 Mbits/s"), but what does mean "bits" here? At least maximum clock (as define named) is Fpclk/2 -> for 168MHz -> 42MHz!
So, as a reason it stays impossible to setup maximum speed for SPI1 bus, because first it is limited to 37.5 and then compared to 42MHz (if (frequency >= priv->spiclock >> 1)) failed and set in if (frequency >= priv->spiclock >> 2) condition to 21MHz.
Can we just remove this first limitation (frequency = STM32_SPI_CLK_MAX) as no sense? In any case actual frequence will be seted up during prescaler selection.