From 4806b519ec350fc320d297eff11d9d812aa42040 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 8 Feb 2021 16:10:15 +0000 Subject: [PATCH] Changes to allow the code to compile on the Arduino NANO 33 BLE I've compiled these changes for every board I have installed and they seem fine. But there may be boards out there that do need the ```extern TwoWire Wire``` and ```extern SPIClass SPI```. Backward compatibility is not 100% guaranteed! --- src/ICM_20948.cpp | 2 +- src/ICM_20948.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ICM_20948.cpp b/src/ICM_20948.cpp index a7ee4d0..48918b3 100644 --- a/src/ICM_20948.cpp +++ b/src/ICM_20948.cpp @@ -908,7 +908,7 @@ ICM_20948_Status_e ICM_20948_write_I2C(uint8_t reg, uint8_t *data, uint32_t len, _i2c->beginTransmission(addr); _i2c->write(reg); - _i2c->write(data, len); + _i2c->write(data, (uint8_t)len); _i2c->endTransmission(); // for( uint32_t indi = 0; indi < len; indi++ ){ diff --git a/src/ICM_20948.h b/src/ICM_20948.h index df5357e..fb220d7 100644 --- a/src/ICM_20948.h +++ b/src/ICM_20948.h @@ -119,8 +119,8 @@ class ICM_20948 // I2C // Forward declarations of TwoWire and Wire for board/variant combinations that don't have a default 'SPI' -class TwoWire; -extern TwoWire Wire; +//class TwoWire; // Commented by PaulZC 21/2/8 - this was causing compilation to fail on the Arduino NANO 33 BLE +//extern TwoWire Wire; // Commented by PaulZC 21/2/8 - this was causing compilation to fail on the Arduino NANO 33 BLE class ICM_20948_I2C : public ICM_20948 { @@ -144,8 +144,8 @@ class ICM_20948_I2C : public ICM_20948 #define ICM_20948_SPI_DEFAULT_MODE SPI_MODE0 // Forward declarations of SPIClass and SPI for board/variant combinations that don't have a default 'SPI' -class SPIClass; -extern SPIClass SPI; +//class SPIClass; // Commented by PaulZC 21/2/8 - this was causing compilation to fail on the Arduino NANO 33 BLE +//extern SPIClass SPI; // Commented by PaulZC 21/2/8 - this was causing compilation to fail on the Arduino NANO 33 BLE class ICM_20948_SPI : public ICM_20948 { @@ -162,4 +162,4 @@ class ICM_20948_SPI : public ICM_20948 ICM_20948_Status_e begin(uint8_t csPin, SPIClass &spiPort = SPI, uint32_t SPIFreq = ICM_20948_SPI_DEFAULT_FREQ); }; -#endif /* _ICM_20948_H_ */ \ No newline at end of file +#endif /* _ICM_20948_H_ */