-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBLE_IMU.h
57 lines (46 loc) · 1.77 KB
/
BLE_IMU.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <Arduino_BMI270_BMM150.h>
class MyBoschSensor: public BoschSensorClass {
public:
MyBoschSensor(TwoWire& wire = Wire) : BoschSensorClass(wire) {};
protected:
virtual int8_t configure_sensor(struct bmi2_dev *dev)
{
int8_t rslt;
uint8_t sens_list[2] = { BMI2_ACCEL, BMI2_GYRO };
struct bmi2_int_pin_config int_pin_cfg;
int_pin_cfg.pin_type = BMI2_INT1;
int_pin_cfg.int_latch = BMI2_INT_NON_LATCH;
int_pin_cfg.pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH;
int_pin_cfg.pin_cfg[0].od = BMI2_INT_PUSH_PULL;
int_pin_cfg.pin_cfg[0].output_en = BMI2_INT_OUTPUT_ENABLE;
int_pin_cfg.pin_cfg[0].input_en = BMI2_INT_INPUT_DISABLE;
struct bmi2_sens_config sens_cfg[2];
sens_cfg[0].type = BMI2_ACCEL;
sens_cfg[0].cfg.acc.bwp = BMI2_ACC_OSR2_AVG2;
sens_cfg[0].cfg.acc.odr = BMI2_ACC_ODR_25HZ;
sens_cfg[0].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE;
sens_cfg[0].cfg.acc.range = BMI2_ACC_RANGE_4G;
sens_cfg[1].type = BMI2_GYRO;
sens_cfg[1].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE;
sens_cfg[1].cfg.gyr.bwp = BMI2_GYR_OSR2_MODE;
sens_cfg[1].cfg.gyr.odr = BMI2_GYR_ODR_25HZ;
sens_cfg[1].cfg.gyr.range = BMI2_GYR_RANGE_2000;
sens_cfg[1].cfg.gyr.ois_range = BMI2_GYR_OIS_2000;
rslt = bmi2_set_int_pin_config(&int_pin_cfg, dev);
if (rslt != BMI2_OK)
return rslt;
rslt = bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, dev);
if (rslt != BMI2_OK)
return rslt;
rslt = bmi2_set_sensor_config(sens_cfg, 2, dev);
if (rslt != BMI2_OK)
return rslt;
rslt = bmi2_sensor_enable(sens_list, 2, dev);
if (rslt != BMI2_OK)
return rslt;
return rslt;
}
};
void initIMU();
void calcIMU();
void writeMSP_ATTITUDE();