upd
This commit is contained in:
+55
-19
@@ -2,12 +2,18 @@
|
||||
// --- Core IDs ---
|
||||
#include <stdint.h>
|
||||
#define BMI270_CHIP_ID 0x00
|
||||
#define BMI270_REV_ID 0x01
|
||||
#define BMI270_ERR_REG 0x02
|
||||
#define BMI270_STATUS 0x03
|
||||
|
||||
// --- Power / system ---
|
||||
#define BMI270_PWR_CONF 0x7C
|
||||
#define BMI270_PWR_CTRL 0x7D
|
||||
#define BMI270_CMD 0x7E
|
||||
#define BMI270_INIT_CTRL 0x59
|
||||
#define BMI270_INIT_ADDR_0 0x5B
|
||||
#define BMI270_INIT_ADDR_1 0x5C
|
||||
#define BMI270_INIT_DATA 0x5E
|
||||
#define BMI270_INTERNAL_STAT 0x21
|
||||
|
||||
// --- Accel config ---
|
||||
#define BMI270_ACC_CONF 0x40
|
||||
@@ -18,37 +24,67 @@
|
||||
#define BMI270_GYR_RANGE 0x43
|
||||
|
||||
// --- Data registers ---
|
||||
#define BMI270_ACC_X_L 0x0C
|
||||
#define BMI270_ACC_X_H 0x0D
|
||||
#define BMI270_ACC_Y_L 0x0E
|
||||
#define BMI270_ACC_Y_H 0x0F
|
||||
#define BMI270_ACC_Z_L 0x10
|
||||
#define BMI270_ACC_Z_H 0x11
|
||||
#define BMI270_ACC_DATA_X_LSB 0x0C
|
||||
#define BMI270_ACC_DATA_X_HSB 0x0D
|
||||
#define BMI270_ACC_DATA_Y_LSB 0x0E
|
||||
#define BMI270_ACC_DATA_Y_HSB 0x0F
|
||||
#define BMI270_ACC_DATA_Z_LSB 0x10
|
||||
#define BMI270_ACC_DATA_Z_HSB 0x11
|
||||
|
||||
#define BMI270_GYR_X_L 0x12
|
||||
#define BMI270_GYR_X_H 0x13
|
||||
#define BMI270_GYR_Y_L 0x14
|
||||
#define BMI270_GYR_Y_H 0x15
|
||||
#define BMI270_GYR_Z_L 0x16
|
||||
#define BMI270_GYR_Z_H 0x17
|
||||
#define BMI270_GYR_DATA_X_LSB 0x12
|
||||
#define BMI270_GYR_DATA_X_HSB 0x13
|
||||
#define BMI270_GYR_DATA_Y_LSB 0x14
|
||||
#define BMI270_GYR_DATA_Y_HSB 0x15
|
||||
#define BMI270_GYR_DATA_Z_LSB 0x16
|
||||
#define BMI270_GYR_DATA_Z_HSB 0x17
|
||||
|
||||
#define BMI270_FIFO_LENGTH_0 0x24
|
||||
#define BMI270_FIFO_DATA 0x26
|
||||
#define BMI270_FIFO_CONFIG_0 0x48
|
||||
#define BMI270_FIFO_CONFIG_1 0x49
|
||||
|
||||
// --- Commands ---
|
||||
#define BMI270_CMD_SOFTRESET 0xB6
|
||||
#define BMI270_CMD_FIFO_FLUSH 0xB0
|
||||
|
||||
// --- Power bits ---
|
||||
#define BMI270_PWR_ACCEL_EN (1 << 3)
|
||||
#define BMI270_PWR_GYRO_EN (1 << 2)
|
||||
#define BMI270_PWR_TEMP_EN (1 << 3) // 0x08
|
||||
#define BMI270_PWR_ACCEL_EN (1 << 2) // 0x04
|
||||
#define BMI270_PWR_GYRO_EN (1 << 1) // 0x02
|
||||
#define BMI270_PWR_AUX_EN (1 << 0) // 0x01
|
||||
|
||||
// --- Config presets (minimal usable defaults) ---
|
||||
#define BMI270_ACC_CONF_100HZ 0xA8
|
||||
#define BMI270_GYR_CONF_100HZ 0xA9
|
||||
|
||||
#define ACC_SCALE (4.0f / 32768.0f)
|
||||
#define G_TO_MS2 9.80665f
|
||||
|
||||
#define GYR_SCALE (2000.0f / 32768.0f)
|
||||
#define DEG_TO_RAD 0.01745329251f
|
||||
|
||||
typedef struct {
|
||||
int16_t ax, ay, az;
|
||||
int16_t gx, gy, gz;
|
||||
int16_t ax_raw;
|
||||
int16_t ay_raw;
|
||||
int16_t az_raw;
|
||||
|
||||
int16_t gx_raw;
|
||||
int16_t gy_raw;
|
||||
int16_t gz_raw;
|
||||
|
||||
float ax;
|
||||
float ay;
|
||||
float az;
|
||||
|
||||
float gx;
|
||||
float gy;
|
||||
float gz;
|
||||
|
||||
uint32_t timestamp_ms;
|
||||
} bmi270_data_t;
|
||||
|
||||
void bmi270_init(void);
|
||||
bool bmi270_init(void);
|
||||
|
||||
void bmi270_read(bmi270_data_t *d);
|
||||
bool bmi270_read(bmi270_data_t *d);
|
||||
|
||||
extern const uint8_t bmi270_config_file[8192];
|
||||
Reference in New Issue
Block a user