Skip to content

Commit e52df4c

Browse files
committed
Extra diagnostics
1 parent e6be93d commit e52df4c

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/ICM_20948.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,12 @@ ICM_20948_Status_e ICM_20948::enableDMPSensor(enum inv_icm20948_sensor sensor, b
10471047
debugPrintf((int)_device._enabled_Android_0);
10481048
debugPrint(F(" _enabled_Android_1: "));
10491049
debugPrintf((int)_device._enabled_Android_1);
1050+
debugPrint(F(" _dataOutCtl1: "));
1051+
debugPrintf((int)_device._dataOutCtl1);
1052+
debugPrint(F(" _dataOutCtl2: "));
1053+
debugPrintf((int)_device._dataOutCtl2);
1054+
debugPrint(F(" _dataRdyStatus: "));
1055+
debugPrintf((int)_device._dataRdyStatus);
10501056
debugPrintln(F(""));
10511057
return status;
10521058
}
@@ -1062,6 +1068,8 @@ ICM_20948_Status_e ICM_20948::enableDMPSensorInt(enum inv_icm20948_sensor sensor
10621068
debugPrintf((int)_device._enabled_Android_intr_0);
10631069
debugPrint(F(" _enabled_Android_intr_1: "));
10641070
debugPrintf((int)_device._enabled_Android_intr_1);
1071+
debugPrint(F(" _dataIntrCtl: "));
1072+
debugPrintf((int)_device._dataIntrCtl);
10651073
debugPrintln(F(""));
10661074
return status;
10671075
}

src/util/ICM_20948_C.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,7 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor(ICM_20948_Device_t *pdev, enum
17231723
unsigned char data_output_control_reg[2];
17241724
data_output_control_reg[0] = (unsigned char)(delta >> 8);
17251725
data_output_control_reg[1] = (unsigned char)(delta & 0xff);
1726+
pdev->_dataOutCtl1 = delta; // Diagnostics
17261727
result = inv_icm20948_write_mems(pdev, DATA_OUT_CTL1, 2, (const unsigned char *)&data_output_control_reg);
17271728
if (result != ICM_20948_Stat_Ok)
17281729
{
@@ -1732,6 +1733,7 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor(ICM_20948_Device_t *pdev, enum
17321733
// Write the 'header2' sensor control bits into memory address DATA_OUT_CTL2
17331734
data_output_control_reg[0] = (unsigned char)(delta2 >> 8);
17341735
data_output_control_reg[1] = (unsigned char)(delta2 & 0xff);
1736+
pdev->_dataOutCtl2 = delta2; // Diagnostics
17351737
result = inv_icm20948_write_mems(pdev, DATA_OUT_CTL2, 2, (const unsigned char *)&data_output_control_reg);
17361738
if (result != ICM_20948_Stat_Ok)
17371739
{
@@ -1741,6 +1743,7 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor(ICM_20948_Device_t *pdev, enum
17411743
// Set the DATA_RDY_STATUS register
17421744
data_output_control_reg[0] = (unsigned char)(data_rdy_status >> 8);
17431745
data_output_control_reg[1] = (unsigned char)(data_rdy_status & 0xff);
1746+
pdev->_dataRdyStatus = data_rdy_status; // Diagnostics
17441747
result = inv_icm20948_write_mems(pdev, DATA_RDY_STATUS, 2, (const unsigned char *)&data_output_control_reg);
17451748
if (result != ICM_20948_Stat_Ok)
17461749
{
@@ -1764,6 +1767,7 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor(ICM_20948_Device_t *pdev, enum
17641767
// Set the MOTION_EVENT_CTL register
17651768
data_output_control_reg[0] = (unsigned char)(inv_event_control >> 8);
17661769
data_output_control_reg[1] = (unsigned char)(inv_event_control & 0xff);
1770+
pdev->_motionEventCtl = inv_event_control; // Diagnostics
17671771
result = inv_icm20948_write_mems(pdev, MOTION_EVENT_CTL, 2, (const unsigned char *)&data_output_control_reg);
17681772
if (result != ICM_20948_Stat_Ok)
17691773
{
@@ -1836,11 +1840,6 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor_int(ICM_20948_Device_t *pdev,
18361840
}
18371841
}
18381842

1839-
unsigned char data_intr_ctl[2];
1840-
1841-
data_intr_ctl[0] = (unsigned char)(delta >> 8);
1842-
data_intr_ctl[1] = (unsigned char)(delta & 0xff);
1843-
18441843
result = ICM_20948_sleep(pdev, false); // Make sure chip is awake
18451844
if (result != ICM_20948_Stat_Ok)
18461845
{
@@ -1853,6 +1852,12 @@ ICM_20948_Status_e inv_icm20948_enable_dmp_sensor_int(ICM_20948_Device_t *pdev,
18531852
return result;
18541853
}
18551854

1855+
unsigned char data_intr_ctl[2];
1856+
1857+
data_intr_ctl[0] = (unsigned char)(delta >> 8);
1858+
data_intr_ctl[1] = (unsigned char)(delta & 0xff);
1859+
pdev->_dataIntrCtl = delta; // Diagnostics
1860+
18561861
// Write the interrupt control bits into memory address DATA_INTR_CTL
18571862
result = inv_icm20948_write_mems(pdev, DATA_INTR_CTL, 2, (const unsigned char *)&data_intr_ctl);
18581863

src/util/ICM_20948_C.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ extern int memcmp(const void *, const void *, size_t); // Avoid compiler warning
172172
uint32_t _enabled_Android_1; // Keep track of which Android sensors are enabled: 32-
173173
uint32_t _enabled_Android_intr_0; // Keep track of which Android sensor interrupts are enabled: 0-31
174174
uint32_t _enabled_Android_intr_1; // Keep track of which Android sensor interrupts are enabled: 32-
175+
uint16_t _dataOutCtl1; // Diagnostics: record the setting of DATA_OUT_CTL1
176+
uint16_t _dataOutCtl2; // Diagnostics: record the setting of DATA_OUT_CTL2
177+
uint16_t _dataRdyStatus; // Diagnostics: record the setting of DATA_RDY_STATUS
178+
uint16_t _motionEventCtl; // Diagnostics: record the setting of MOTION_EVENT_CTL
179+
uint16_t _dataIntrCtl; // Diagnostics: record the setting of DATA_INTR_CTL
175180
} ICM_20948_Device_t; // Definition of device struct type
176181

177182
// ICM_20948_Status_e ICM_20948_Startup( ICM_20948_Device_t* pdev ); // For the time being this performs a standardized startup routine

0 commit comments

Comments
 (0)