Skip to content

Commit 4c85462

Browse files
committed
Fix C-backbone examples
1 parent d773715 commit 4c85462

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# VSCode
2+
*.vscode/*
0 Bytes
Binary file not shown.

examples/Example999_I2C_Testing/Example999_I2C_Testing.ino

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
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){
179179
void 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

185185
void 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

277277
uint16_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

examples/Example999_SPI_Testing/Example999_SPI_Testing.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define SPI_CLK 1000000
1010
SPISettings mySettings(SPI_CLK, MSBFIRST, SPI_MODE3);
1111

12-
ICM_20948_Status_e mywrite(uint8_t reg, uint8_t* data, uint32_t len);
13-
ICM_20948_Status_e myread(uint8_t reg, uint8_t* buff, uint32_t len);
12+
ICM_20948_Status_e mywrite(uint8_t reg, uint8_t* data, uint32_t len, void* user);
13+
ICM_20948_Status_e myread(uint8_t reg, uint8_t* buff, uint32_t len, void* user);
1414

1515

1616
ICM_20948_Device_t myICM;
@@ -89,7 +89,7 @@ void loop() {
8989
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;
9090
ICM_20948_INT_STATUS_1_t reg;
9191
retval = ICM_20948_set_bank( &myICM, 0); // Must be in the right bank
92-
retval = myread( AGB0_REG_INT_STATUS_1, (uint8_t*)&reg, sizeof(ICM_20948_INT_STATUS_1_t));
92+
retval = myread( AGB0_REG_INT_STATUS_1, (uint8_t*)&reg, sizeof(ICM_20948_INT_STATUS_1_t), NULL);
9393

9494
Serial.println(*((uint8_t*)&reg), BIN);
9595

@@ -104,7 +104,7 @@ void loop() {
104104

105105
}
106106

107-
ICM_20948_Status_e mywrite(uint8_t reg, uint8_t* data, uint32_t len){
107+
ICM_20948_Status_e mywrite(uint8_t reg, uint8_t* data, uint32_t len, void* user){
108108
digitalWrite(CS_PIN, LOW);
109109
delayMicroseconds(5);
110110
SPI.beginTransaction(mySettings);
@@ -120,7 +120,7 @@ ICM_20948_Status_e mywrite(uint8_t reg, uint8_t* data, uint32_t len){
120120
return ICM_20948_Stat_Ok;
121121
}
122122

123-
ICM_20948_Status_e myread(uint8_t reg, uint8_t* buff, uint32_t len){
123+
ICM_20948_Status_e myread(uint8_t reg, uint8_t* buff, uint32_t len, void* user){
124124
digitalWrite(CS_PIN, LOW);
125125
delayMicroseconds(5);
126126
SPI.beginTransaction(mySettings);

src/ICM_20948.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Forward Declarations
44
ICM_20948_Status_e ICM_20948_write_I2C(uint8_t reg, uint8_t* data, uint32_t len, void* user);
55
ICM_20948_Status_e ICM_20948_read_I2C(uint8_t reg, uint8_t* buff, uint32_t len, void* user);
6-
ICM_20948_Status_e ICM_20948_write_SPI(uint8_t reg, uint8_t* buff, uint32_t len, void* user)
6+
ICM_20948_Status_e ICM_20948_write_SPI(uint8_t reg, uint8_t* buff, uint32_t len, void* user);
77
ICM_20948_Status_e ICM_20948_read_SPI(uint8_t reg, uint8_t* buff, uint32_t len, void* user);
88

99

src/ICM_20948.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ICM_20948_SPI {
4747

4848
ICM_20948_Status_e begin();
4949

50-
read( )
50+
// read( )
5151
};
5252

5353

0 commit comments

Comments
 (0)