Skip to content

Commit c97b49f

Browse files
committed
SPI: provide a hook to set the minimum SPI frequency
On Giga, the system will complain loudly if the frequency selected is too low ```<err> spi_ll_stm32: Unsupported frequency 400000Hz, max 120000000Hz, min 937500Hz``` Let's try to keep this at minimum or change when we'll be able to grab the same infor from a macro/API provided by zephyr
1 parent 5eb1f50 commit c97b49f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: libraries/SPI/SPI.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ void arduino::ZephyrSPI::usingInterrupt(int interruptNumber) {
7979
void arduino::ZephyrSPI::notUsingInterrupt(int interruptNumber) {
8080
}
8181

82+
#ifndef SPI_MIN_CLOCK_FEQUENCY
83+
#define SPI_MIN_CLOCK_FEQUENCY 1000000
84+
#endif
85+
8286
void arduino::ZephyrSPI::beginTransaction(SPISettings settings) {
8387
memset(&config, 0, sizeof(config));
84-
config.frequency = settings.getClockFreq();
88+
config.frequency = settings.getClockFreq() > SPI_MIN_CLOCK_FEQUENCY ? settings.getClockFreq() : SPI_MIN_CLOCK_FEQUENCY;
8589
auto mode = SPI_MODE_CPOL | SPI_MODE_CPHA;
8690
switch (settings.getDataMode()) {
8791
case SPI_MODE0:

0 commit comments

Comments
 (0)