Improve frequency setting proc of Renesas SPI driver

If the specified frequency exceeds the upper limit and lower limit at SPI driver, an error is output, but this does not match policy with other renesas drivers. Thus I revises the processing as follows.
- If "hz" is maximum over, it is rounded by the maximum value.
- If "hz" is minimum under, it is rounded by the minimum value.
pull/8379/head
TomoYamanaka 2018-10-11 20:51:20 +09:00
parent c43a3f4dfb
commit 470f9bc375
1 changed files with 5 additions and 3 deletions

View File

@ -149,9 +149,11 @@ void spi_frequency(spi_t *obj, int hz) {
hz_min = pclk_base / 2 / 256 / 8;
hz_max = pclk_base / 2;
if (((uint32_t)hz < hz_min) || ((uint32_t)hz > hz_max)) {
error("Couldn't setup requested SPI frequency");
return;
if ((uint32_t)hz < hz_min) {
hz = hz_min;
}
if ((uint32_t)hz > hz_max) {
hz = hz_max;
}
div = (pclk_base / hz / 2);