@@ -34,7 +34,7 @@ void BoschSensorClass::onInterrupt(mbed::Callback<void(void)> cb)
34
34
irq.rise (mbed::callback (this , &BoschSensorClass::interrupt_handler));
35
35
}
36
36
#endif
37
- int BoschSensorClass::begin () {
37
+ int BoschSensorClass::begin (CfgBoshSensor_t cfg ) {
38
38
39
39
_wire->begin ();
40
40
@@ -60,23 +60,29 @@ int BoschSensorClass::begin() {
60
60
mag_dev_info._wire = _wire;
61
61
mag_dev_info.dev_addr = bmm1.chip_id ;
62
62
63
- int8_t bmi270InitResult = bmi270_init (&bmi2);
64
- print_rslt (bmi270InitResult);
63
+ int8_t result = 0 ;
65
64
66
- int8_t bmi270ConfigResult = configure_sensor (&bmi2);
67
- print_rslt (bmi270ConfigResult);
65
+ if (cfg != BOSCH_MAGNETOMETER_ONLY) {
68
66
69
- int8_t bmm150InitResult = bmm150_init (&bmm1 );
70
- print_rslt (bmm150InitResult );
67
+ result |= bmi270_init (&bmi2 );
68
+ print_rslt (result );
71
69
72
- int8_t bmm150ConfigResult = configure_sensor (&bmm1);
73
- print_rslt (bmm150ConfigResult);
70
+ result |= configure_sensor (&bmi2);
71
+ print_rslt (result);
72
+ }
73
+
74
+ if (cfg != BOSCH_ACCELEROMETER_ONLY) {
75
+
76
+ result |= bmm150_init (&bmm1);
77
+ print_rslt (result);
78
+
79
+ result = configure_sensor (&bmm1);
80
+ print_rslt (result);
81
+ }
74
82
75
- bool success = bmi270InitResult == BMI2_OK && bmi270ConfigResult == BMI2_OK &&
76
- bmm150InitResult == BMM150_OK && bmm150ConfigResult == BMM150_OK;
77
- _initialized = success;
83
+ _initialized = (result == 0 );
78
84
79
- return success ;
85
+ return _initialized ;
80
86
}
81
87
82
88
0 commit comments