Skip to content

Commit 6126cb7

Browse files
committed
Modify frequency setting processing of SPI
In case of off-line compiler, there is no problem about the frequency setting processing. But in case of online compiler, the frequency setting processing will be error. So, modify frequency setting processing of SPI to pass in online compiler.
1 parent 2f63fa7 commit 6126cb7

File tree

1 file changed

+5
-1
lines changed
  • libraries/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H

1 file changed

+5
-1
lines changed

libraries/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/spi_api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ void spi_frequency(spi_t *obj, int hz) {
169169
uint32_t pclk_base;
170170
uint32_t div;
171171
uint32_t brdv = 0;
172+
uint32_t hz_max;
173+
uint32_t hz_min;
172174
uint16_t mask = 0x000c;
173175

174176
/* set PCLK */
@@ -178,7 +180,9 @@ void spi_frequency(spi_t *obj, int hz) {
178180
pclk_base = CM0_RENESAS_RZ_A1_P1_CLK;
179181
}
180182

181-
if ((hz < (pclk_base / 2 / 256 / 8)) || (hz > (pclk_base / 2))) {
183+
hz_min = pclk_base / 2 / 256 / 8;
184+
hz_max = pclk_base / 2;
185+
if ((hz < hz_min) || (hz > hz_max)) {
182186
error("Couldn't setup requested SPI frequency");
183187
return;
184188
}

0 commit comments

Comments
 (0)