/* * icm_datatypes.h * * Created on: 8. 1. 2023 * Author: juraj */ #ifndef ICM_DATATYPES_H_ #define ICM_DATATYPES_H_ #if defined(STM32F401xC) || defined(STM32F401xE) #include "stm32f4xx_hal.h" #endif #if defined (STM32L432xx) #include "stm32l4xx_hal.h" #endif typedef struct { uint8_t type; float x; float y; float z; } axises; typedef enum { _250dps, _500dps, _1000dps, _2000dps } gyro_full_scale; typedef enum { _2g, _4g, _8g, _16g } accel_full_scale; /** * @brief Acceleroemter settings: register ACCEL_CONFIG_1 (Bank 2). */ typedef enum { /** output rate = 4500Hz */ ACCEL_low_pass_OFF = 0, /** output rate = determined by @ref icm20948ACCEL_sample_rate_divider function, @ref accel_samplerate respectivelly */ ACCEL_lpf_246Hz = 0x9, ACCEL_lpf_114_4Hz = 0x11, ACCEL_lpf_050_4Hz = 0x19, ACCEL_lpf_023_9Hz = 0x21, ACCEL_lpf_011_5Hz = 0x29, ACCEL_lpf_005_7Hz = 0x31, ACCEL_lpf_473Hz = 0x39, } accel_dlp_cfg; typedef enum { ACCEL_samplerate_562_5Hz = 1, ACCEL_samplerate_281_3Hz = 3, ACCEL_samplerate_187_5Hz = 5, ACCEL_samplerate_140_6Hz = 7, ACCEL_samplerate_102_3Hz = 10, ACCEL_samplerate_70_3Hz = 15, ACCEL_samplerate_48_9Hz = 22, ACCEL_samplerate_35_2Hz = 31, ACCEL_samplerate_17_6Hz = 34, ACCEL_samplerate_8_8Hz = 127, ACCEL_samplerate_4_4Hz = 255, ACCEL_samplerate_2_2Hz = 513, ACCEL_samplerate_1_1Hz = 1022, ACCEL_samplerate_0_55Hz = 2044, ACCEL_samplerate_0_27Hz = 4095, } accel_samplerate; typedef enum { GYRO_samplerate_562_5Hz = 1, GYRO_samplerate_375_0Hz = 2, GYRO_samplerate_281_3Hz = 3, GYRO_samplerate_225_0Hz = 4, GYRO_samplerate_187_5Hz = 5, GYRO_samplerate_140_6Hz = 7, GYRO_samplerate_125_0Hz = 8, GYRO_samplerate_102_3Hz = 10, GYRO_samplerate_070_3Hz = 15, GYRO_samplerate_066_2Hz = 16, GYRO_samplerate_048_9Hz = 22, GYRO_samplerate_035_2Hz = 31, GYRO_samplerate_034_1Hz = 32, GYRO_samplerate_017_6Hz = 63, GYRO_samplerate_017_3Hz = 64, GYRO_samplerate_004_4Hz = 255, } gyro_samplerate; /** * @brief Gyroscope settings: register GYRO_CONFIG_1 (Bank 2). */ typedef enum { /** output rate = 9000Hz */ GYRO_low_pass_OFF = 0, /** output rate = determined by @ref icm20948_gyro_sample_rate_divider function, @ref accel_samplerate respectivelly */ GYRO_lpf_196_6Hz = 0x1, GYRO_lpf_151_8Hz = 0x09, GYRO_lpf_119_5Hz = 0x11, GYRO_lpf_051_2Hz = 0x19, GYRO_lpf_023_9Hz = 0x21, GYRO_lpf_011_6Hz = 0x29, GYRO_lpf_005_7Hz = 0x31, GYRO_lpf_361_4Hz = 0x39, } gyro_dlp_cfg; typedef enum { mag_mode_power_down = 0, mag_mode_single_measurement = 1, mag_mode_cont_measurement_010hz = 2, mag_mode_cont_measurement_020hz = 4, mag_mode_cont_measurement_050hz = 6, mag_mode_cont_measurement_100hz = 8 } AK09916_operation_mode; typedef enum { interrupt_disable = 0, /** Enable DMP interrupt to propagate to interrupt pin 1. */ interrupt_DMP_INT1_EN = 1 << 1, /** Enable PLL RDY interrupt (PLL RDY means PLL is running and in use as the clock source for the system) to propagate to interrupt pin 1. */ interrupt_PLL_RDY_EN = 1 << 2, /** Enable interrupt for wake on motion to propagate to interrupt pin 1. */ interrupt_WOM_INT_EN = 1 << 3, /** Enable wake on FSYNC interrupt. */ interrupt_REG_WOF_EN = 1 << 7, /** Enable raw data ready interrupt from any sensor to propagate to interrupt pin 1.*/ interrupt_RAW_DATA_0_RDY_EN = 1 << 8 }interrupt_source_enum; typedef struct { uint8_t I2C_MST_INT : 1; uint8_t DMP_INT1 : 1; uint8_t PLL_RDY_INT : 1; uint8_t WOM_INT : 1; uint8_t reserved_0 : 4; } ICM_INT_STATUS_t; typedef struct{ GPIO_TypeDef *port; uint16_t pin; }McuPin_typeDef; typedef struct { accel_dlp_cfg low_pass_filter = ACCEL_low_pass_OFF; accel_samplerate sample_rate = ACCEL_samplerate_562_5Hz; }Config_Accel_t; typedef struct { gyro_dlp_cfg low_pass_filter = GYRO_low_pass_OFF; gyro_samplerate sample_rate = GYRO_samplerate_375_0Hz; }Config_Gyro_t; typedef struct { AK09916_operation_mode mode = mag_mode_power_down; }Config_Mag_t; typedef struct { McuPin_typeDef *pinCS = NULL; McuPin_typeDef *pinINT = NULL; McuPin_typeDef *pinLED = NULL; Config_Accel_t accel; Config_Gyro_t gyro; Config_Mag_t mag; interrupt_source_enum int_source = interrupt_disable; }icm20948_Config; #endif /* ICM_DATATYPES_H_ */