Skip to content

Commit d5ae1eb

Browse files
authored
Merge pull request #85 from sparkfun/release_candidate
v1.2.9
2 parents b27edc2 + a93f0df commit d5ae1eb

File tree

5 files changed

+56
-14
lines changed

5 files changed

+56
-14
lines changed

examples/Arduino/Example2_Advanced/Example2_Advanced.ino

-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ void setup()
9898
SERIAL_PORT.println(myICM.statusString());
9999
}
100100

101-
delay(1); // Give the ICM20948 time to change the sample mode (see issue #8)
102-
103101
// Set full scale ranges for both acc and gyr
104102
ICM_20948_fss_t myFSS; // This uses a "Full Scale Settings" structure that can contain values for all configurable sensors
105103

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library
2-
version=1.2.8
2+
version=1.2.9
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
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™).

src/ICM_20948.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ bool ICM_20948::isConnected(void)
395395
ICM_20948_Status_e ICM_20948::setSampleMode(uint8_t sensor_id_bm, uint8_t lp_config_cycle_mode)
396396
{
397397
status = ICM_20948_set_sample_mode(&_device, (ICM_20948_InternalSensorID_bm)sensor_id_bm, (ICM_20948_LP_CONFIG_CYCLE_e)lp_config_cycle_mode);
398+
delay(1); // Give the ICM20948 time to change the sample mode (see issue #8)
398399
return status;
399400
}
400401

@@ -1704,16 +1705,7 @@ ICM_20948_Status_e ICM_20948_read_I2C(uint8_t reg, uint8_t *buff, uint32_t len,
17041705
_i2c->write(reg);
17051706
_i2c->endTransmission(false); // Send repeated start
17061707

1707-
uint32_t offset = 0;
17081708
uint32_t num_received = _i2c->requestFrom(addr, len);
1709-
// while(_i2c->available()){
1710-
// if(len > 0){
1711-
// *(buff + offset) = _i2c->read();
1712-
// len--;
1713-
// }else{
1714-
// break;
1715-
// }
1716-
// }
17171709

17181710
if (num_received == len)
17191711
{

src/util/ICM_20948_C.c

+53-1
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,26 @@ ICM_20948_Status_e ICM_20948_set_sample_mode(ICM_20948_Device_t *pdev, ICM_20948
627627
{
628628
return retval;
629629
}
630+
631+
// Check the data was written correctly
632+
retval = ICM_20948_execute_r(pdev, AGB0_REG_LP_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_LP_CONFIG_t));
633+
if (retval != ICM_20948_Stat_Ok)
634+
{
635+
return retval;
636+
}
637+
if (sensors & ICM_20948_Internal_Acc)
638+
{
639+
if (reg.ACCEL_CYCLE != mode) retval = ICM_20948_Stat_Err;
640+
}
641+
if (sensors & ICM_20948_Internal_Gyr)
642+
{
643+
if (reg.GYRO_CYCLE != mode) retval = ICM_20948_Stat_Err;
644+
}
645+
if (sensors & ICM_20948_Internal_Mst)
646+
{
647+
if (reg.I2C_MST_CYCLE != mode) retval = ICM_20948_Stat_Err;
648+
}
649+
630650
return retval;
631651
}
632652

@@ -646,6 +666,9 @@ ICM_20948_Status_e ICM_20948_set_full_scale(ICM_20948_Device_t *pdev, ICM_20948_
646666
retval |= ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
647667
reg.ACCEL_FS_SEL = fss.a;
648668
retval |= ICM_20948_execute_w(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
669+
// Check the data was written correctly
670+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
671+
if (reg.ACCEL_FS_SEL != fss.a) retval |= ICM_20948_Stat_Err;
649672
}
650673
if (sensors & ICM_20948_Internal_Gyr)
651674
{
@@ -654,6 +677,9 @@ ICM_20948_Status_e ICM_20948_set_full_scale(ICM_20948_Device_t *pdev, ICM_20948_
654677
retval |= ICM_20948_execute_r(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
655678
reg.GYRO_FS_SEL = fss.g;
656679
retval |= ICM_20948_execute_w(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
680+
// Check the data was written correctly
681+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
682+
if (reg.GYRO_FS_SEL != fss.g) retval |= ICM_20948_Stat_Err;
657683
}
658684
return retval;
659685
}
@@ -674,6 +700,9 @@ ICM_20948_Status_e ICM_20948_set_dlpf_cfg(ICM_20948_Device_t *pdev, ICM_20948_In
674700
retval |= ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
675701
reg.ACCEL_DLPFCFG = cfg.a;
676702
retval |= ICM_20948_execute_w(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
703+
// Check the data was written correctly
704+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
705+
if (reg.ACCEL_DLPFCFG != cfg.a) retval |= ICM_20948_Stat_Err;
677706
}
678707
if (sensors & ICM_20948_Internal_Gyr)
679708
{
@@ -682,6 +711,9 @@ ICM_20948_Status_e ICM_20948_set_dlpf_cfg(ICM_20948_Device_t *pdev, ICM_20948_In
682711
retval |= ICM_20948_execute_r(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
683712
reg.GYRO_DLPFCFG = cfg.g;
684713
retval |= ICM_20948_execute_w(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
714+
// Check the data was written correctly
715+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
716+
if (reg.GYRO_DLPFCFG != cfg.g) retval |= ICM_20948_Stat_Err;
685717
}
686718
return retval;
687719
}
@@ -709,6 +741,16 @@ ICM_20948_Status_e ICM_20948_enable_dlpf(ICM_20948_Device_t *pdev, ICM_20948_Int
709741
reg.ACCEL_FCHOICE = 0;
710742
}
711743
retval |= ICM_20948_execute_w(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
744+
// Check the data was written correctly
745+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_CONFIG, (uint8_t *)&reg, sizeof(ICM_20948_ACCEL_CONFIG_t));
746+
if (enable)
747+
{
748+
if (reg.ACCEL_FCHOICE != 1) retval |= ICM_20948_Stat_Err;
749+
}
750+
else
751+
{
752+
if (reg.ACCEL_FCHOICE != 0) retval |= ICM_20948_Stat_Err;
753+
}
712754
}
713755
if (sensors & ICM_20948_Internal_Gyr)
714756
{
@@ -724,6 +766,16 @@ ICM_20948_Status_e ICM_20948_enable_dlpf(ICM_20948_Device_t *pdev, ICM_20948_Int
724766
reg.GYRO_FCHOICE = 0;
725767
}
726768
retval |= ICM_20948_execute_w(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
769+
// Check the data was written correctly
770+
retval |= ICM_20948_execute_r(pdev, AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&reg, sizeof(ICM_20948_GYRO_CONFIG_1_t));
771+
if (enable)
772+
{
773+
if (reg.GYRO_FCHOICE != 1) retval |= ICM_20948_Stat_Err;
774+
}
775+
else
776+
{
777+
if (reg.GYRO_FCHOICE != 0) retval |= ICM_20948_Stat_Err;
778+
}
727779
}
728780
return retval;
729781
}
@@ -2384,7 +2436,7 @@ ICM_20948_Status_e inv_icm20948_read_dmp_data(ICM_20948_Device_t *pdev, icm_2094
23842436
return result;
23852437
}
23862438

2387-
static uint8_t sensor_type_2_android_sensor(enum inv_icm20948_sensor sensor)
2439+
uint8_t sensor_type_2_android_sensor(enum inv_icm20948_sensor sensor)
23882440
{
23892441
switch (sensor)
23902442
{

src/util/ICM_20948_C.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ extern int memcmp(const void *, const void *, size_t); // Avoid compiler warning
274274
ICM_20948_Status_e inv_icm20948_set_dmp_sensor_period(ICM_20948_Device_t *pdev, enum DMP_ODR_Registers odr_reg, uint16_t interval);
275275
ICM_20948_Status_e inv_icm20948_enable_dmp_sensor(ICM_20948_Device_t *pdev, enum inv_icm20948_sensor sensor, int state); // State is actually boolean
276276
ICM_20948_Status_e inv_icm20948_enable_dmp_sensor_int(ICM_20948_Device_t *pdev, enum inv_icm20948_sensor sensor, int state); // State is actually boolean
277-
static uint8_t sensor_type_2_android_sensor(enum inv_icm20948_sensor sensor);
277+
uint8_t sensor_type_2_android_sensor(enum inv_icm20948_sensor sensor);
278278
enum inv_icm20948_sensor inv_icm20948_sensor_android_2_sensor_type(int sensor);
279279

280280
ICM_20948_Status_e inv_icm20948_read_dmp_data(ICM_20948_Device_t *pdev, icm_20948_DMP_data_t *data);

0 commit comments

Comments
 (0)