69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
|
|
#ifndef __INERTIALSENSOR_INVENSENSE_H__
|
|
#define __INERTIALSENSOR_INVENSENSE_H__
|
|
|
|
#include "SPIDevice.h"
|
|
|
|
enum Invensense_Type {
|
|
Invensense_MPU6000=0,
|
|
Invensense_MPU6500,
|
|
Invensense_MPU9250,
|
|
Invensense_ICM20600,
|
|
Invensense_ICM20608,
|
|
Invensense_ICM20602,
|
|
Invensense_ICM20601,
|
|
Invensense_ICM20789,
|
|
Invensense_ICM20689,
|
|
};
|
|
|
|
typedef struct {
|
|
float accel[3];
|
|
float gyro[3];
|
|
uint8_t count;
|
|
} ACCUM_t;
|
|
|
|
typedef struct {
|
|
int16_t _raw_temp;
|
|
|
|
float temp_sensitivity; // degC/LSB
|
|
float temp_zero; // degC
|
|
|
|
float _accel_scale;
|
|
|
|
GPIO_TypeDef* _drdy;
|
|
uint16_t _drdy_Pin;
|
|
SPI_DEV_t* _dev;
|
|
|
|
// which sensor type this is
|
|
enum Invensense_Type _mpu_type;
|
|
|
|
// Last status from register user control
|
|
uint8_t _last_stat_user_ctrl;
|
|
|
|
// buffer for fifo read
|
|
uint8_t *_fifo_buffer;
|
|
|
|
ACCUM_t _accum;
|
|
|
|
uint32_t accel_clip_count;
|
|
|
|
float accel[3];
|
|
float gyro[3];
|
|
float temp_degc;
|
|
|
|
const char *name;
|
|
bool success;
|
|
int cnt;
|
|
int pps;
|
|
int seq;
|
|
osMutexId mutex;
|
|
}InertialSensor_Invensense_t;
|
|
|
|
bool InertialSensor_Invensense_init(InertialSensor_Invensense_t *imu, const char *name, SPI_DEV_t* dev, GPIO_TypeDef* drdy, uint16_t drdy_Pin);
|
|
void InertialSensor_Invensense_update(InertialSensor_Invensense_t *imu);
|
|
void InertialSensor_Invensense_loop(InertialSensor_Invensense_t *imu);
|
|
void InertialSensor_Invensense_monitor(InertialSensor_Invensense_t *imu);
|
|
|
|
#endif /* __INERTIALSENSOR_INVENSENSE_H__ */
|
|
|