|
|
|
@ -280,6 +280,9 @@ AP_InertialSensor_Backend *AP_InertialSensor_MPU6000::probe(AP_InertialSensor &i
@@ -280,6 +280,9 @@ AP_InertialSensor_Backend *AP_InertialSensor_MPU6000::probe(AP_InertialSensor &i
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::SPIDevice> dev, |
|
|
|
|
enum Rotation rotation) |
|
|
|
|
{ |
|
|
|
|
if (!dev) { |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
AP_InertialSensor_MPU6000 *sensor; |
|
|
|
|
|
|
|
|
|
dev->set_read_flag(0x80); |
|
|
|
@ -409,10 +412,7 @@ void AP_InertialSensor_MPU6000::start()
@@ -409,10 +412,7 @@ void AP_InertialSensor_MPU6000::start()
|
|
|
|
|
set_accel_orientation(_accel_instance, _rotation); |
|
|
|
|
|
|
|
|
|
// start the timer process to read samples
|
|
|
|
|
if (_dev->register_periodic_callback(1000, FUNCTOR_BIND_MEMBER(&AP_InertialSensor_MPU6000::_poll_data, bool)) == nullptr) { |
|
|
|
|
// cope with AuxiliaryBus which does not support register_periodic_callback yet
|
|
|
|
|
hal.scheduler->register_timer_process(FUNCTOR_BIND_MEMBER(&AP_InertialSensor_MPU6000::_poll_data_timer, void)); |
|
|
|
|
} |
|
|
|
|
_dev->register_periodic_callback(1000, FUNCTOR_BIND_MEMBER(&AP_InertialSensor_MPU6000::_poll_data, bool)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -469,18 +469,6 @@ bool AP_InertialSensor_MPU6000::_poll_data()
@@ -469,18 +469,6 @@ bool AP_InertialSensor_MPU6000::_poll_data()
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
varient of _poll_data for systems where register_periodic_callback |
|
|
|
|
fails. We need to handle the semaphore ourselves. |
|
|
|
|
*/ |
|
|
|
|
void AP_InertialSensor_MPU6000::_poll_data_timer() |
|
|
|
|
{ |
|
|
|
|
if (_dev->get_semaphore()->take_nonblocking()) { |
|
|
|
|
_poll_data(); |
|
|
|
|
_dev->get_semaphore()->give(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AP_InertialSensor_MPU6000::_accumulate(uint8_t *samples, uint8_t n_samples) |
|
|
|
|
{ |
|
|
|
|
for (uint8_t i = 0; i < n_samples; i++) { |
|
|
|
|