Skip to content
Snippets Groups Projects
bno055_common.h 4.66 KiB
#ifndef BNO055_COMMON_H
#define BNO055_COMMON_H

typedef enum {normal_mode=0x00,
              low_power_mode=0x01,
              suspend_mode=0x02} power_mode_t;

typedef enum {config_mode=0x00,
              acc_only_mode=0x01,
              mag_only_mode=0x02,
              gyro_only_mode=0x03,
              acc_mag_mode=0x04,
              acc_gyro_mode=0x05,
              mag_gyro_mode=0x06,
              acc_mag_gyro_mode=0x07,
              imu_mode=0x08,
              compass_mode=0x09,
              m4g_mode=0x0A,
              ndof_off_mode=0x0B,
              ndof_mode=0x0C} op_mode_t;

typedef struct
{
  unsigned char chip_id;
  unsigned char acc_id;
  unsigned char mag_id;
  unsigned char gyr_id;
  unsigned short int soft_ver;
  unsigned char boot_ver;
}TBNO055IMUInfo;

/* accelerometer definitions */
/* operation mode */
#define       ACCEL_MODE_MASK               0xE0
#define       ACCEL_NORMAL_MODE            0x00
#define       ACCEL_SUSPEND_MODE           0x20
#define       ACCEL_LOW_POWER1_MODE        0x40
#define       ACCEL_STANDBY_MODE           0x60
#define       ACCEL_LOW_POWER2_MODE        0x80
#define       ACCEL_DEEP_SUSPEND_MODE      0xA0

/* range */
#define       ACCEL_RANGE_MASK             0x03
#define       ACCEL_2G_RANGE               0x00
#define       ACCEL_4G_RANGE               0x01
#define       ACCEL_8G_RANGE               0x02
#define       ACCEL_16G_RANGE              0x03

/* bandwidth */
#define       ACCEL_BW_MASK                0x1C
#define       ACCEL_7_81_BW                0x00
#define       ACCEL_15_63_BW               0x04
#define       ACCEL_31_25_BW               0x08
#define       ACCEL_62_5_BW                0x0C
#define       ACCEL_125_BW                 0x10
#define       ACCEL_250_BW                 0x14
#define       ACCEL_500_BW                 0x18
#define       ACCEL_1000_BW                0x1C

typedef enum {accel_linear,accel_gravity} accel_units_t;

typedef struct
{
  unsigned char conf_reg;
  accel_units_t units;
}TBNO055AccelConfig;

/* gyroscope definitions */
/* operation mode */
#define       GYRO_MODE_MASK               0x07
#define       GYRO_NORMAL_MODE             0x00
#define       GYRO_FAST_PWR_UP_MODE        0x01
#define       GYRO_DEEP_SUSPEND_MODE       0x02
#define       GYRO_SUSPEND_MODE            0x03
#define       GYRO_ADV_POWER_SAVE_MODE     0x04

/* range */
#define       GYRO_RANGE_MASK              0x07
#define       GYRO_2000_RANGE              0x00
#define       GYRO_1000_RANGE              0x01
#define       GYRO_500_RANGE               0x02
#define       GYRO_250_RANGE               0x03
#define       GYRO_125_RANGE               0x04

/* bandwidth */
#define       GYRO_BW_MASK                 0x38
#define       GYRO_523_BW                  0x00
#define       GYRO_230_BW                  0x08
#define       GYRO_116_BW                  0x10
#define       GYRO_47_BW                   0x18
#define       GYRO_23_BW                   0x20
#define       GYRO_12_BW                   0x28
#define       GYRO_64_BW                   0x30
#define       GYRO_32_BW                   0x38

typedef enum {gyro_deg,gyro_rad} gyro_units_t;
typedef enum {euler_deg,euler_rad} euler_units_t;

typedef struct
{
  unsigned char conf_reg1;
  unsigned char conf_reg2;
  gyro_units_t units;
}TBNO055GyroConfig;

/* magnetometer definitions */
/* operation mode */
#define       MAG_OP_MODE_MASK             0x18
#define       MAG_LOW_POWER_MODE           0x00
#define       MAG_REGULAR_MODE             0x08
#define       MAG_EN_REGULAR_MODE          0x10
#define       MAG_HICH_ACC_MODE            0x18

/* power mode */
#define       MAG_POWER_MODE_MASK          0x60
#define       MAG_NORMAL_MODE              0x00
#define       MAG_SLEEP_MODE               0x20
#define       MAG_SUSPEND_MODE             0x40
#define       MAG_FORCE_MODE               0x60

/* rate */
#define       MAG_RATE_MASK                0x07
#define       MAG_2_RATE                   0x00
#define       MAG_6_RATE                   0x01
#define       MAG_8_RATE                   0x02
#define       MAG_10_RATE                  0x03
#define       MAG_15_RATE                  0x04
#define       MAG_20_RATE                  0x05
#define       MAG_25_RATE                  0x06
#define       MAG_30_RATE                  0x07

typedef struct
{
  unsigned char conf_reg;
}TBNO055MagConfig;

#define       ACCEL_UNITS_MASK             0x01
#define       GYRO_UNITS_MASK              0x02
#define       EULER_UNITS_MASK             0x04
#define       TEMP_UNITS_MASK              0x10

/* temperature definitions */
typedef enum {temp_celcius,temp_farenheit} temp_units_t;

/* axis remapping definitions */
typedef enum {X_AXIS=0x00,Y_AXIS=0x01,Z_AXIS=0x02} axis_t;

#endif