Skip to content

Commit 7234182

Browse files
committed
Merge pull request #817 from masaohamanaka/master
RZ_A1H - Modify frequency setting processing of SPI
2 parents 77d6454 + 6126cb7 commit 7234182

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)