Skip to content

Commit 1282690

Browse files
author
Nathan Seidle
committed
Limit SPI freq to 7MHz and change default to 6MHz at begin
IC can't communicate with SPI freqs above 7MHz. And some platforms (looking at you Artemis) will run the SPI clock at 7.125MHz when started at 7MHz breaking the first example.
1 parent f096cf3 commit 1282690

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/ICM_20948.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ ICM_20948_SPI::ICM_20948_SPI()
887887

888888
ICM_20948_Status_e ICM_20948_SPI::begin(uint8_t csPin, SPIClass &spiPort, uint32_t SPIFreq)
889889
{
890+
if (SPIFreq > 7000000)
891+
SPIFreq = 7000000;
892+
890893
// Associate
891894
_spi = &spiPort;
892895
_spisettings = SPISettings(SPIFreq, ICM_20948_SPI_DEFAULT_ORDER, ICM_20948_SPI_DEFAULT_MODE);

src/ICM_20948.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ICM_20948_I2C : public ICM_20948
138138
};
139139

140140
// SPI
141-
#define ICM_20948_SPI_DEFAULT_FREQ 7000000
141+
#define ICM_20948_SPI_DEFAULT_FREQ 6000000
142142
#define ICM_20948_SPI_DEFAULT_ORDER MSBFIRST
143143
#define ICM_20948_SPI_DEFAULT_MODE SPI_MODE0
144144

0 commit comments

Comments
 (0)