Integrate asynchronous GPS IMU fusion
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#ifndef ST_LSM6DSOX_H
|
||||
#define ST_LSM6DSOX_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "imu/imu_sample.h"
|
||||
|
||||
#ifndef ST_IMU_RAW_QUEUE_CAPACITY
|
||||
#define ST_IMU_RAW_QUEUE_CAPACITY 256u
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t odr_hz;
|
||||
unsigned int accel_full_scale_g;
|
||||
unsigned int gyro_full_scale_dps;
|
||||
} st_lsm6dsox_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t timestamp_ticks;
|
||||
int16_t temperature_raw;
|
||||
int16_t accel_raw[3];
|
||||
int16_t gyro_raw[3];
|
||||
uint32_t sequence;
|
||||
} st_lsm6dsox_raw_sample_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t irq_count;
|
||||
uint64_t sample_count;
|
||||
uint64_t invalid_sample_count;
|
||||
uint64_t spurious_irq_count;
|
||||
uint64_t queue_overflow_count;
|
||||
uint64_t estimated_missed_sample_count;
|
||||
uint64_t last_timestamp_ticks;
|
||||
uint8_t who_am_i;
|
||||
bool initialized;
|
||||
bool running;
|
||||
} st_lsm6dsox_diagnostics_t;
|
||||
|
||||
void st_lsm6dsox_default_config(st_lsm6dsox_config_t* config);
|
||||
bool st_lsm6dsox_init(const st_lsm6dsox_config_t* config);
|
||||
bool st_lsm6dsox_start(void);
|
||||
void st_lsm6dsox_stop(void);
|
||||
/* Called only by the common PLIC ISR for BSP_PMOD_IRQ. */
|
||||
void st_lsm6dsox_irq_handler(void);
|
||||
/* Retained as a no-op so every backend has the same service interface. */
|
||||
void st_lsm6dsox_service(void);
|
||||
bool st_lsm6dsox_take_measurement(
|
||||
imu_sample_t* measurement_out);
|
||||
void st_lsm6dsox_get_diagnostics(
|
||||
st_lsm6dsox_diagnostics_t* diagnostics_out);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
#ifndef TDK_ICM42688_H
|
||||
#define TDK_ICM42688_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "imu/imu_sample.h"
|
||||
|
||||
#ifndef TDK_IMU_RAW_QUEUE_CAPACITY
|
||||
#define TDK_IMU_RAW_QUEUE_CAPACITY 256u
|
||||
#endif
|
||||
|
||||
#ifndef TDK_IMU_ODR_HZ
|
||||
#define TDK_IMU_ODR_HZ 500u
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TDK_ACCEL_FS_2G = 2,
|
||||
TDK_ACCEL_FS_4G = 4,
|
||||
TDK_ACCEL_FS_8G = 8,
|
||||
TDK_ACCEL_FS_16G = 16
|
||||
} tdk_accel_full_scale_t;
|
||||
|
||||
typedef enum {
|
||||
TDK_GYRO_FS_15D625 = 15625,
|
||||
TDK_GYRO_FS_31D25 = 31250,
|
||||
TDK_GYRO_FS_62D5 = 62500,
|
||||
TDK_GYRO_FS_125 = 125000,
|
||||
TDK_GYRO_FS_250 = 250000,
|
||||
TDK_GYRO_FS_500 = 500000,
|
||||
TDK_GYRO_FS_1000 = 1000000,
|
||||
TDK_GYRO_FS_2000 = 2000000
|
||||
} tdk_gyro_full_scale_mdps_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t odr_hz;
|
||||
tdk_accel_full_scale_t accel_full_scale_g;
|
||||
tdk_gyro_full_scale_mdps_t gyro_full_scale_mdps;
|
||||
uint8_t ui_filter_config;
|
||||
} tdk_icm42688_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t timestamp_ticks;
|
||||
int16_t temperature_raw;
|
||||
int16_t accel_raw[3];
|
||||
int16_t gyro_raw[3];
|
||||
uint32_t sequence;
|
||||
} tdk_icm42688_raw_sample_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t irq_count;
|
||||
uint64_t sample_count;
|
||||
uint64_t invalid_sample_count;
|
||||
uint64_t spurious_irq_count;
|
||||
uint64_t queue_overflow_count;
|
||||
uint64_t estimated_missed_sample_count;
|
||||
uint64_t last_timestamp_ticks;
|
||||
uint8_t who_am_i;
|
||||
bool initialized;
|
||||
bool running;
|
||||
} tdk_icm42688_diagnostics_t;
|
||||
|
||||
void tdk_icm42688_default_config(tdk_icm42688_config_t* config);
|
||||
bool tdk_icm42688_init(const tdk_icm42688_config_t* config);
|
||||
bool tdk_icm42688_start(void);
|
||||
void tdk_icm42688_stop(void);
|
||||
|
||||
/* Called only by the common PLIC ISR for BSP_PMOD_IRQ. */
|
||||
void tdk_icm42688_irq_handler(void);
|
||||
|
||||
/* Foreground conversion; no floating-point work is performed in the ISR. */
|
||||
bool tdk_icm42688_take_measurement(imu_sample_t* measurement_out);
|
||||
void tdk_icm42688_get_diagnostics(tdk_icm42688_diagnostics_t* diagnostics_out);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user