@@ -242,236 +242,290 @@ float ICM_20948::getGyrDPS(int16_t axis_val)
242
242
// Gyro Bias
243
243
ICM_20948_Status_e ICM_20948::setBiasGyroX ( int32_t newValue)
244
244
{
245
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
245
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
246
+ {
246
247
unsigned char gyro_bias_reg[4 ];
247
248
gyro_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
248
249
gyro_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
249
250
gyro_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
250
251
gyro_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
251
- result = inv_icm20948_write_mems (&_device, GYRO_BIAS_X, 4 , (const unsigned char *)&gyro_bias_reg);
252
- return result;
252
+ status = inv_icm20948_write_mems (&_device, GYRO_BIAS_X, 4 , (const unsigned char *)&gyro_bias_reg);
253
+ return status;
254
+ }
255
+ return ICM_20948_Stat_DMPNotSupported;
253
256
}
254
257
255
258
ICM_20948_Status_e ICM_20948::setBiasGyroY ( int32_t newValue)
256
259
{
257
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
260
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
261
+ {
258
262
unsigned char gyro_bias_reg[4 ];
259
263
gyro_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
260
264
gyro_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
261
265
gyro_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
262
266
gyro_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
263
- result = inv_icm20948_write_mems (&_device, GYRO_BIAS_Y, 4 , (const unsigned char *)&gyro_bias_reg);
264
- return result;
267
+ status = inv_icm20948_write_mems (&_device, GYRO_BIAS_Y, 4 , (const unsigned char *)&gyro_bias_reg);
268
+ return status;
269
+ }
270
+ return ICM_20948_Stat_DMPNotSupported;
265
271
}
266
272
267
273
ICM_20948_Status_e ICM_20948::setBiasGyroZ ( int32_t newValue)
268
274
{
269
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
275
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
276
+ {
270
277
unsigned char gyro_bias_reg[4 ];
271
278
gyro_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
272
279
gyro_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
273
280
gyro_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
274
281
gyro_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
275
- result = inv_icm20948_write_mems (&_device, GYRO_BIAS_Z, 4 , (const unsigned char *)&gyro_bias_reg);
276
- return result;
282
+ status = inv_icm20948_write_mems (&_device, GYRO_BIAS_Z, 4 , (const unsigned char *)&gyro_bias_reg);
283
+ return status;
284
+ }
285
+ return ICM_20948_Stat_DMPNotSupported;
277
286
}
278
287
279
288
ICM_20948_Status_e ICM_20948::getBiasGyroX ( int32_t * bias)
280
289
{
281
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
290
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
291
+ {
282
292
unsigned char bias_data[4 ] = { 0 };
283
- result = inv_icm20948_read_mems (&_device, GYRO_BIAS_X, 4 , bias_data);
293
+ status = inv_icm20948_read_mems (&_device, GYRO_BIAS_X, 4 , bias_data);
284
294
union {
285
295
int32_t signed32;
286
296
uint32_t unsigned32;
287
297
} signedUnsigned32;
288
298
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
289
299
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
290
- return result;
300
+ return status;
301
+ }
302
+ return ICM_20948_Stat_DMPNotSupported;
291
303
}
292
304
293
305
ICM_20948_Status_e ICM_20948::getBiasGyroY ( int32_t * bias)
294
306
{
295
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
307
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
308
+ {
296
309
unsigned char bias_data[4 ] = { 0 };
297
- result = inv_icm20948_read_mems (&_device, GYRO_BIAS_Y, 4 , bias_data);
310
+ status = inv_icm20948_read_mems (&_device, GYRO_BIAS_Y, 4 , bias_data);
298
311
union {
299
312
int32_t signed32;
300
313
uint32_t unsigned32;
301
314
} signedUnsigned32;
302
315
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
303
316
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
304
- return result;
317
+ return status;
318
+ }
319
+ return ICM_20948_Stat_DMPNotSupported;
305
320
}
306
321
307
322
ICM_20948_Status_e ICM_20948::getBiasGyroZ ( int32_t * bias)
308
323
{
309
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
324
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
325
+ {
310
326
unsigned char bias_data[4 ] = { 0 };
311
- result = inv_icm20948_read_mems (&_device, GYRO_BIAS_Z, 4 , bias_data);
327
+ status = inv_icm20948_read_mems (&_device, GYRO_BIAS_Z, 4 , bias_data);
312
328
union {
313
329
int32_t signed32;
314
330
uint32_t unsigned32;
315
331
} signedUnsigned32;
316
332
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
317
333
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
318
- return result;
334
+ return status;
335
+ }
336
+ return ICM_20948_Stat_DMPNotSupported;
319
337
}
320
338
// Accel Bias
321
339
ICM_20948_Status_e ICM_20948::setBiasAccelX ( int32_t newValue)
322
340
{
323
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
341
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
342
+ {
324
343
unsigned char accel_bias_reg[4 ];
325
344
accel_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
326
345
accel_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
327
346
accel_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
328
347
accel_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
329
- result = inv_icm20948_write_mems (&_device, ACCEL_BIAS_X, 4 , (const unsigned char *)&accel_bias_reg);
330
- return result;
348
+ status = inv_icm20948_write_mems (&_device, ACCEL_BIAS_X, 4 , (const unsigned char *)&accel_bias_reg);
349
+ return status;
350
+ }
351
+ return ICM_20948_Stat_DMPNotSupported;
331
352
}
332
353
333
354
ICM_20948_Status_e ICM_20948::setBiasAccelY ( int32_t newValue)
334
355
{
335
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
356
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
357
+ {
336
358
unsigned char accel_bias_reg[4 ];
337
359
accel_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
338
360
accel_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
339
361
accel_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
340
362
accel_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
341
- result = inv_icm20948_write_mems (&_device, ACCEL_BIAS_Y, 4 , (const unsigned char *)&accel_bias_reg);
342
- return result;
363
+ status = inv_icm20948_write_mems (&_device, ACCEL_BIAS_Y, 4 , (const unsigned char *)&accel_bias_reg);
364
+ return status;
365
+ }
366
+ return ICM_20948_Stat_DMPNotSupported;
343
367
}
344
368
345
369
ICM_20948_Status_e ICM_20948::setBiasAccelZ ( int32_t newValue)
346
370
{
347
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
371
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
372
+ {
348
373
unsigned char accel_bias_reg[4 ];
349
374
accel_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
350
375
accel_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
351
376
accel_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
352
377
accel_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
353
- result = inv_icm20948_write_mems (&_device, ACCEL_BIAS_Z, 4 , (const unsigned char *)&accel_bias_reg);
354
- return result;
378
+ status = inv_icm20948_write_mems (&_device, ACCEL_BIAS_Z, 4 , (const unsigned char *)&accel_bias_reg);
379
+ return status;
380
+ }
381
+ return ICM_20948_Stat_DMPNotSupported;
355
382
}
356
383
357
384
ICM_20948_Status_e ICM_20948::getBiasAccelX ( int32_t * bias)
358
385
{
359
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
386
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
387
+ {
360
388
unsigned char bias_data[4 ] = { 0 };
361
- result = inv_icm20948_read_mems (&_device, ACCEL_BIAS_X, 4 , bias_data);
389
+ status = inv_icm20948_read_mems (&_device, ACCEL_BIAS_X, 4 , bias_data);
362
390
union {
363
391
int32_t signed32;
364
392
uint32_t unsigned32;
365
393
} signedUnsigned32;
366
394
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
367
395
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
368
- return result;
396
+ return status;
397
+ }
398
+ return ICM_20948_Stat_DMPNotSupported;
369
399
}
370
400
371
401
ICM_20948_Status_e ICM_20948::getBiasAccelY ( int32_t * bias)
372
402
{
373
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
403
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
404
+ {
374
405
unsigned char bias_data[4 ] = { 0 };
375
- result = inv_icm20948_read_mems (&_device, ACCEL_BIAS_Y, 4 , bias_data);
406
+ status = inv_icm20948_read_mems (&_device, ACCEL_BIAS_Y, 4 , bias_data);
376
407
union {
377
408
int32_t signed32;
378
409
uint32_t unsigned32;
379
410
} signedUnsigned32;
380
411
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
381
412
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
382
- return result;
413
+ return status;
414
+ }
415
+ return ICM_20948_Stat_DMPNotSupported;
383
416
}
384
417
385
418
ICM_20948_Status_e ICM_20948::getBiasAccelZ ( int32_t * bias)
386
419
{
387
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
420
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
421
+ {
388
422
unsigned char bias_data[4 ] = { 0 };
389
- result = inv_icm20948_read_mems (&_device, ACCEL_BIAS_Z, 4 , bias_data);
423
+ status = inv_icm20948_read_mems (&_device, ACCEL_BIAS_Z, 4 , bias_data);
390
424
union {
391
425
int32_t signed32;
392
426
uint32_t unsigned32;
393
427
} signedUnsigned32;
394
428
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
395
429
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
396
- return result;
430
+ return status;
431
+ }
432
+ return ICM_20948_Stat_DMPNotSupported;
397
433
}
398
434
// CPass Bias
399
435
ICM_20948_Status_e ICM_20948::setBiasCPassX ( int32_t newValue)
400
436
{
401
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
437
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
438
+ {
402
439
unsigned char cpass_bias_reg[4 ];
403
440
cpass_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
404
441
cpass_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
405
442
cpass_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
406
443
cpass_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
407
- result = inv_icm20948_write_mems (&_device, CPASS_BIAS_X, 4 , (const unsigned char *)&cpass_bias_reg);
408
- return result;
444
+ status = inv_icm20948_write_mems (&_device, CPASS_BIAS_X, 4 , (const unsigned char *)&cpass_bias_reg);
445
+ return status;
446
+ }
447
+ return ICM_20948_Stat_DMPNotSupported;
409
448
}
410
449
411
450
ICM_20948_Status_e ICM_20948::setBiasCPassY ( int32_t newValue)
412
451
{
413
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
452
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
453
+ {
414
454
unsigned char cpass_bias_reg[4 ];
415
455
cpass_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
416
456
cpass_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
417
457
cpass_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
418
458
cpass_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
419
- result = inv_icm20948_write_mems (&_device, CPASS_BIAS_Y, 4 , (const unsigned char *)&cpass_bias_reg);
420
- return result;
459
+ status = inv_icm20948_write_mems (&_device, CPASS_BIAS_Y, 4 , (const unsigned char *)&cpass_bias_reg);
460
+ return status;
461
+ }
462
+ return ICM_20948_Stat_DMPNotSupported;
421
463
}
422
464
423
465
ICM_20948_Status_e ICM_20948::setBiasCPassZ ( int32_t newValue)
424
466
{
425
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
467
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
468
+ {
426
469
unsigned char cpass_bias_reg[4 ];
427
470
cpass_bias_reg[0 ] = (unsigned char )(newValue >> 24 );
428
471
cpass_bias_reg[1 ] = (unsigned char )(newValue >> 16 );
429
472
cpass_bias_reg[2 ] = (unsigned char )(newValue >> 8 );
430
473
cpass_bias_reg[3 ] = (unsigned char )(newValue & 0xff );
431
- result = inv_icm20948_write_mems (&_device, CPASS_BIAS_Z, 4 , (const unsigned char *)&cpass_bias_reg);
432
- return result;
474
+ status = inv_icm20948_write_mems (&_device, CPASS_BIAS_Z, 4 , (const unsigned char *)&cpass_bias_reg);
475
+ return status;
476
+ }
477
+ return ICM_20948_Stat_DMPNotSupported;
433
478
}
434
479
435
480
ICM_20948_Status_e ICM_20948::getBiasCPassX ( int32_t * bias)
436
481
{
437
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
482
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
483
+ {
438
484
unsigned char bias_data[4 ] = { 0 };
439
- result = inv_icm20948_read_mems (&_device, CPASS_BIAS_X, 4 , bias_data);
485
+ status = inv_icm20948_read_mems (&_device, CPASS_BIAS_X, 4 , bias_data);
440
486
union {
441
487
int32_t signed32;
442
488
uint32_t unsigned32;
443
489
} signedUnsigned32;
444
490
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
445
491
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
446
- return result;
492
+ return status;
493
+ }
494
+ return ICM_20948_Stat_DMPNotSupported;
447
495
}
448
496
449
497
ICM_20948_Status_e ICM_20948::getBiasCPassY ( int32_t * bias)
450
498
{
451
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
499
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
500
+ {
452
501
unsigned char bias_data[4 ] = { 0 };
453
- result = inv_icm20948_read_mems (&_device, CPASS_BIAS_Y, 4 , bias_data);
502
+ status = inv_icm20948_read_mems (&_device, CPASS_BIAS_Y, 4 , bias_data);
454
503
union {
455
504
int32_t signed32;
456
505
uint32_t unsigned32;
457
506
} signedUnsigned32;
458
507
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
459
508
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
460
- return result;
509
+ return status;
510
+ }
511
+ return ICM_20948_Stat_DMPNotSupported;
461
512
}
462
513
463
514
ICM_20948_Status_e ICM_20948::getBiasCPassZ ( int32_t * bias)
464
515
{
465
- ICM_20948_Status_e result = ICM_20948_Stat_Ok;
516
+ if (_device._dmp_firmware_available == true ) // Is DMP supported?
517
+ {
466
518
unsigned char bias_data[4 ] = { 0 };
467
- result = inv_icm20948_read_mems (&_device, CPASS_BIAS_Z, 4 , bias_data);
519
+ status = inv_icm20948_read_mems (&_device, CPASS_BIAS_Z, 4 , bias_data);
468
520
union {
469
521
int32_t signed32;
470
522
uint32_t unsigned32;
471
523
} signedUnsigned32;
472
524
signedUnsigned32.unsigned32 = (((uint32_t )bias_data[0 ]) << 24 ) | (((uint32_t )bias_data[1 ]) << 16 ) | (((uint32_t )bias_data[2 ]) << 8 ) | (bias_data[3 ]);
473
525
*bias = signedUnsigned32.signed32 ; // Convert from unsigned to signed with no cast ambiguity
474
- return result;
526
+ return status;
527
+ }
528
+ return ICM_20948_Stat_DMPNotSupported;
475
529
}
476
530
477
531
float ICM_20948::temp (void )
0 commit comments