### SPI Traffic: Load DMP Firmware (Part 1) Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transactions to set the memory start address and begin loading DMP firmware. This snippet shows writing to the Memory Start Address register. ```text 619098-619140 SPI: COPI data: 7C : Write Bank 0 Reg 0x7C Memory Start Address 619140-619182 SPI: COPI data: 90 : Memory Address 0x90 : Start of the DMP ``` -------------------------------- ### Set DMP Start Address Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Sets the program start address for the DMP by loading the 16-bit register AGB2_REG_PRGM_START_ADDRH (Bank 2, 0x50). ```c++ uint8_t setDMPstartAddress(){ // Before the DMP is enabled, the 16-bit register AGB2_REG_PRGM_START_ADDRH (Bank 2, 0x50) needs to be loaded with the program start address. // setDMPstartAddress does this for you. // Placeholder for actual address setting logic return ICM_20948_Stat_Ok; } ``` -------------------------------- ### SPI Traffic: Set DMP Memory Address for Bank 0x38 Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to set the memory start address to 0x00 within DMP memory bank 0x38. ```text 1416390-1416432 SPI: COPI data: 7C : Write Bank 0 Reg 0x7C Memory Start Address ``` -------------------------------- ### SPI Traffic: Set DMP Memory Address for Bank 0x01 Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to set the memory start address to 0x00 within the selected DMP memory bank. ```text 625464-625508 SPI: COPI data: 7C : Write Bank 0 Reg 0x7C Memory Start Address 625506-625550 SPI: COPI data: 00 : Memory Address 0x00 : DMP ``` -------------------------------- ### Initialize DMP Firmware and Configuration Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md This function handles the download of DMP firmware and configures all necessary registers. It's a weak function that can be overwritten to customize settings like sample rate. ```Arduino initializeDMP(); ``` -------------------------------- ### Initialize DMP Helper Function Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md The `initializeDMP` function simplifies the process of downloading DMP firmware and configuring registers. It is a weak function that can be overridden for custom sample rates. ```c++ uint8_t initializeDMP(){ //Download DMP firmware if(loadDMPFirmware() != ICM_20948_Stat_Ok){ return ICM_20948_Stat_Err; } //Set the correct program start address if(setDMPstartAddress() != ICM_20948_Stat_Ok){ return ICM_20948_Stat_Err; } //Enable the DMP if(enableDMP() != ICM_20948_Stat_Ok){ return ICM_20948_Stat_Err; } //Reset FIFO and DMP if(resetDMP() != ICM_20948_Stat_Ok){ return ICM_20948_Stat_Err; } return ICM_20948_Stat_Ok; } ``` -------------------------------- ### Enable DMP Support in ICM_20948_C.h Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md To enable DMP support, uncomment the `#define ICM_20948_USE_DMP` line in the `ICM_20948_C.h` configuration file. This is necessary because DMP support consumes significant program memory. ```c++ #define ICM_20948_USE_DMP ``` -------------------------------- ### ICM-20948 DMP Configuration Parameters Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Defines the configuration for the Game Rotation Vector (Quat6) output. This snippet shows how to enable/disable specific sensors and set their frequencies. ```c++ QuaternionAnimation (Quat6): .enable_gyroscope = false, // Enables gyroscope output .enable_accelerometer = false, // Enables accelerometer output .enable_magnetometer = false, // Enables magnetometer output .enable_quaternion = true, // Enables quaternion output .gyroscope_frequency = 1, // Max frequency = 225, min frequency = 1 .accelerometer_frequency = 1, // Max frequency = 225, min frequency = 1 .magnetometer_frequency = 1, // Max frequency = 70, min frequency = 1 .quaternion_frequency = 225 // Max frequency = 225, min frequency = 50 ``` -------------------------------- ### Supported DMP Features Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Lists the DMP features currently supported by the library, including various sensor data types and motion processing outputs. ```c++ INV_ICM20948_SENSOR_ACCELEROMETER (16-bit accel) INV_ICM20948_SENSOR_GYROSCOPE (16-bit gyro + 32-bit calibrated gyro) INV_ICM20948_SENSOR_RAW_ACCELEROMETER (16-bit accel) INV_ICM20948_SENSOR_RAW_GYROSCOPE (16-bit gyro + 32-bit calibrated gyro) INV_ICM20948_SENSOR_MAGNETIC_FIELD_UNCALIBRATED (16-bit compass) INV_ICM20948_SENSOR_GYROSCOPE_UNCALIBRATED (16-bit gyro) INV_ICM20948_SENSOR_STEP_DETECTOR (Pedometer Step Detector) INV_ICM20948_SENSOR_STEP_COUNTER (Pedometer Step Detector) INV_ICM20948_SENSOR_GAME_ROTATION_VECTOR (32-bit 6-axis quaternion) INV_ICM20948_SENSOR_ROTATION_VECTOR (32-bit 9-axis quaternion + heading accuracy) INV_ICM20948_SENSOR_GEOMAGNETIC_ROTATION_VECTOR (32-bit Geomag RV + heading accuracy) INV_ICM20948_SENSOR_GEOMAGNETIC_FIELD (32-bit calibrated compass) INV_ICM20948_SENSOR_GRAVITY (32-bit 6-axis quaternion) INV_ICM20948_SENSOR_LINEAR_ACCELERATION (16-bit accel + 32-bit 6-axis quaternion) INV_ICM20948_SENSOR_ORIENTATION (32-bit 9-axis quaternion + heading accuracy) ``` -------------------------------- ### Enable DMP Interrupts Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Functions to enable and configure DMP interrupts. Note that interrupt support may not be fully tested. ```Arduino intEnableDMP(); enableDMPSensorInt(); ``` -------------------------------- ### SPI Traffic: Load DMP Firmware (Part 2) Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transactions for loading DMP firmware, involving writing to the Memory Read/Write register with 16 bytes of data. ```text 619225-619269 SPI: COPI data: 7D : Write Bank 0 Reg 0x7D Memory Read/Write 619267-619311 SPI: COPI data: 00 : DMP firmware (16 bytes) 619310-619352 SPI: COPI data: 01 619352-619394 SPI: COPI data: 00 619394-619436 SPI: COPI data: 00 619436-619478 SPI: COPI data: 00 619478-619520 SPI: COPI data: 00 619520-619562 SPI: COPI data: 00 619562-619604 SPI: COPI data: 00 619604-619646 SPI: COPI data: 00 619646-619688 SPI: COPI data: 00 619688-619730 SPI: COPI data: 00 619730-619772 SPI: COPI data: 00 619772-619814 SPI: COPI data: 00 619814-619856 SPI: COPI data: 00 619856-619898 SPI: COPI data: 00 619898-619940 SPI: COPI data: 00 ``` -------------------------------- ### Load DMP Firmware Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Loads the DMP firmware into the ICM-20948's processor memory. This function handles breaking the firmware into blocks and writing to special Bank 0 registers. ```c++ uint8_t loadDMPFirmware(){ //The DMP firmware is loaded into the ICM-20948's processor memory space via three special Bank 0 registers: //AGB0_REG_MEM_START_ADDR (0x7C) - the address which AGB0_REG_MEM_R_W reads from or writes to (it auto-increments after each read or write) //AGB0_REG_MEM_R_W (0x7D) - the memory read/write register //AGB0_REG_MEM_BANK_SEL (0x7E) - the memory bank select. The complete read/write address is: (AGB0_REG_MEM_BANK_SEL * 256) + AGB0_REG_MEM_START_ADDR //The firmware binary (14290 or 14301 Bytes) is written into processor memory starting at address 0x90. //loadDMPFirmware automatically breaks the code up into 256 byte blocks and increments AGB0_REG_MEM_BANK_SEL during the writing. // Placeholder for actual firmware loading logic return ICM_20948_Stat_Ok; } ``` -------------------------------- ### SPI Traffic: Load DMP Firmware (Part 3) Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transactions for loading DMP firmware, involving writing to the Memory Read/Write register with specific data bytes. ```text 620116-620158 SPI: COPI data: 7D : Write Bank 0 Reg 0x7D Memory Read/Write 620158-620200 SPI: COPI data: 00 : DMP firmware (16 bytes) 620200-620242 SPI: COPI data: 05 620242-620284 SPI: COPI data: 00 620284-620326 SPI: COPI data: 00 620326-620370 SPI: COPI data: 00 620368-620412 SPI: COPI data: 05 620410-620454 SPI: COPI data: 00 620452-620496 SPI: COPI data: 00 620494-620538 SPI: COPI data: 00 620536-620580 SPI: COPI data: 05 620578-620622 SPI: COPI data: 00 620620-620664 SPI: COPI data: 01 620662-620706 SPI: COPI data: 00 620704-620748 SPI: COPI data: 05 620746-620790 SPI: COPI data: 00 620788-620832 SPI: COPI data: FF ``` -------------------------------- ### Set DMP Sample Rate Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Sets the sample rate for the DMP. This function is part of the DMP configuration and works in conjunction with other settings. ```Arduino setSampleRate(sampleRate); ``` -------------------------------- ### SPI Traffic: Load DMP Firmware (Part 4) Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transactions for loading DMP firmware, involving writing to the Memory Read/Write register with 16 bytes of data for bank 0x01. ```text 625592-625634 SPI: COPI data: 7D : Write Bank 0 Reg 0x7D Memory Read/Write 625634-625676 SPI: COPI data: 00 : DMP firmware (16 bytes) 625676-625718 SPI: COPI data: 00 625718-625760 SPI: COPI data: 03 625760-625802 SPI: COPI data: 84 625802-625844 SPI: COPI data: 00 625844-625886 SPI: COPI data: 00 625886-625928 SPI: COPI data: 9C 625928-625970 SPI: COPI data: 40 625970-626012 SPI: COPI data: 00 626012-626054 SPI: COPI data: 00 626054-626096 SPI: COPI data: 00 62096-626138 SPI: COPI data: 00 626138-626180 SPI: COPI data: 04 626180-626222 SPI: COPI data: 00 626222-626264 SPI: COPI data: 00 626264-626306 SPI: COPI data: 00 ``` -------------------------------- ### SPI Traffic: Configure LP_CONFIG Register Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to write to the LP_CONFIG register, enabling the I2C controller and setting the accelerometer and gyroscope to operate in duty cycled mode. ```text 618830-618872 SPI: COPI data: 05 : Write Bank 0 Reg 0x05 LP_CONFIG 618872-618914 SPI: COPI data: 70 : Operate I2C controller, accel and gyro in duty cycled mode ``` -------------------------------- ### Enable and Reset DMP Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Enables or resets the DMP by setting bits in the Bank 0 register AGB0_REG_USER_CTRL (0x03). ```c++ uint8_t enableDMP(){ // The DMP is enabled or reset by setting bits in the Bank 0 register AGB0_REG_USER_CTRL (0x03). // enableDMP and resetDMP do this for you. // Placeholder for actual enable logic return ICM_20948_Stat_Ok; } uint8_t resetDMP(){ // Placeholder for actual reset logic return ICM_20948_Stat_Ok; } ``` -------------------------------- ### SPI Traffic: Read USER_CTRL Register Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to read the USER_CTRL register. ```text 618291-618333 SPI: COPI data: 83 : Read Bank 0 Reg 0x03 USER_CTRL 618333-618375 SPI: CIPO data: 00 ``` -------------------------------- ### SPI Traffic: Configure PWR_MGMT_1 Register Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to write to the PWR_MGMT_1 register, setting the clock source to Auto (Best Available). ```text 617952-617994 SPI: COPI data: 06 : Write Bank 0 Reg 0x06 PWR_MGMT_1 617994-618036 SPI: COPI data: 01 : Clock Source Auto (Best Available) ``` -------------------------------- ### SPI Traffic: Select DMP Memory Bank 0x38 Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to select memory bank 0x38 for DMP operations. ```text 1416262-1416304 SPI: COPI data: 7E : Write Bank 0 Reg 0x7E Memory Bank Select 1416304-1416346 SPI: COPI data: 38 : Bank 0x38 ``` -------------------------------- ### Read and Write DMP Memory Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Provides functions to read and write data directly from the DMP memory space. ```c++ uint8_t readDMPmems(uint8_t startAddr, uint16_t len, uint8_t* buffer){ // Placeholder for actual read logic return ICM_20948_Stat_Ok; } uint8_t writeDMPmems(uint8_t startAddr, uint16_t len, uint8_t* buffer){ // Placeholder for actual write logic return ICM_20948_Stat_Ok; } ``` -------------------------------- ### SPI Traffic: Configure USER_CTRL for SPI Mode Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to write to the USER_CTRL register, disabling the I2C peripheral and setting the interface to SPI mode only. ```text 618426-618468 SPI: COPI data: 03 : Write Bank 0 Reg 0x03 USER_CTRL 618468-618510 SPI: COPI data: 10 : I2C_IF_DIS Reset I2C peripheral module and put the serial interface in SPI mode only ``` -------------------------------- ### SPI Traffic: Read WHO_AM_I Register Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Captures SPI traffic for reading the WHO_AM_I register to identify the ICM-20948 sensor. ```text 617669-617713 SPI: COPI data: 80 : Read Bank 0 Reg 0x00 WHO_AM_I 617711-617755 SPI: CIPO data: EA : ICM_20948 ``` -------------------------------- ### SPI Traffic: Configure PWR_MGMT_2 Register Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to write to the PWR_MGMT_2 register, disabling the pressure sensor and all gyroscope axes. ```text 618560-618602 SPI: COPI data: 07 : Write Bank 0 Reg 0x07 PWR_MGMT_2 618602-618644 SPI: COPI data: 47 : Disable pressure sensor. Disable all gyroscope axes ``` -------------------------------- ### Read DMP Data from FIFO Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Reads data from the FIFO buffer, checking for availability and copying it into an `icm_20948_DMP_data_t` struct. Returns status indicating data availability. ```c++ uint8_t readDMPdataFromFIFO(icm_20948_DMP_data_t &data){ // The DMP data is returned via the FIFO (First In First Out). // readDMPdataFromFIFO checks if any data is present in the FIFO (by calling getFIFOcount which reads the 16-bit register AGB0_REG_FIFO_COUNT_H (0x70)). // If data is present, it is copied into a icm_20948_DMP_data_t struct. // Placeholder for actual data reading logic return ICM_20948_Stat_Ok; } ``` -------------------------------- ### Disable DMP Support in ICM_20948_C.h Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md DMP support is disabled by default to conserve program memory. Ensure the `#define ICM_20948_USE_DMP` line is commented out if DMP functionality is not required. ```c++ //#define ICM_20948_USE_DMP ``` -------------------------------- ### SPI Traffic: Select DMP Memory Bank Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to select memory bank 0x01 for DMP operations. ```text 625336-625380 SPI: COPI data: 7E : Write Bank 0 Reg 0x7E Memory Bank Select 625378-625422 SPI: COPI data: 01 : Bank 0x01 ``` -------------------------------- ### DMP Header Bitmaps Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Defines bitmasks used to interpret the `data.header` field, indicating the type of data present in a DMP frame. Includes primary and secondary data indicators. ```c++ #define DMP_header_bitmap_Compass_Calibr 0x0020 #define DMP_header_bitmap_Gyro_Calibr 0x0040 #define DMP_header_bitmap_Geomag 0x0100 #define DMP_header_bitmap_PQuat6 0x0200 #define DMP_header_bitmap_Quat9 0x0400 #define DMP_header_bitmap_Quat6 0x0800 #define DMP_header_bitmap_ALS 0x1000 #define DMP_header_bitmap_Compass 0x2000 #define DMP_header_bitmap_Gyro 0x4000 #define DMP_header_bitmap_Accel 0x8000 #define DMP_header_bitmap_Header2 0x0008 #define DMP_header2_bitmap_Compass_Accuracy 0x1000 #define DMP_header2_bitmap_Gyro_Accuracy 0x2000 #define DMP_header2_bitmap_Accel_Accuracy 0x4000 ``` -------------------------------- ### Set DMP Output Data Rate (ODR) Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md Configures the DMP's Output Data Rate registers. This setting, along with the raw sensor rate, determines the final DMP data rate. ```Arduino setDMPODRrate(odr); ``` -------------------------------- ### SPI Traffic: Set DMP Memory Address Source: https://github.com/sparkfun/sparkfun_icm-20948_arduinolibrary/blob/main/DMP.md SPI transaction to set the memory address for DMP operations to 0xA0. ```text 619988-620032 SPI: COPI data: 7C : Write Bank 0 Reg 0x7C Memory Start Address 620030-620074 SPI: COPI data: A0 : Memory Address 0xA0 : DMP ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.