55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#pragma once
|
|
// --- Core IDs ---
|
|
#include <stdint.h>
|
|
#define BMI270_CHIP_ID 0x00
|
|
#define BMI270_REV_ID 0x01
|
|
|
|
// --- Power / system ---
|
|
#define BMI270_PWR_CONF 0x7C
|
|
#define BMI270_PWR_CTRL 0x7D
|
|
#define BMI270_CMD 0x7E
|
|
|
|
// --- Accel config ---
|
|
#define BMI270_ACC_CONF 0x40
|
|
#define BMI270_ACC_RANGE 0x41
|
|
|
|
// --- Gyro config ---
|
|
#define BMI270_GYR_CONF 0x42
|
|
#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_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
|
|
|
|
// --- 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)
|
|
|
|
// --- Config presets (minimal usable defaults) ---
|
|
#define BMI270_ACC_CONF_100HZ 0xA8
|
|
#define BMI270_GYR_CONF_100HZ 0xA9
|
|
|
|
typedef struct {
|
|
int16_t ax, ay, az;
|
|
int16_t gx, gy, gz;
|
|
} bmi270_data_t;
|
|
|
|
void bmi270_init(void);
|
|
|
|
void bmi270_read(bmi270_data_t *d);
|