Skip to content

Commit

Permalink
Merge pull request #122 from sparkfun/release_candidate
Browse files Browse the repository at this point in the history
v1.2.12 - add WOMLogic
  • Loading branch information
PaulZC committed Jun 18, 2023
2 parents f0b90f4 + b249f13 commit 9a10c51
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ void setup()
SERIAL_PORT.print(F("Set threshold returned: "));
SERIAL_PORT.println(myICM.statusString());

myICM.WOMLogic(true, 1); // enable WoM Logic mode 1

myICM.intEnableWOM(true); // enable interrupts on WakeOnMotion
SERIAL_PORT.print(F("intEnableWOM returned: "));
SERIAL_PORT.println(myICM.statusString());
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ intEnableWOF KEYWORD2
intEnableRawDataReady KEYWORD2
intEnableOverflowFIFO KEYWORD2
intEnableWatermarkFIFO KEYWORD2
WOMLogic KEYWORD2
WOMThreshold KEYWORD2
i2cMasterPassthrough KEYWORD2
i2cMasterEnable KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library
version=1.2.11
version=1.2.12
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Use the low-power high-resolution ICM 20948 9 DoF IMU from Invensense with I2C or SPI. Version 1.2 of the library includes support for the InvenSense Digital Motion Processor (DMP™).
Expand Down
24 changes: 24 additions & 0 deletions src/ICM_20948.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,30 @@ ICM_20948_Status_e ICM_20948::intEnableWatermarkFIFO(uint8_t bm_enable)
return status;
}

ICM_20948_Status_e ICM_20948::WOMLogic(uint8_t enable, uint8_t mode)
{
ICM_20948_ACCEL_INTEL_CTRL_t ctrl; // storage
status = ICM_20948_wom_logic(&_device, NULL, &ctrl); // read phase
if (status != ICM_20948_Stat_Ok)
{
return status;
}
ctrl.ACCEL_INTEL_EN = enable; // enable the WOM logic
ctrl.ACCEL_INTEL_MODE_INT = mode; // config mode

status = ICM_20948_wom_logic(&_device, &ctrl, &ctrl); // write new config
if (status != ICM_20948_Stat_Ok)
{
return status;
}
if (ctrl.ACCEL_INTEL_MODE_INT != mode)
{
status = ICM_20948_Stat_Err;
return status;
}
return status;
}

ICM_20948_Status_e ICM_20948::WOMThreshold(uint8_t threshold)
{
ICM_20948_ACCEL_WOM_THR_t thr; // storage
Expand Down
1 change: 1 addition & 0 deletions src/ICM_20948.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class ICM_20948
ICM_20948_Status_e intEnableOverflowFIFO(uint8_t bm_enable);
ICM_20948_Status_e intEnableWatermarkFIFO(uint8_t bm_enable);

ICM_20948_Status_e WOMLogic(uint8_t enable, uint8_t mode);
ICM_20948_Status_e WOMThreshold(uint8_t threshold);

// Interface Options
Expand Down
35 changes: 35 additions & 0 deletions src/util/ICM_20948_C.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,41 @@ ICM_20948_Status_e ICM_20948_int_enable(ICM_20948_Device_t *pdev, ICM_20948_INT_
return retval;
}

ICM_20948_Status_e ICM_20948_wom_logic(ICM_20948_Device_t *pdev, ICM_20948_ACCEL_INTEL_CTRL_t *write, ICM_20948_ACCEL_INTEL_CTRL_t *read)
{
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;

ICM_20948_ACCEL_INTEL_CTRL_t ctrl;

retval = ICM_20948_set_bank(pdev, 2); // Must be in the right bank

if (write != NULL)
{ // If the write pointer is not NULL then write to the registers BEFORE reading
ctrl.ACCEL_INTEL_EN = write->ACCEL_INTEL_EN;
ctrl.ACCEL_INTEL_MODE_INT = write->ACCEL_INTEL_MODE_INT;

retval = ICM_20948_execute_w(pdev, AGB2_REG_ACCEL_INTEL_CTRL, (uint8_t *)&ctrl, sizeof(ICM_20948_ACCEL_INTEL_CTRL_t));
if (retval != ICM_20948_Stat_Ok)
{
return retval;
}
}

if (read != NULL)
{ // 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)
retval = ICM_20948_execute_r(pdev, AGB2_REG_ACCEL_INTEL_CTRL, (uint8_t *)&ctrl, sizeof(ICM_20948_ACCEL_INTEL_CTRL_t));
if (retval != ICM_20948_Stat_Ok)
{
return retval;
}

read->ACCEL_INTEL_EN = ctrl.ACCEL_INTEL_EN;
read->ACCEL_INTEL_MODE_INT = ctrl.ACCEL_INTEL_MODE_INT;
}

return retval;
}

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)
{
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;
Expand Down
3 changes: 3 additions & 0 deletions src/util/ICM_20948_C.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ extern int memcmp(const void *, const void *, size_t); // Avoid compiler warning
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
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

// WoM Enable Logic configuration
ICM_20948_Status_e ICM_20948_wom_logic(ICM_20948_Device_t *pdev, ICM_20948_ACCEL_INTEL_CTRL_t *write, ICM_20948_ACCEL_INTEL_CTRL_t *read); //Enable or disable WoM Logic

// WoM Threshold Level Configuration
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

Expand Down

0 comments on commit 9a10c51

Please sign in to comment.