How to use¶
Platform support¶
Framework:
Arduino
This library is made to be used with:
ESP32 family
Necessary inclusions¶
Only the header has to be included to you project
#include "libDM_icm42688.hpp"
Object creation¶
The library supports only SPI reading. The following example shows how to create the object:
Important
API ref: ICM42688_SPI
timerTool myTimer;
SDIO_CONF sdioConf(generalConf.sdioClock,
pinConf.pinSdioClk,
pinConf.pinSdioCmd,
pinConf.pinSdioDat0,
pinConf.pinSdioDat1,
pinConf.pinSdioDat2,
pinConf.pinSdioDat3,
generalConf.sdioMountpoint,
false);
streamLogger streamObj(&myTimer, sdioConf);
ICM42688_SPI icm(generalConf.icmSpiClock,
pinConf.pinSS,
&streamObj,
&myTimer,
&SPI,
ABSTRACT_SENSOR_SPI::SPI_CONF(),
true,
true);
Object configuration¶
The best way to use to the sensor is with the Fifo activated. The following example shows how to configure the sensor to use it:
Important
API ref: ICM42688_SPI::softResetSensor()
, ICM42688_SPI::setGyroOdrRange()
, ICM42688_SPI::setAccOdrRange()
, ICM42688_SPI::setGyroAccelFilter()
, ICM42688_SPI::flushFifo()
1 icm.softResetSensor();
2 icm.begin();
3 icm.setGyroOdrRange(ICM42688_ENUM::ODR::_1kHz, ICM42688_ENUM::GYRO_RANGE::_2000dps);
4 icm.setAccOdrRange(ICM42688_ENUM::ODR::_1kHz, ICM42688_ENUM::ACC_RANGE::_16g);
5 icm.setGyroAccelFilter(ICM42688_ENUM::FILTER_BW::ODR_DIV_4,
6 ICM42688_ENUM::FILTER_BW::ODR_DIV_4,
7 ICM42688_ENUM::FILTER_ORDER::_2nd_ORDER,
8 ICM42688_ENUM::FILTER_ORDER::_2nd_ORDER);
9 delay(100);
10 if (icm.checkImmobility(0.3F, 200U, 1U, 1000U))
11 icm.calibGyro(2000);
12 icm.flushFifo(true);
13 delay(100);
Get data¶
The following example shows how to get the data from the sensor:
Important
API ref: ICM42688_SPI::readFifo()
1 ABSTRACT_IMU::IMU_OUTPUT resIMU;
2
3 icm.readFifo();
4 resIMU = icm.getOutput();