Basic_Frame_TypeC_2023_Omni
Loading...
Searching...
No Matches
bmi088_driver.h
1/*******************************************************************************
2* @file : bmi088_driver.h
3* @brief : gyroscope BMI088 and ist8310 read/write for attitude reading
4* @restructed : Nov, 2023
5* @maintainer : Haoran
6********************************************************************************
7* Copyright (c) 2023 UARM Artemis.
8* All rights reserved.
9*******************************************************************************/
10
11#ifndef __BMI088_DRIVER_H__
12#define __BMI088_DRIVER_H__
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include "bmi088_middleware.h"
19#include "bmi088_reg.h"
20#include "stdint.h"
21
22/* public defines of IMU */
23#define BMI088_TEMP_FACTOR 0.125f
24#define BMI088_TEMP_OFFSET 23.0f
25
26#define BMI088_WRITE_ACCEL_REG_NUM 6
27#define BMI088_WRITE_GYRO_REG_NUM 6
28
29#define BMI088_GYRO_DATA_READY_BIT 0
30#define BMI088_ACCEL_DATA_READY_BIT 1
31#define BMI088_ACCEL_TEMP_DATA_READY_BIT 2
32
33#define BMI088_LONG_DELAY_TIME 80
34#define BMI088_COM_WAIT_SENSOR_TIME 150
35
36#define BMI088_ACCEL_IIC_ADDRESSE (0x18 << 1)
37#define BMI088_GYRO_IIC_ADDRESSE (0x68 << 1)
38
39#define BMI088_ACCEL_RANGE_3G
40//#define BMI088_ACCEL_RANGE_6G
41//#define BMI088_ACCEL_RANGE_12G
42//#define BMI088_ACCEL_RANGE_24G
43
44#define BMI088_GYRO_RANGE_2000
45//#define BMI088_GYRO_RANGE_1000
46//#define BMI088_GYRO_RANGE_500
47//#define BMI088_GYRO_RANGE_250
48//#define BMI088_GYRO_RANGE_125
49
50#define BMI088_ACCEL_3G_SEN 0.000091552734375f
51#define BMI088_ACCEL_6G_SEN 0.00018310546875f
52#define BMI088_ACCEL_12G_SEN 0.0003662109375f
53#define BMI088_ACCEL_24G_SEN 0.000732421875f
54
55#define BMI088_GYRO_2000_SEN 0.06103515625f
56#define BMI088_GYRO_1000_SEN 0.030517578125f
57#define BMI088_GYRO_500_SEN 0.0152587890625f
58#define BMI088_GYRO_250_SEN 0.00762939453125f
59#define BMI088_GYRO_125_SEN 0.00381469726563f
60
61#define DEGREES_TO_RADIANS 0.0174532925199f
62
63// TODO: Change when moving locations
64// Edmonton gravity conversion
65#define G_TO_METERS_PER_SECOND_SQUARED 9.8115861
66
67typedef struct BMI088_REAL_DATA {
68 uint8_t status;
69 float accel[3];
70 float temp;
71 float gyro[3];
72 float time;
73} bmi088_real_data_t;
74
75enum {
76 BMI088_NO_ERROR = 0x00,
77 BMI088_ACC_PWR_CTRL_ERROR = 0x01,
78 BMI088_ACC_PWR_CONF_ERROR = 0x02,
79 BMI088_ACC_CONF_ERROR = 0x03,
80 BMI088_ACC_SELF_TEST_ERROR = 0x04,
81 BMI088_ACC_RANGE_ERROR = 0x05,
82 BMI088_INT1_IO_CTRL_ERROR = 0x06,
83 BMI088_INT_MAP_DATA_ERROR = 0x07,
84 BMI088_GYRO_RANGE_ERROR = 0x08,
85 BMI088_GYRO_BANDWIDTH_ERROR = 0x09,
86 BMI088_GYRO_LPM1_ERROR = 0x0A,
87 BMI088_GYRO_CTRL_ERROR = 0x0B,
88 BMI088_GYRO_INT3_INT4_IO_CONF_ERROR = 0x0C,
89 BMI088_GYRO_INT3_INT4_IO_MAP_ERROR = 0x0D,
90
91 BMI088_SELF_TEST_ACCEL_ERROR = 0x80,
92 BMI088_SELF_TEST_GYRO_ERROR = 0x40,
93 BMI088_NO_SENSOR = 0xFF,
94};
95
96/* define private functions of IMU */
97uint8_t BMI088_init(void);
98uint8_t bmi088_accel_init(void);
99uint8_t bmi088_gyro_init(void);
100uint8_t bmi088_accel_self_test(void);
101uint8_t bmi088_gyro_self_test(void);
102void BMI088_read_gyro_who_am_i(void);
103uint8_t BMI088_read_accel_who_am_i(void);
104void BMI088_accel_read(uint8_t* rx_buf, float accel[3], float* time);
105void BMI088_gyro_read(uint8_t* rx_buf, float gyro[3]);
106void BMI088_temperature_read(uint8_t* rx_buf, float* temperate);
107void BMI088_Read(float gyro[3], float accel[3], float* temperate);
108float get_BMI088_temperature(void);
109void get_BMI088_gyro(int16_t gyro[3]);
110void get_BMI088_accel(float accel[3]);
111
112#define BMI088_ACCEL_Read_Single_Reg(reg, data) \
113 { \
114 BMI088_ACCEL_NS_L(); \
115 BMI088_Read_Write_Byte((reg) | 0x80); \
116 BMI088_Read_Write_Byte(0x55); \
117 (data) = BMI088_Read_Write_Byte(0x55); \
118 BMI088_ACCEL_NS_H(); \
119 }
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
Definition bmi088_driver.h:67