PER Firmware
Loading...
Searching...
No Matches
bmi088.h
Go to the documentation of this file.
1
9#ifndef BMI088_H
10#define BMI088_H
11
12#include <stdbool.h>
13#include <stdint.h>
14
15#include "common/phal/gpio.h"
16#include "common/phal/spi.h"
17
18#define BMI088_GYRO_CHIP_ID (0x0FU)
19#define BMI088_ACC_CHIP_ID (0x1EU)
20#define BMI088_ACC_PWR_CTRL_NORMAL (0x04U)
21
22#define BMI088_GYRO_CHIP_ID_ADDR (0x00U) /* Gyro Chip ID address */
23#define BMI088_GYRO_RATE_X_LSB_ADDR (0x02U) /* Gyro X rate LSB address */
24#define BMI088_GYRO_RATE_Y_LSB_ADDR (0x04U) /* Gyro Y rate LSB address */
25#define BMI088_GYRO_RATE_Z_LSB_ADDR (0x06U) /* Gyro Z rate LSB address */
26#define BMI088_GYRO_RANGE_ADDR (0x0FU) /* Gyro data range address */
27#define BMI088_GYRO_BANDWIDTH_ADDR (0x10U) /* Gyro data bandwidth address */
28#define BMI088_GYRO_SELFTEST_ADDR (0x3CU) /* Gyro self test address */
29
30#define BMI088_ACC_CHIP_ID_ADDR (0x00U) /* Accelerometer Chip ID address */
31#define BMI088_ACC_STATUS_ADDR (0x03U) /* Accelerometer status address */
32#define BMI088_ACC_RATE_X_LSB_ADDR (0x12U) /* Accelerometer X Rate LSB address */
33#define BMI088_ACC_RATE_Y_LSB_ADDR (0x14U) /* Accelerometer Y Rate LSB address */
34#define BMI088_ACC_RATE_Z_LSB_ADDR (0x16U) /* Accelerometer Z Rate LSB address */
35#define BMI088_ACC_CONFIG_ADDR (0x40U) /* Accelerometer configuration address */
36#define BMI088_ACC_RANGE_ADDR (0x41U) /* Accelerometer rate range address */
37#define BMI088_ACC_PWR_CONF_ADDR (0x7CU) /* Accelerometer power configuration address */
38#define BMI088_ACC_PWR_CTRL_ADDR (0x7DU) /* Accelerometer power control address */
39
40typedef enum {
41 ACCEL_ODR_12_5Hz = 0x05,
42 ACCEL_ODR_25Hz = 0x06,
43 ACCEL_ODR_50Hz = 0x07,
44 ACCEL_ODR_100Hz = 0x08,
45 ACCEL_ODR_200Hz = 0x09,
46 ACCEL_ODR_400Hz = 0x0A,
47 ACCEL_ODR_800Hz = 0x0B,
48 ACCEL_ODR_1600Hz = 0x0C,
49} BMI088_AccelODR_t;
50
51typedef enum {
52 ACCEL_OS_NORMAL = 0x0A,
53 ACCEL_OS_2 = 0x09,
54 ACCEL_OS_4 = 0x08,
55} BMI088_AccelBWP_t;
56
57typedef enum {
58 ACCEL_RANGE_3G = 0x00,
59 ACCEL_RANGE_6G = 0x01,
60 ACCEL_RANGE_12G = 0x02,
61 ACCEL_RANGE_24G = 0x03,
62} BMI088_AccelRange_t;
63
64typedef enum {
65 GYRO_RANGE_2000 = 0x00,
66 GYRO_RANGE_1000 = 0x01,
67 GYRO_RANGE_500 = 0x02,
68 GYRO_RANGE_250 = 0x03,
69 GYRO_RANGE_125 = 0x04,
70} BMI088_GyroRange_t;
71
72typedef enum {
73 GYRO_DR_2000Hz_532Hz = 0x00,
74 GYRO_DR_2000Hz_230Hz = 0x01,
75 GYRO_DR_1000Hz_116Hz = 0x02,
76 GYRO_DR_400Hz_47Hz = 0x03,
77 GYRO_DR_200Hz_23Hz = 0x04,
78 GYRO_DR_100Hz_12Hz = 0x05,
79 GYRO_DR_200Hz_64Hz = 0x06,
80 GYRO_DR_100Hz_32Hz = 0x07,
81} BMI088_GyroDrBw_t;
82
83typedef struct {
84 float gyro_x; // Angular velocity around the X axis (pitch) in rad/s
85 float gyro_y; // Angular velocity around the Y axis (roll) in rad/s
86 float gyro_z; // Angular velocity around the Z axis (yaw) in rad/s
87
88 float accel_x; // Acceleration over x axis (m/s^2)
89 float accel_y; // Acceleration over y axis (m/s^2)
90 float accel_z; // Acceleration over z axis (m/s^2)
92
93typedef struct
94{
96
97 uint8_t bmi_rx_buffer[16];
98 uint8_t bmi_tx_buffer[16];
99 IMU_data_t data;
100
101 BMI088_AccelRange_t accel_range;
102 BMI088_AccelBWP_t accel_bwp;
103 BMI088_AccelODR_t accel_odr;
104 BMI088_GyroRange_t gyro_range;
105 BMI088_GyroDrBw_t gyro_datarate;
106
107 bool enableDynamicRange;
108 bool isAccelReady;
109 bool isGyroOK;
111
120
121void BMI088_wakeAccel(BMI088_Handle_t *bmi);
122
131
140
148
156
164
172
181
182uint8_t BMI088_checkGyroHealth(BMI088_Handle_t *bmi);
183
184#endif // BMI088_H
bool BMI088_readGyro(BMI088_Handle_t *bmi)
Blocking function to read the most recent Data Sample from the gyro.
Definition bmi088.c:155
bool BMI088_readAccel(BMI088_Handle_t *bmi)
Blocking function to read the acceleration values form the device.
Definition bmi088.c:190
bool BMI088_gyroOK(BMI088_Handle_t *bmi)
Do self test of gyroscope.
Definition bmi088.c:66
bool BMI088_initAccel(BMI088_Handle_t *bmi)
Setup the accelerometer, must be done 50ms or longer after POR.
Definition bmi088.c:51
bool BMI088_init(BMI088_Handle_t *bmi)
Definition bmi088.c:21
bool BMI088_gyroSelfTestPass(BMI088_Handle_t *bmi)
Check the status of the most recent Gyro self test.
Definition bmi088.c:92
bool BMI088_gyroSelfTestStart(BMI088_Handle_t *bmi)
Start the gyro self test.
Definition bmi088.c:78
bool BMI088_gyroSelfTestComplete(BMI088_Handle_t *bmi)
Check the status of the most recent Gyro self test.
Definition bmi088.c:85
Definition bmi088.h:94
Definition bmi088.h:83
Configuration entry for SPI initilization.
Definition spi.h:26