ICM20948 IMU driver + SPP service implementation. More...
#include "spp/services/icm20948/icm20948.h"#include "spp/core/returnTypes.h"#include "spp/hal/spi/spi.h"#include "spp/hal/gpio/gpio.h"#include "spp/hal/time/time.h"#include "spp/core/types.h"#include "spp/services/log/log.h"#include "spp/services/databank/databank.h"#include "spp/services/service.h"#include "spp/core/pubsub/pubsub.h"#include "spp/services/fsm/fsm.h"#include <string.h>#include <math.h>#include "dmpImage.h"Go to the source code of this file.
Data Structures | |
| struct | ICM20948_DmpMatrixEntry_t |
Macros | |
| #define | K_READ_OP 0x80U |
| #define | K_WRITE_OP 0x00U |
| #define | K_ICM20948_BASE_SAMPLE_RATE 1125L |
| #define | K_ICM20948_DMP_RUNNING_RATE 225L |
| #define | K_ICM20948_DMP_DIVIDER (K_ICM20948_BASE_SAMPLE_RATE / K_ICM20948_DMP_RUNNING_RATE) |
| #define | K_ICM20948_WHO_AM_I_VALUE 0xEAU |
| #define | K_ICM20948_DMP_PACKET_SIZE_BYTES 42U |
| #define | K_ICM20948_FIFO_RESET_THRESHOLD 512U |
| #define | K_ICM20948_DMP_START_ADDR_MSB 0x10U |
| #define | K_ICM20948_DMP_START_ADDR_LSB 0x00U |
| #define | K_ICM20948_LOG_TAG "ICM" |
Functions | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_writeReg (void *p_spi, spp_uint8_t reg, spp_uint8_t value) |
| Writes a single byte to an ICM-20948 register over SPI. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_readReg (void *p_spi, spp_uint8_t reg, spp_uint8_t *p_value) |
| Reads a single byte from an ICM-20948 register over SPI. | |
| static SPP_RetVal_t | readFifoBurst (void *p_spi, spp_uint8_t *p_dst, spp_uint8_t count) |
Reads count bytes sequentially from the FIFO_R_W register. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_setBank (void *p_spi, ICM20948_RegBank_t regBank) |
| Selects the active register bank by writing REG_BANK_SEL. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_resetFifo (void *p_spi) |
| Resets all five FIFO streams by toggling the FIFO_RST bits. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_dmpWriteBytes (void *p_data, spp_uint16_t addr, const spp_uint8_t *p_bytes, spp_uint8_t len) |
Writes len bytes to DMP memory starting at address addr. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_dmpWrite32 (void *p_data, spp_uint16_t addr, spp_uint32_t value) |
Writes a 32-bit big-endian value to DMP memory at addr. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_dmpWrite16 (void *p_data, spp_uint16_t addr, spp_uint16_t value) |
Writes a 16-bit big-endian value to DMP memory at addr. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_lpWakeCycle (void *p_data) |
| Toggles PWR_MGMT_1 into low-power wake-cycle mode then back to normal. | |
| static spp_int32_t | SPP_SERVICES_ICM20948_calcGyroSf (spp_int8_t pll) |
| Computes the DMP gyroscope scale factor from the PLL trim value. | |
| static SPP_RetVal_t | ICM20948_dmpWriteOutputConfig (void *p_data, spp_uint16_t outCtl1, spp_uint16_t motionEvent) |
| Programs the DMP output control and motion event registers. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_loadDmp (void *p_data) |
| Loads the DMP3 firmware image into ICM-20948 SRAM. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_configDmpInit (void *p_data) |
| Executes the full DMP initialisation sequence. | |
| static void | SPP_SERVICES_ICM20948_checkFifoData (ICM20948_t *p_ctx) |
| Reads and parses DMP FIFO packets, updating the sensor data fields. | |
| static void | SPP_SERVICES_ICM20948_initGpio (ICM20948_Data_t *p_icm) |
| Initialises the ICM20948 interrupt context and registers the GPIO ISR. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_init (void) |
| Service init callback — sets hardware config, registers GPIO ISR, loads DMP firmware. | |
| static SPP_RetVal_t | SPP_SERVICES_ICM20948_acquireData (SPP_Kpid_t kpid) |
| Service acquire callback — reads FIFO data and publishes a packet. | |
| const SPP_SERVICE_ProducerContract_t * | SPP_SERVICES_ICM20948_getProducerContract (void) |
| Returns a pointer to the ICM20948 producer contract. | |
Variables | |
| static const spp_uint8_t | s_dmp3Image [] |
| static ICM20948_t | s_icmData |
| static const SPP_SERVICE_ProducerContract_t | s_icm20948ProducerContract |
ICM20948 IMU driver + SPP service implementation.
Implements SPI register access, DMP firmware loading and the full DMP initialisation sequence. Exposes a single public accessor (SPP_SERVICES_ICM20948_getProducerContract) so the device can be registered with the SPP service registry via SPP_SERVICES_PUBSUB_registerProducer().
Definition in file icm20948.c.
| #define K_READ_OP 0x80U |
SPI read flag — set MSB to signal a read transaction.
Definition at line 35 of file icm20948.c.
Referenced by readFifoBurst(), SPP_SERVICES_ICM20948_checkFifoData(), and SPP_SERVICES_ICM20948_readReg().
| #define K_WRITE_OP 0x00U |
SPI write marker (zero).
Definition at line 36 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_checkFifoData(), SPP_SERVICES_ICM20948_readReg(), and SPP_SERVICES_ICM20948_writeReg().
| #define K_ICM20948_BASE_SAMPLE_RATE 1125L |
Definition at line 38 of file icm20948.c.
| #define K_ICM20948_DMP_RUNNING_RATE 225L |
Definition at line 39 of file icm20948.c.
| #define K_ICM20948_DMP_DIVIDER (K_ICM20948_BASE_SAMPLE_RATE / K_ICM20948_DMP_RUNNING_RATE) |
Definition at line 40 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_calcGyroSf().
| #define K_ICM20948_WHO_AM_I_VALUE 0xEAU |
Definition at line 41 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_configDmpInit().
| #define K_ICM20948_DMP_PACKET_SIZE_BYTES 42U |
Definition at line 42 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_checkFifoData().
| #define K_ICM20948_FIFO_RESET_THRESHOLD 512U |
Definition at line 43 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_checkFifoData().
| #define K_ICM20948_DMP_START_ADDR_MSB 0x10U |
Definition at line 44 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_configDmpInit().
| #define K_ICM20948_DMP_START_ADDR_LSB 0x00U |
Definition at line 45 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_configDmpInit().
| #define K_ICM20948_LOG_TAG "ICM" |
Definition at line 46 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_acquireData(), SPP_SERVICES_ICM20948_checkFifoData(), SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_init().
|
static |
Writes a single byte to an ICM-20948 register over SPI.
| p_spi | SPI device handle. |
| reg | Register address. |
| value | Value to write. |
Definition at line 265 of file icm20948.c.
References K_WRITE_OP, SPP_HAL_SPI_transmit(), and SPP_SERVICES_ICM20948_writeReg().
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), SPP_SERVICES_ICM20948_dmpWriteBytes(), SPP_SERVICES_ICM20948_loadDmp(), SPP_SERVICES_ICM20948_lpWakeCycle(), SPP_SERVICES_ICM20948_resetFifo(), SPP_SERVICES_ICM20948_setBank(), and SPP_SERVICES_ICM20948_writeReg().
|
static |
Reads a single byte from an ICM-20948 register over SPI.
The HAL always issues a 3-byte SPI frame for reads (addr + 2 data bytes); ICM-20948 has no dummy byte so data lands at buf[1]. buf[2] absorbs the extra byte clocked out — must exist in the array to avoid a stack write.
| p_spi | SPI device handle. |
| reg | Register address. |
| p_value | Output: register value (may be NULL to discard). |
Definition at line 283 of file icm20948.c.
References K_READ_OP, K_WRITE_OP, SPP_HAL_SPI_transmit(), and SPP_SERVICES_ICM20948_readReg().
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), SPP_SERVICES_ICM20948_loadDmp(), and SPP_SERVICES_ICM20948_readReg().
|
static |
Reads count bytes sequentially from the FIFO_R_W register.
The HAL issues 3-byte read frames (address + 2 data bytes), yielding 2 FIFO bytes per frame. count must be even; K_ICM20948_DMP_PACKET_SIZE_BYTES satisfies this requirement.
| p_spi | SPI device handle. |
| p_dst | Destination buffer (must be at least count bytes). |
| count | Number of bytes to read (must be even). |
Definition at line 308 of file icm20948.c.
References K_ICM20948_REG_FIFO_R_W, K_READ_OP, K_SPP_OK, readFifoBurst(), and SPP_HAL_SPI_transmit().
Referenced by readFifoBurst(), and SPP_SERVICES_ICM20948_checkFifoData().
|
static |
Selects the active register bank by writing REG_BANK_SEL.
| p_spi | SPI device handle. |
| regBank | Target bank (K_ICM20948_REG_BANK_0 … _3). |
Definition at line 339 of file icm20948.c.
References ICM20948_RegBankSel_t::bits, K_ICM20948_REG_BANK_0, K_ICM20948_REG_BANK_1, K_ICM20948_REG_BANK_2, K_ICM20948_REG_BANK_3, K_ICM20948_REG_BANK_SEL, K_SPP_ERROR, SPP_SERVICES_ICM20948_setBank(), SPP_SERVICES_ICM20948_writeReg(), and ICM20948_RegBankSel_t::value.
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), SPP_SERVICES_ICM20948_loadDmp(), and SPP_SERVICES_ICM20948_setBank().
|
static |
Resets all five FIFO streams by toggling the FIFO_RST bits.
| p_spi | SPI device handle. |
Definition at line 369 of file icm20948.c.
References ICM20948_RegFifoRst_t::bits, K_ICM20948_REG_FIFO_RST, K_SPP_OK, SPP_SERVICES_ICM20948_resetFifo(), SPP_SERVICES_ICM20948_writeReg(), and ICM20948_RegFifoRst_t::value.
Referenced by SPP_SERVICES_ICM20948_checkFifoData(), SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_resetFifo().
|
static |
Writes len bytes to DMP memory starting at address addr.
| p_data | SPI device handle. |
| addr | DMP memory start address. |
| p_bytes | Pointer to byte array to write. |
| len | Number of bytes to write. |
Definition at line 399 of file icm20948.c.
References K_ICM20948_REG_MEM_BANK_SEL, K_ICM20948_REG_MEM_R_W, K_ICM20948_REG_MEM_START_ADDR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_SERVICES_ICM20948_dmpWriteBytes(), and SPP_SERVICES_ICM20948_writeReg().
Referenced by SPP_SERVICES_ICM20948_dmpWrite16(), SPP_SERVICES_ICM20948_dmpWrite32(), and SPP_SERVICES_ICM20948_dmpWriteBytes().
|
static |
Writes a 32-bit big-endian value to DMP memory at addr.
| p_data | SPI device handle. |
| addr | DMP memory address. |
| value | 32-bit value to write. |
Definition at line 441 of file icm20948.c.
References SPP_SERVICES_ICM20948_dmpWrite32(), and SPP_SERVICES_ICM20948_dmpWriteBytes().
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_dmpWrite32().
|
static |
Writes a 16-bit big-endian value to DMP memory at addr.
| p_data | SPI device handle. |
| addr | DMP memory address. |
| value | 16-bit value to write. |
Definition at line 456 of file icm20948.c.
References SPP_SERVICES_ICM20948_dmpWrite16(), and SPP_SERVICES_ICM20948_dmpWriteBytes().
Referenced by ICM20948_dmpWriteOutputConfig(), SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_dmpWrite16().
|
static |
Toggles PWR_MGMT_1 into low-power wake-cycle mode then back to normal.
| p_data | SPI device handle. |
Definition at line 468 of file icm20948.c.
References ICM20948_RegPwrMgmt1_t::bits, K_ICM20948_CLK_AUTO, K_ICM20948_REG_PWR_MGMT_1, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_SERVICES_ICM20948_lpWakeCycle(), SPP_SERVICES_ICM20948_writeReg(), and ICM20948_RegPwrMgmt1_t::value.
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_lpWakeCycle().
|
static |
Computes the DMP gyroscope scale factor from the PLL trim value.
| pll | PLL timebase correction value read from bank 1. |
Definition at line 499 of file icm20948.c.
References K_ICM20948_DMP_DIVIDER, and SPP_SERVICES_ICM20948_calcGyroSf().
Referenced by SPP_SERVICES_ICM20948_calcGyroSf(), and SPP_SERVICES_ICM20948_configDmpInit().
|
static |
Programs the DMP output control and motion event registers.
| p_data | SPI device handle. |
| outCtl1 | DATA_OUT_CTL1 bitmask (selects sensor outputs). |
| motionEvent | MOTION_EVENT_CTL bitmask. |
Definition at line 520 of file icm20948.c.
References ICM20948_dmpWriteOutputConfig(), K_ICM20948_DMP_DATA_INTR_CTL, K_ICM20948_DMP_DATA_OUT_CTL1, K_ICM20948_DMP_DATA_OUT_CTL2, K_ICM20948_DMP_MOTION_EVENT_CTL, K_SPP_OK, and SPP_SERVICES_ICM20948_dmpWrite16().
Referenced by ICM20948_dmpWriteOutputConfig(), and SPP_SERVICES_ICM20948_configDmpInit().
|
static |
Loads the DMP3 firmware image into ICM-20948 SRAM.
Writes s_dmp3Image byte-by-byte starting at K_ICM20948_DMP_LOAD_START, then primes the SRAM read path with a dummy read transaction.
| p_data | SPI device handle. |
Definition at line 564 of file icm20948.c.
References K_ICM20948_DMP_LOAD_START, K_ICM20948_REG_BANK_0, K_ICM20948_REG_MEM_BANK_SEL, K_ICM20948_REG_MEM_R_W, K_ICM20948_REG_MEM_START_ADDR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_dmp3Image, SPP_SERVICES_ICM20948_loadDmp(), SPP_SERVICES_ICM20948_readReg(), SPP_SERVICES_ICM20948_setBank(), and SPP_SERVICES_ICM20948_writeReg().
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_loadDmp().
|
static |
Executes the full DMP initialisation sequence.
Resets the device, loads DMP firmware, configures gyroscope/accelerometer full-scale ranges, compass mount matrix, sample-rate dividers and output data rates, then starts the magnetometer and enables the DMP FIFO.
| p_data | SPI device handle. |
Definition at line 645 of file icm20948.c.
References ICM20948_RegAccelConfig_t::bits, ICM20948_RegGyroConfig_t::bits, ICM20948_RegIntEnable2_t::bits, ICM20948_RegIntEnable_t::bits, ICM20948_RegLpConf_t::bits, ICM20948_RegPwrMgmt1_t::bits, ICM20948_RegPwrMgmt2_t::bits, ICM20948_RegUserCtrl_t::bits, ICM20948_dmpWriteOutputConfig(), K_ICM20948_ACCEL_FS_4G, K_ICM20948_CLK_AUTO, K_ICM20948_DMP_ACC_SCALE, K_ICM20948_DMP_ACC_SCALE2, K_ICM20948_DMP_ACCEL_A_VAR, K_ICM20948_DMP_ACCEL_ALPHA_VAR, K_ICM20948_DMP_ACCEL_CAL_INIT, K_ICM20948_DMP_ACCEL_ONLY_GAIN, K_ICM20948_DMP_B2S_MTX_00, K_ICM20948_DMP_B2S_MTX_01, K_ICM20948_DMP_B2S_MTX_02, K_ICM20948_DMP_B2S_MTX_10, K_ICM20948_DMP_B2S_MTX_11, K_ICM20948_DMP_B2S_MTX_12, K_ICM20948_DMP_B2S_MTX_20, K_ICM20948_DMP_B2S_MTX_21, K_ICM20948_DMP_B2S_MTX_22, K_ICM20948_DMP_B2S_RATE, K_ICM20948_DMP_BAC_RATE, K_ICM20948_DMP_CPASS_MTX_00, K_ICM20948_DMP_CPASS_MTX_01, K_ICM20948_DMP_CPASS_MTX_02, K_ICM20948_DMP_CPASS_MTX_10, K_ICM20948_DMP_CPASS_MTX_11, K_ICM20948_DMP_CPASS_MTX_12, K_ICM20948_DMP_CPASS_MTX_20, K_ICM20948_DMP_CPASS_MTX_21, K_ICM20948_DMP_CPASS_MTX_22, K_ICM20948_DMP_CPASS_TIME_BUFFER, K_ICM20948_DMP_DATA_RDY_STATUS, K_ICM20948_DMP_FIFO_WATERMARK, K_ICM20948_DMP_GYRO_FULLSCALE, K_ICM20948_DMP_GYRO_SF, K_ICM20948_DMP_ODR_ACCEL, K_ICM20948_DMP_ODR_CPASS, K_ICM20948_DMP_ODR_GYRO, K_ICM20948_DMP_ODR_QUAT6, K_ICM20948_DMP_ODR_QUAT9, K_ICM20948_DMP_START_ADDR_LSB, K_ICM20948_DMP_START_ADDR_MSB, K_ICM20948_GYRO_FS_2000DPS, K_ICM20948_I2C_MST_ODR_CONFIG, K_ICM20948_I2C_SLV1_ADDR, K_ICM20948_I2C_SLV1_CTRL, K_ICM20948_I2C_SLV1_DO, K_ICM20948_I2C_SLV1_REG, K_ICM20948_LOG_TAG, K_ICM20948_MAG_CTRL_2, K_ICM20948_MAG_RD_ADDR, K_ICM20948_MAG_WR_ADDR, K_ICM20948_REG_ACCEL_CONFIG, K_ICM20948_REG_ACCEL_CONFIG_2, K_ICM20948_REG_ACCEL_SMPLRT_DIV_1, K_ICM20948_REG_ACCEL_SMPLRT_DIV_2, K_ICM20948_REG_BANK_0, K_ICM20948_REG_BANK_1, K_ICM20948_REG_BANK_2, K_ICM20948_REG_BANK_3, K_ICM20948_REG_DMP_ADDR_LSB, K_ICM20948_REG_DMP_ADDR_MSB, K_ICM20948_REG_FIFO_CFG, K_ICM20948_REG_FIFO_EN_1, K_ICM20948_REG_FIFO_EN_2, K_ICM20948_REG_GYRO_CONFIG, K_ICM20948_REG_GYRO_SMPLRT_DIV, K_ICM20948_REG_HW_FIX_DISABLE, K_ICM20948_REG_I2C_CTRL, K_ICM20948_REG_INT_ENABLE, K_ICM20948_REG_INT_ENABLE_2, K_ICM20948_REG_LP_CONF, K_ICM20948_REG_PWR_MGMT_1, K_ICM20948_REG_PWR_MGMT_2, K_ICM20948_REG_SINGLE_FIFO_PRIORITY_SEL, K_ICM20948_REG_SLV0_ADDR, K_ICM20948_REG_SLV0_CTRL, K_ICM20948_REG_SLV0_REG, K_ICM20948_REG_TIMEBASE_CORRECTION_PLL, K_ICM20948_REG_USER_CTRL, K_ICM20948_REG_WHO_AM_I, K_ICM20948_WHO_AM_I_VALUE, K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_HAL_TIME_delayMs(), SPP_LOGE, SPP_LOGI, SPP_SERVICES_ICM20948_calcGyroSf(), SPP_SERVICES_ICM20948_configDmpInit(), SPP_SERVICES_ICM20948_dmpWrite16(), SPP_SERVICES_ICM20948_dmpWrite32(), SPP_SERVICES_ICM20948_loadDmp(), SPP_SERVICES_ICM20948_lpWakeCycle(), SPP_SERVICES_ICM20948_readReg(), SPP_SERVICES_ICM20948_resetFifo(), SPP_SERVICES_ICM20948_setBank(), SPP_SERVICES_ICM20948_writeReg(), ICM20948_RegAccelConfig2_t::value, ICM20948_RegAccelConfig_t::value, ICM20948_RegFifoCfg_t::value, ICM20948_RegFifoEn1_t::value, ICM20948_RegFifoEn2_t::value, ICM20948_RegGyroConfig_t::value, ICM20948_RegHwFixDisable_t::value, ICM20948_RegIntEnable2_t::value, ICM20948_RegIntEnable_t::value, ICM20948_RegLpConf_t::value, ICM20948_RegPwrMgmt1_t::value, ICM20948_RegPwrMgmt2_t::value, ICM20948_RegSingleFifoPrioritySel_t::value, and ICM20948_RegUserCtrl_t::value.
Referenced by SPP_SERVICES_ICM20948_configDmpInit(), and SPP_SERVICES_ICM20948_init().
|
static |
Reads and parses DMP FIFO packets, updating the sensor data fields.
Checks INT_STATUS for a raw-data-ready flag, reads the FIFO count, and processes each complete DMP packet. Resets the FIFO if the count exceeds K_ICM20948_FIFO_RESET_THRESHOLD.
| p_ctx | Pointer to the ICM20948 driver context. |
Definition at line 1632 of file icm20948.c.
References ICM20948_SensorData_t::accuracy, ICM20948_SensorData_t::ax, ICM20948_SensorData_t::ay, ICM20948_SensorData_t::az, ICM20948_SensorData_t::dataReady, ICM20948_SensorData_t::gx, ICM20948_SensorData_t::gy, ICM20948_SensorData_t::gz, K_ICM20948_DMP_PACKET_SIZE_BYTES, K_ICM20948_FIFO_RESET_THRESHOLD, K_ICM20948_LOG_TAG, K_ICM20948_REG_DMP_INT_STATUS, K_ICM20948_REG_FIFO_COUNTH, K_ICM20948_REG_INT_STATUS, K_READ_OP, K_SPP_OK, K_WRITE_OP, ICM20948_t::lastData, ICM20948_SensorData_t::mx, ICM20948_SensorData_t::my, ICM20948_SensorData_t::mz, ICM20948_t::p_spi, ICM20948_SensorData_t::qw, ICM20948_SensorData_t::qx, ICM20948_SensorData_t::qy, ICM20948_SensorData_t::qz, readFifoBurst(), SPP_HAL_SPI_transmit(), SPP_LOGI, SPP_SERVICES_ICM20948_checkFifoData(), and SPP_SERVICES_ICM20948_resetFifo().
Referenced by SPP_SERVICES_ICM20948_acquireData(), and SPP_SERVICES_ICM20948_checkFifoData().
|
static |
Initialises the ICM20948 interrupt context and registers the GPIO ISR.
| p_icm | Pointer to the ICM20948 interrupt context to initialise. |
Definition at line 123 of file icm20948.c.
References ICM20948_Data_t::drdyFlag, ICM20948_Data_t::intIntrType, ICM20948_Data_t::intPin, ICM20948_Data_t::intPull, ICM20948_Data_t::isr_ctx, SPP_GpioIsrCtx_t::p_flag, SPP_HAL_GPIO_configInterrupt(), SPP_HAL_GPIO_registerIsr(), and SPP_SERVICES_ICM20948_initGpio().
Referenced by SPP_SERVICES_ICM20948_init(), and SPP_SERVICES_ICM20948_initGpio().
|
static |
Service init callback — sets hardware config, registers GPIO ISR, loads DMP firmware.
Definition at line 135 of file icm20948.c.
References ICM20948_t::icmData, ICM20948_Data_t::intIntrType, ICM20948_t::intIntrType, ICM20948_Data_t::intPin, ICM20948_t::intPin, ICM20948_Data_t::intPull, ICM20948_t::intPull, K_ICM20948_INT_INTR_TYPE, K_ICM20948_INT_PIN_NUM, K_ICM20948_INT_PULL, K_ICM20948_LOG_TAG, K_ICM20948_SPI_HOST_USED, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, ICM20948_t::p_spi, s_icmData, ICM20948_t::seq, ICM20948_t::spiDevIdx, SPP_CORE_FSM_getErrorsBit(), SPP_HAL_SPI_deviceInit(), SPP_HAL_SPI_getHandle(), SPP_LOGE, SPP_LOGI, SPP_SERVICES_ICM20948_configDmpInit(), SPP_SERVICES_ICM20948_init(), and SPP_SERVICES_ICM20948_initGpio().
Referenced by SPP_SERVICES_ICM20948_init().
|
static |
Service acquire callback — reads FIFO data and publishes a packet.
Called by the service framework on each cycle. Checks the DRDY flag, reads the DMP FIFO, packs 9-axis sensor data into an SPP packet and publishes it.
Definition at line 177 of file icm20948.c.
References ICM20948_SensorData_t::accuracy, ICM20948_SensorData_t::ax, ICM20948_SensorData_t::ay, ICM20948_SensorData_t::az, ICM20948_SensorData_t::dataReady, ICM20948_Data_t::drdyFlag, ICM20948_SensorData_t::gx, ICM20948_SensorData_t::gy, ICM20948_SensorData_t::gz, ICM20948_t::icmData, K_ICM20948_LOG_TAG, K_SPP_ERROR, K_SPP_OK, ICM20948_t::lastData, ICM20948_SensorData_t::mx, ICM20948_SensorData_t::my, ICM20948_SensorData_t::mz, ICM20948_SensorData_t::qw, ICM20948_SensorData_t::qx, ICM20948_SensorData_t::qy, ICM20948_SensorData_t::qz, s_icmData, ICM20948_t::seq, SPP_LOGE, SPP_LOGI, SPP_Packet_t, SPP_SERVICES_DATABANK_getPacket(), SPP_SERVICES_DATABANK_packetData(), SPP_SERVICES_DATABANK_returnPacket(), SPP_SERVICES_ICM20948_acquireData(), SPP_SERVICES_ICM20948_checkFifoData(), SPP_SERVICES_PUBSUB_publish(), and SPP_Kpid_t::value.
Referenced by SPP_SERVICES_ICM20948_acquireData().
| const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_ICM20948_getProducerContract | ( | void | ) |
Returns a pointer to the ICM20948 producer contract.
Definition at line 106 of file icm20948.c.
References s_icm20948ProducerContract, and SPP_SERVICES_ICM20948_getProducerContract().
Referenced by SPP_SERVICES_ICM20948_getProducerContract().
|
static |
Definition at line 85 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_loadDmp().
|
static |
Definition at line 89 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_acquireData(), and SPP_SERVICES_ICM20948_init().
|
static |
Definition at line 91 of file icm20948.c.
Referenced by SPP_SERVICES_ICM20948_getProducerContract().