diff --git a/examples/PortableC/Example999_Portable/Example999_Portable.ino b/examples/PortableC/Example999_Portable/Example999_Portable.ino index d1e59dc..ad58aa3 100644 --- a/examples/PortableC/Example999_Portable/Example999_Portable.ino +++ b/examples/PortableC/Example999_Portable/Example999_Portable.ino @@ -72,6 +72,9 @@ void setup() WIRE_PORT.setClock(400000); #endif + // Initialize myICM + ICM_20948_init_struct(&myICM); + // Link the serif ICM_20948_link_serif(&myICM, &mySerif); @@ -202,7 +205,6 @@ ICM_20948_Status_e my_read_i2c(uint8_t reg, uint8_t *buff, uint32_t len, void *u buff[i] = WIRE_PORT.read(); } } - WIRE_PORT.endTransmission(); return ICM_20948_Stat_Ok; } diff --git a/library.properties b/library.properties index bf7d5a0..b0dab8f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library -version=1.2.7 +version=1.2.8 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Use the low-power high-resolution ICM 20948 9 DoF IMU from Invensense with I2C or SPI. Version 1.2 of the library includes support for the InvenSense Digital Motion Processor (DMP™). diff --git a/src/ICM_20948.cpp b/src/ICM_20948.cpp index 1f534c2..0e19913 100644 --- a/src/ICM_20948.cpp +++ b/src/ICM_20948.cpp @@ -12,6 +12,7 @@ ICM_20948_Status_e ICM_20948_read_SPI(uint8_t reg, uint8_t *buff, uint32_t len, // Base ICM_20948::ICM_20948() { + status = ICM_20948_init_struct(&_device); } void ICM_20948::enableDebugging(Stream &debugPort) diff --git a/src/util/ICM_20948_C.c b/src/util/ICM_20948_C.c index 44d6ac4..356e44f 100644 --- a/src/util/ICM_20948_C.c +++ b/src/util/ICM_20948_C.c @@ -8,7 +8,9 @@ */ #if defined(ICM_20948_USE_DMP) // Only include the 14301 Bytes of DMP if ICM_20948_USE_DMP is defined -#if defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) // Store the DMP firmware in PROGMEM on older AVR (ATmega) platforms +#if defined(ARDUINO_ARCH_MBED) // ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h / PROGMEM +const uint8_t dmp3_image[] = { +#elif (defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__)) && !defined(__linux__) // Store the DMP firmware in PROGMEM on older AVR (ATmega) platforms #define ICM_20948_USE_PROGMEM_FOR_DMP #include const uint8_t dmp3_image[] PROGMEM = { @@ -120,6 +122,16 @@ const ICM_20948_Serif_t NullSerif = { // Private function prototypes // Function definitions +ICM_20948_Status_e ICM_20948_init_struct(ICM_20948_Device_t *pdev) +{ + // Initialize all elements by 0 except for _last_bank + // Initialize _last_bank to 4 (invalid bank number) + // so ICM_20948_set_bank function does not skip issuing bank change operation + static const ICM_20948_Device_t init_device = { ._last_bank = 4 }; + *pdev = init_device; + return ICM_20948_Stat_Ok; +} + ICM_20948_Status_e ICM_20948_link_serif(ICM_20948_Device_t *pdev, const ICM_20948_Serif_t *s) { if (s == NULL) diff --git a/src/util/ICM_20948_C.h b/src/util/ICM_20948_C.h index 088a714..c732ebc 100644 --- a/src/util/ICM_20948_C.h +++ b/src/util/ICM_20948_C.h @@ -184,6 +184,8 @@ extern int memcmp(const void *, const void *, size_t); // Avoid compiler warning uint16_t _dataIntrCtl; // Diagnostics: record the setting of DATA_INTR_CTL } ICM_20948_Device_t; // Definition of device struct type + ICM_20948_Status_e ICM_20948_init_struct(ICM_20948_Device_t *pdev); // Initialize ICM_20948_Device_t + // ICM_20948_Status_e ICM_20948_Startup( ICM_20948_Device_t* pdev ); // For the time being this performs a standardized startup routine ICM_20948_Status_e ICM_20948_link_serif(ICM_20948_Device_t *pdev, const ICM_20948_Serif_t *s); // Links a SERIF structure to the device