|
|
|
@ -245,18 +245,19 @@ static volatile uint16_t _count;
@@ -245,18 +245,19 @@ static volatile uint16_t _count;
|
|
|
|
|
|
|
|
|
|
/*================ AP_INERTIALSENSOR PUBLIC INTERFACE ==================== */ |
|
|
|
|
|
|
|
|
|
void AP_InertialSensor_MPU6000::wait_for_sample() |
|
|
|
|
bool AP_InertialSensor_MPU6000::wait_for_sample(uint16_t timeout_ms) |
|
|
|
|
{ |
|
|
|
|
uint32_t tstart = hal.scheduler->micros(); |
|
|
|
|
while (sample_available() == false) { |
|
|
|
|
uint32_t now = hal.scheduler->micros(); |
|
|
|
|
uint32_t dt = now - tstart; |
|
|
|
|
if (dt > 50000) { |
|
|
|
|
hal.scheduler->panic( |
|
|
|
|
PSTR("PANIC: AP_InertialSensor_MPU6000::update " |
|
|
|
|
"waited 50ms for data from interrupt")); |
|
|
|
|
if (sample_available()) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
uint32_t start = hal.scheduler->millis(); |
|
|
|
|
while ((hal.scheduler->millis() - start) < timeout_ms) { |
|
|
|
|
hal.scheduler->delay_microseconds(100); |
|
|
|
|
if (sample_available()) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AP_InertialSensor_MPU6000::update( void ) |
|
|
|
@ -266,7 +267,9 @@ bool AP_InertialSensor_MPU6000::update( void )
@@ -266,7 +267,9 @@ bool AP_InertialSensor_MPU6000::update( void )
|
|
|
|
|
Vector3f accel_scale = _accel_scale.get(); |
|
|
|
|
|
|
|
|
|
// wait for at least 1 sample
|
|
|
|
|
wait_for_sample(); |
|
|
|
|
if (!wait_for_sample(1000)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// disable timer procs for mininum time
|
|
|
|
|
hal.scheduler->suspend_timer_procs(); |
|
|
|
|