77#include " Wire.h"
88#include < M5GFX.h>
99#include < lgfx/v1/panel/Panel_ST7789.hpp>
10- // #include "Arduino_BMI270_BMM150.h"
10+ #include " Arduino_BMI270_BMM150.h"
1111
1212#undef LORA_LNA_ENABLE
1313#undef LORA_ANTENNA_SWITCH
@@ -250,5 +250,67 @@ class NessoTouch {
250250 }
251251};
252252
253+ class MyBoschSensor : public BoschSensorClass {
254+
255+ public:
256+ MyBoschSensor (TwoWire& wire = Wire) : BoschSensorClass(wire) {};
257+ bool begin () {
258+ return BoschSensorClass::begin (BOSCH_ACCELEROMETER_ONLY);
259+ }
260+
261+ protected:
262+ virtual int8_t configure_sensor (struct bmi2_dev *dev)
263+ {
264+ int8_t rslt;
265+ uint8_t sens_list[2 ] = { BMI2_ACCEL, BMI2_GYRO };
266+
267+ // This configures the second gpio expander and clears its interrupt status
268+ pinMode (LORA_ENABLE, INPUT);
269+
270+ struct bmi2_int_pin_config int_pin_cfg;
271+ int_pin_cfg.pin_type = BMI2_INT1;
272+ int_pin_cfg.int_latch = BMI2_INT_LATCH;
273+ int_pin_cfg.pin_cfg [0 ].lvl = BMI2_INT_ACTIVE_LOW;
274+ int_pin_cfg.pin_cfg [0 ].od = BMI2_INT_PUSH_PULL;
275+ int_pin_cfg.pin_cfg [0 ].output_en = BMI2_INT_OUTPUT_ENABLE;
276+ int_pin_cfg.pin_cfg [0 ].input_en = BMI2_INT_INPUT_DISABLE;
277+
278+ struct bmi2_sens_config sens_cfg[2 ];
279+ sens_cfg[0 ].type = BMI2_ACCEL;
280+ sens_cfg[0 ].cfg .acc .bwp = BMI2_ACC_OSR2_AVG2;
281+ sens_cfg[0 ].cfg .acc .odr = BMI2_ACC_ODR_25HZ;
282+ sens_cfg[0 ].cfg .acc .filter_perf = BMI2_PERF_OPT_MODE;
283+ sens_cfg[0 ].cfg .acc .range = BMI2_ACC_RANGE_4G;
284+ sens_cfg[1 ].type = BMI2_GYRO;
285+ sens_cfg[1 ].cfg .gyr .filter_perf = BMI2_PERF_OPT_MODE;
286+ sens_cfg[1 ].cfg .gyr .bwp = BMI2_GYR_OSR2_MODE;
287+ sens_cfg[1 ].cfg .gyr .odr = BMI2_GYR_ODR_25HZ;
288+ sens_cfg[1 ].cfg .gyr .range = BMI2_GYR_RANGE_2000;
289+ sens_cfg[1 ].cfg .gyr .ois_range = BMI2_GYR_OIS_2000;
290+
291+ rslt = bmi2_set_int_pin_config (&int_pin_cfg, dev);
292+ if (rslt != BMI2_OK)
293+ return rslt;
294+
295+ rslt = bmi2_map_data_int (BMI2_DRDY_INT, BMI2_INT1, dev);
296+ if (rslt != BMI2_OK)
297+ return rslt;
298+
299+ rslt = bmi2_set_sensor_config (sens_cfg, 2 , dev);
300+ if (rslt != BMI2_OK)
301+ return rslt;
302+
303+ rslt = bmi2_sensor_enable (sens_list, 2 , dev);
304+ if (rslt != BMI2_OK)
305+ return rslt;
306+
307+ return rslt;
308+ }
309+ };
310+
311+ extern MyBoschSensor myIMU;
312+ #undef IMU
313+ #define IMU myIMU
314+
253315#endif
254316#endif
0 commit comments