20#define I2C_FREQ 400000UL
43 { 0, 0, 265.0f, 1125.0f,
"246 ; 265 ; 1125 " },
44 { 1, 0, 265.0f, 1125.0f,
"246 ; 265 ; 1125 " },
45 { 2, 1, 136.0f, 562.5f,
"111 ; 136 ; 562 " },
46 { 3, 2, 68.8f, 375.0f,
"50 ; 69 ; 375 " },
47 { 4, 7, 34.4f, 140.6f,
"24 ; 34 ; 141 " },
48 { 5, 15, 17.0f, 70.3f,
"12 ; 17 ; 70 " },
49 { 6, 29, 8.3f, 37.5f,
"6 ; 8 ; 35 " },
50 { 7, 0, 499.0f, 1125.0f,
"473 ; 499 ; 1125 " },
95 0, 1, 3, 5, 7, 10, 15, 22, 31, 63, 127, 255, 513, 1022, 2044, 4095
99 "1125.0",
"562.5",
"281.3",
"187.5",
"140.6",
"102.3",
"70.3",
100 "48.9",
"35.2",
"17.6",
"8.8",
"4.4",
"2.2",
"1.1",
"0.55",
"0.27"
115void printLinea() { Serial.println(F(
"------------------------------------------------------------")); }
117void printDobleLinea() { Serial.println(F(
"============================================================")); }
127 Serial.println(F(
"ERROR: WHO_AM_I mismatch"));
128 while (1) delay(200);
130 Serial.printf(
"WHO_AM_I = 0x%02X OK\n", who);
188 Serial.println(F(
" ICM-20948 | UNIT Electronics"));
189 Serial.println(F(
" MODO VERIFICACION — FS=+-2g fijo, 3 lecturas por config"));
190 Serial.println(F(
" Sensor PLANO y QUIETO | Az esperado: ~+1.000g"));
192 for(uint8_t i = 0; i <
N_AVG; i++){
193 for(uint8_t j = 0; j <
N_FS;j++){
194 for (uint8_t d = 0; d <
N_DLPF; d++) {
206 Serial.println(F(
" ERROR: applySettings() fallo"));
211 uint32_t settle_ms = max((uint32_t)(10000.0f /
configsDLPF[d].odr_hz),
216 uint32_t periodo_ms = max((uint32_t)(1000.0f /
configsDLPF[d].odr_hz),
219 for (uint8_t r = 0; r < 100; r++) {
223 Serial.printf(
"%d ; %s ; %s ; %s ; %+.4f ; %+.4f ; %+.4f\n",
230 Serial.println(F(
" [?] readAccel() fallo"));
238 Serial.println(F(
" VERIFICACION COMPLETA"));
239 Serial.println(F(
" Si Az ~ +1.0g en todos los bloques:"));
240 Serial.println(F(
" el sensor funciona correctamente."));
241 Serial.println(F(
" Activar sweep completo cuando este listo."));
252 Serial.begin(115200);
254 Serial.println(F(
"ICM-20948 — Verificacion"));
257 Serial.println(F(
" ICM-20948 VALIDACION ACELEROMETRO"));
263 Serial.println(F(
"ERROR: beginI2C() fallo"));
264 while (1) delay(200);
277 Serial.println(F(
"ERROR: setSensors() fallo"));
280 Serial.println(F(
" Sensor listo.\n"));
281 Serial.println(F(
" Sensor PLANO y QUIETO sobre la mesa."));
282 Serial.println(F(
" Iniciando en 5 segundos..."));
283 for (
int i = 5; i > 0; i--) {
284 Serial.printf(
" %d...\n", i);
bool setAccelScale(ICM20948_Accel_FullScale fullScale)
bool readAccel(float &x, float &y, float &z)
bool setAccelAveraging(ICM20948_Accel_Average avg)
bool readWhoAmI(uint8_t &whoAmI)
bool beginI2C(uint8_t address=0x69, TwoWire &i2cPort=Wire, uint32_t i2cSpeed=400000)
bool setAccelDLPF(uint8_t dlpf, bool bypass)
bool setAccelDivRate(uint16_t divisor)
bool setSensors(bool accel_on, bool gyro_on, bool temp_on)
void applySettings()
Initialize the magnetometer and collect samples for each mode.
Gyroscope DLPF divider and timing configuration.
float odr_hz
Output data rate in hertz for timing calculations.
uint8_t dlpf_idx
Index into the gyroDLPF lookup table.
const char * nombre
Text label printed with each captured sample.
uint16_t div
Sample-rate divider written to the IMU register.
float nbw_hz
Noise bandwidth in hertz for reporting.
#define SCL_PIN
I2C SCL pin used by the example board.
const uint8_t N_AVG
Number of accelerometer averaging settings.
const char * etiquetasAccelCfg[]
Text labels matching accelCfg.
const ICM20948_Accel_DLPFCFG accelDLPF[]
Accelerometer DLPF enum values matching configsDLPF.
uint8_t total_fail
Count of validation failures reserved for future checks.
void firstStage()
Verify the IMU identity register.
const char * etiquetasAccelAVG[]
Text labels matching accelAVG.
void printDobleLinea()
Print a double separator line to Serial.
const ICM20948_Accel_Average accelAVG[]
Accelerometer averaging settings exercised by the sweep.
void setup()
Initialize I2C, reset/wake the IMU, enable sensors, and start sweep.
#define SDA_PIN
I2C SDA pin used by the example board.
void runSweep()
Run the full accelerometer validation matrix and print samples.
const uint8_t N_FS
Number of accelerometer full-scale ranges.
const uint8_t N_DLPF
Number of accelerometer DLPF configurations.
void printLinea()
Print a separator line to Serial.
#define I2C_FREQ
I2C bus speed in hertz.
#define ICM_ADDR
ICM-20948 I2C address selected by the AD0 pin.
const configDLPF configsDLPF[]
Accelerometer DLPF configurations exercised by this sweep.
DevLab_ICM20948 imu
Global ICM-20948 driver instance.
const char * etiquetasSR[]
Text labels matching accelSR output data rates.
uint8_t total_pass
Count of validation passes reserved for future checks.
uint8_t total_warn
Count of validation warnings reserved for future checks.
const uint16_t accelSR[]
Raw accelerometer sample-rate divider values for experiments.
const ICM20948_Accel_FullScale accelCfg[]
Accelerometer full-scale ranges exercised by the sweep.
void loop()
Optional post-sweep loop for manual accelerometer reads.