@@ -220,16 +220,9 @@ void SPIClass::setDataMode(uint8_t _pin, uint8_t _mode)
220
220
221
221
/* *
222
222
* @brief Deprecated function.
223
- * Configure the clock speed: 125kHz to 8MHz.
223
+ * Configure the clock speed
224
224
* @param _pin: CS pin associated to a configuration (optional).
225
- * @param _divider: can be one of the following parameters:
226
- * SPI_CLOCK_DIV2 (8MHz)
227
- * SPI_CLOCK_DIV4 (4MHz)
228
- * SPI_CLOCK_DIV8 (2MHz)
229
- * SPI_CLOCK_DIV16 (1MHz)
230
- * SPI_CLOCK_DIV32 (500kHz)
231
- * SPI_CLOCK_DIV64 (250kHz)
232
- * SPI_CLOCK_DIV128 (125kHz)
225
+ * @param _divider: the SPI clock can be divided by values from 1 to 255
233
226
*/
234
227
void SPIClass::setClockDivider (uint8_t _pin, uint8_t _divider)
235
228
{
@@ -240,24 +233,13 @@ void SPIClass::setClockDivider(uint8_t _pin, uint8_t _divider)
240
233
if (idx >= NB_SPI_SETTINGS) {
241
234
return ;
242
235
}
243
-
236
+ if (_divider == 0 ) {
237
+ return ;
238
+ }
244
239
/* Get clk freq of the SPI instance */
245
240
uint32_t spiClkFreq = spi_getClkFreq (&_spi);
246
241
247
- switch (_divider) {
248
- case (SPI_CLOCK_DIV2) :
249
- case (SPI_CLOCK_DIV4) :
250
- case (SPI_CLOCK_DIV8) :
251
- case (SPI_CLOCK_DIV16) :
252
- case (SPI_CLOCK_DIV32) :
253
- case (SPI_CLOCK_DIV64) :
254
- case (SPI_CLOCK_DIV128) :
255
- spiSettings[idx].clk = spiClkFreq/_divider;
256
- break ;
257
- default :
258
- spiSettings[idx].clk = SPI_SPEED_CLOCK_DEFAULT;
259
- break ;
260
- }
242
+ spiSettings[idx].clk = spiClkFreq/_divider;
261
243
262
244
spi_init (&_spi, spiSettings[idx].clk ,
263
245
spiSettings[idx].dMode ,
0 commit comments