Skip to content

Commit b42341b

Browse files
authored
Add files via upload
Wake On Motion threshold function added
1 parent 80f37f7 commit b42341b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/util/ICM_20948_C.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,45 @@ ICM_20948_Status_e ICM_20948_int_enable(ICM_20948_Device_t *pdev, ICM_20948_INT_
425425
return retval;
426426
}
427427

428+
429+
430+
431+
432+
433+
434+
ICM_20948_Status_e ICM_20948_wom_threshold(ICM_20948_Device_t *pdev, ICM_20948_ACCEL_WOM_THR_t *write, ICM_20948_ACCEL_WOM_THR_t *read)
435+
{
436+
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;
437+
438+
ICM_20948_ACCEL_WOM_THR_t thr;
439+
440+
retval = ICM_20948_set_bank(pdev, 2); // Must be in the right bank
441+
442+
if (write != NULL)
443+
{ // If the write pointer is not NULL then write to the registers BEFORE reading
444+
thr.WOM_THRESHOLD = write->WOM_THRESHOLD;
445+
446+
retval = ICM_20948_execute_w(pdev, AGB2_REG_ACCEL_WOM_THR, (uint8_t *)&thr, sizeof(ICM_20948_ACCEL_WOM_THR_t));
447+
if (retval != ICM_20948_Stat_Ok)
448+
{
449+
return retval;
450+
}
451+
}
452+
453+
if (read != NULL)
454+
{ // If read pointer is not NULL then read the registers (if write is not NULL then this should read back the results of write into read)
455+
retval = ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_WOM_THR, (uint8_t *)&thr, sizeof(ICM_20948_ACCEL_WOM_THR_t));
456+
if (retval != ICM_20948_Stat_Ok)
457+
{
458+
return retval;
459+
}
460+
461+
read->WOM_THRESHOLD = thr.WOM_THRESHOLD;
462+
}
463+
464+
return retval;
465+
}
466+
428467
ICM_20948_Status_e ICM_20948_set_sample_mode(ICM_20948_Device_t *pdev, ICM_20948_InternalSensorID_bm sensors, ICM_20948_LP_CONFIG_CYCLE_e mode)
429468
{
430469
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;

src/util/ICM_20948_C.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ callbacks for the user to respond to interrupt events
192192
ICM_20948_Status_e ICM_20948_int_pin_cfg(ICM_20948_Device_t *pdev, ICM_20948_INT_PIN_CFG_t *write, ICM_20948_INT_PIN_CFG_t *read); // Set the INT pin configuration
193193
ICM_20948_Status_e ICM_20948_int_enable(ICM_20948_Device_t *pdev, ICM_20948_INT_enable_t *write, ICM_20948_INT_enable_t *read); // Write and or read the interrupt enable information. If non-null the write operation occurs before the read, so as to verify that the write was successful
194194

195+
// WoM Threshold Level Configuration
196+
ICM_20948_Status_e ICM_20948_wom_threshold(ICM_20948_Device_t *pdev, ICM_20948_ACCEL_WOM_THR_t *write, ICM_20948_ACCEL_WOM_THR_t *read); // Write and or read the Wake on Motion threshold. If non-null the write operation occurs before the read, so as to verify that the write was successful
197+
195198
// Internal Sensor Options
196199
ICM_20948_Status_e ICM_20948_set_sample_mode(ICM_20948_Device_t *pdev, ICM_20948_InternalSensorID_bm sensors, ICM_20948_LP_CONFIG_CYCLE_e mode); // Use to set accel, gyro, and I2C master into cycled or continuous modes
197200
ICM_20948_Status_e ICM_20948_set_full_scale(ICM_20948_Device_t *pdev, ICM_20948_InternalSensorID_bm sensors, ICM_20948_fss_t fss);

0 commit comments

Comments
 (0)