Реализовано асинхронное чтение IMU
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
#define REG_BANK_SEL 0x7F
|
||||
#define REG_GYRO_CONFIG_1 0x01
|
||||
#define REG_ACCEL_CONFIG 0x14
|
||||
#define IMU_DT 0.002f // 2 ms
|
||||
#define FREQUENCY 100.0f
|
||||
#define IMU_DT 1.0f / FREQUENCY
|
||||
|
||||
#define GYRO_FS_SEL_2000 3 << 1
|
||||
#define GYRO_DLPFCFG_73 3 << 3
|
||||
@@ -23,12 +24,20 @@
|
||||
#define ACCEL_FCHOICE_ON 1
|
||||
#define ACCEL_FCHOICE_OFF 0
|
||||
|
||||
static volatile uint8_t i2c_busy = 0;
|
||||
static uint8_t i2c_buf[16];
|
||||
static uint8_t i2c_len = 0;
|
||||
static uint8_t i2c_reg = 0;
|
||||
static uint8_t i2c_addr = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16_t ax, ay, az; // lsb
|
||||
int16_t gx, gy, gz; // lsb
|
||||
} imu_raw_t;
|
||||
|
||||
static void (*i2c_callback)(uint8_t* buf) = 0;
|
||||
|
||||
void imu_pow_init();
|
||||
|
||||
void i2c_gpio_init();
|
||||
@@ -37,10 +46,12 @@ void i2c1_init();
|
||||
|
||||
void imu_init();
|
||||
|
||||
void imu_tim6_init();
|
||||
void imu_tim6_init(const uint16_t freq);
|
||||
|
||||
void i2c_read(uint8_t addr, uint8_t reg, uint8_t* buf, uint8_t len);
|
||||
|
||||
uint8_t i2c_read_async(uint8_t addr, uint8_t reg, uint8_t len, void (*cb)(uint8_t*));
|
||||
|
||||
void i2c_write(uint8_t addr, uint8_t reg, uint8_t data);
|
||||
|
||||
void imu_read_raw(imu_raw_t* data);
|
||||
|
||||
@@ -17,11 +17,12 @@ typedef struct
|
||||
|
||||
void imu_processing_init();
|
||||
|
||||
void imu_process_raw(imu_scaled_t* out, imu_raw_t* raw, const uint8_t* allowed_calib);
|
||||
void imu_read_scaled(imu_scaled_t* out, const uint8_t* allowed_calib);
|
||||
void imu_calib(imu_raw_t* imu, long gyrLim, long accZero, long accMax);
|
||||
uint16_t Rev16(uint16_t v);
|
||||
|
||||
void imu_calibrate();
|
||||
void imu_accel_calibrate();
|
||||
|
||||
float normalize(float value, float scale, float min, float max);
|
||||
long absl(long value);
|
||||
|
||||
Reference in New Issue
Block a user