66#include < Wire.h>
77
88
9- ICM_20948_Status_e write (uint8_t reg, uint8_t * data, uint32_t len);
10- ICM_20948_Status_e read (uint8_t reg, uint8_t * buff, uint32_t len);
9+ ICM_20948_Status_e write (uint8_t reg, uint8_t * data, uint32_t len, void * user );
10+ ICM_20948_Status_e read (uint8_t reg, uint8_t * buff, uint32_t len, void * user );
1111#define I2C_ADDR 0x69
1212
1313
@@ -143,7 +143,7 @@ void loop() {
143143
144144}
145145
146- ICM_20948_Status_e write (uint8_t reg, uint8_t * data, uint32_t len){
146+ ICM_20948_Status_e write (uint8_t reg, uint8_t * data, uint32_t len, void * user ){
147147 Wire.beginTransmission (I2C_ADDR);
148148 Wire.write (reg);
149149 Wire.write (data, len);
@@ -152,7 +152,7 @@ ICM_20948_Status_e write(uint8_t reg, uint8_t* data, uint32_t len){
152152 return ICM_20948_Stat_Ok;
153153}
154154
155- ICM_20948_Status_e read (uint8_t reg, uint8_t * buff, uint32_t len){
155+ ICM_20948_Status_e read (uint8_t reg, uint8_t * buff, uint32_t len, void * user ){
156156 Wire.beginTransmission (I2C_ADDR);
157157 Wire.write (reg);
158158 Wire.endTransmission (false ); // Send repeated start
@@ -179,15 +179,15 @@ ICM_20948_Status_e read(uint8_t reg, uint8_t* buff, uint32_t len){
179179void setBank (uint8_t bank){
180180 bank &= 0x03 ; // mask off values above 3
181181 bank = bank << 4 ; // Shift into the right place
182- write ((uint8_t )REG_BANK_SEL, &bank, 1 );
182+ write ((uint8_t )REG_BANK_SEL, &bank, 1 , NULL );
183183}
184184
185185void getAGMT ( ICM_20948_AGMT_t* p ){
186186 const uint8_t numbytes = 14 ;
187187 uint8_t buff[numbytes];
188188
189189 setBank (0 );
190- read ( (uint8_t )AGB0_REG_ACCEL_XOUT_H, buff, numbytes);
190+ read ( (uint8_t )AGB0_REG_ACCEL_XOUT_H, buff, numbytes, NULL );
191191
192192 p->acc .i16bit [0 ] = ((buff[0 ] << 8 ) | (buff[1 ] & 0xFF ));
193193 p->acc .i16bit [1 ] = ((buff[2 ] << 8 ) | (buff[3 ] & 0xFF ));
@@ -208,18 +208,18 @@ void getAGMT( ICM_20948_AGMT_t* p ){
208208
209209 setBank (2 );
210210 ICM_20948_ACCEL_CONFIG_t acfg;
211- read ( (uint8_t )AGB2_REG_ACCEL_CONFIG, (uint8_t *)&acfg, 1 *sizeof (acfg));
211+ read ( (uint8_t )AGB2_REG_ACCEL_CONFIG, (uint8_t *)&acfg, 1 *sizeof (acfg), NULL );
212212 p->fss .a = acfg.ACCEL_FS_SEL ; // Worth noting that without explicitly setting the FS range of the accelerometer it was showing the register value for +/- 2g but the reported values were actually scaled to the +/- 16g range
213213 // Wait a minute... now it seems like this problem actually comes from the digital low-pass filter. When enabled the value is 1/8 what it should be...
214214 setBank (2 );
215215 ICM_20948_GYRO_CONFIG_1_t gcfg1;
216- read ( (uint8_t )AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&gcfg1, 1 *sizeof (gcfg1));
216+ read ( (uint8_t )AGB2_REG_GYRO_CONFIG_1, (uint8_t *)&gcfg1, 1 *sizeof (gcfg1), NULL );
217217 p->fss .g = gcfg1.GYRO_FS_SEL ;
218218
219219// Serial.print("acc cfg: 0x"); Serial.print(*((uint8_t*)&acfg), HEX); Serial.println();
220220
221221 ICM_20948_ACCEL_CONFIG_2_t acfg2;
222- read ( (uint8_t )AGB2_REG_ACCEL_CONFIG_2, (uint8_t *)&acfg2, 1 *sizeof (acfg2));
222+ read ( (uint8_t )AGB2_REG_ACCEL_CONFIG_2, (uint8_t *)&acfg2, 1 *sizeof (acfg2), NULL );
223223// Serial.print("acc cfg2: 0x"); Serial.print(*((uint8_t*)&acfg2), HEX); Serial.println();
224224
225225}
@@ -276,7 +276,7 @@ void printRawAGMT( ICM_20948_AGMT_t agmt){
276276
277277uint16_t fifoAvailable ( void ){
278278 uint16_t retval = 0 ;
279- read ((uint8_t )AGB0_REG_FIFO_COUNT_H, (uint8_t *)&retval, 2 );
279+ read ((uint8_t )AGB0_REG_FIFO_COUNT_H, (uint8_t *)&retval, 2 , NULL );
280280 return retval;
281281}
282282
0 commit comments