Merge branch 'improve_spi_drv' of ssh://github.com/TomoYamanaka/mbed-os into TomoYamanaka-improve_spi_drv

pull/8423/head
Cruz Monrreal II 2018-10-12 21:46:41 -05:00
commit 7a61a17ce4
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);