Skip to content

Commit 470f9bc

Browse files
committed
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.
1 parent c43a3f4 commit 470f9bc

File tree

1 file changed

+5
-3
lines changed
  • targets/TARGET_RENESAS/TARGET_RZ_A1XX

1 file changed

+5
-3
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1XX/spi_api.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ void spi_frequency(spi_t *obj, int hz) {
149149

150150
hz_min = pclk_base / 2 / 256 / 8;
151151
hz_max = pclk_base / 2;
152-
if (((uint32_t)hz < hz_min) || ((uint32_t)hz > hz_max)) {
153-
error("Couldn't setup requested SPI frequency");
154-
return;
152+
if ((uint32_t)hz < hz_min) {
153+
hz = hz_min;
154+
}
155+
if ((uint32_t)hz > hz_max) {
156+
hz = hz_max;
155157
}
156158

157159
div = (pclk_base / hz / 2);

0 commit comments

Comments
 (0)