diff --git a/libraries/AP_ADC/AP_ADC_ADS7844.cpp b/libraries/AP_ADC/AP_ADC_ADS7844.cpp index 9e4cef4e84..df950f56bf 100644 --- a/libraries/AP_ADC/AP_ADC_ADS7844.cpp +++ b/libraries/AP_ADC/AP_ADC_ADS7844.cpp @@ -180,13 +180,13 @@ float AP_ADC_ADS7844::Ch(uint8_t ch_num) // ensure we have at least one value while (_count[ch_num] == 0) /* noop */; - // grab the value with interrupts disabled, and clear the count - hal.scheduler->begin_atomic(); + // grab the value with timer procs disabled, and clear the count + hal.scheduler->suspend_timer_procs(); count = _count[ch_num]; sum = _sum[ch_num]; _count[ch_num] = 0; _sum[ch_num] = 0; - hal.scheduler->end_atomic(); + hal.scheduler->resume_timer_procs(); return ((float)sum)/count; } @@ -221,8 +221,8 @@ uint32_t AP_ADC_ADS7844::Ch6(const uint8_t *channel_numbers, float *result) while (_count[channel_numbers[i]] == 0) /* noop */; } - // grab the values with interrupts disabled, and clear the counts - hal.scheduler->begin_atomic(); + // grab the values with timer procs disabled, and clear the counts + hal.scheduler->suspend_timer_procs(); for (i=0; i<6; i++) { count[i] = _count[channel_numbers[i]]; sum[i] = _sum[channel_numbers[i]]; @@ -235,7 +235,7 @@ uint32_t AP_ADC_ADS7844::Ch6(const uint8_t *channel_numbers, float *result) uint32_t ret = _ch6_last_sample_time_micros - _ch6_delta_time_start_micros; _ch6_delta_time_start_micros = _ch6_last_sample_time_micros; - hal.scheduler->end_atomic(); + hal.scheduler->resume_timer_procs(); // calculate averages. We keep this out of the cli region // to prevent us stalling the ISR while doing the diff --git a/libraries/AP_Baro/AP_Baro_MS5611.cpp b/libraries/AP_Baro/AP_Baro_MS5611.cpp index 3e58bba986..e51a533bf4 100644 --- a/libraries/AP_Baro/AP_Baro_MS5611.cpp +++ b/libraries/AP_Baro/AP_Baro_MS5611.cpp @@ -289,15 +289,17 @@ uint8_t AP_Baro_MS5611::read() if (updated) { uint32_t sD1, sD2; uint8_t d1count, d2count; - // we need to disable interrupts to access - // _s_D1 and _s_D2 as they are not atomic - hal.scheduler->begin_atomic(); + + // Suspend timer procs because these variables are written to + // in "_update". + hal.scheduler->suspend_timer_procs(); sD1 = _s_D1; _s_D1 = 0; sD2 = _s_D2; _s_D2 = 0; d1count = _d1_count; _d1_count = 0; d2count = _d2_count; _d2_count = 0; _updated = false; - hal.scheduler->end_atomic(); + hal.scheduler->resume_timer_procs(); + if (d1count != 0) { D1 = ((float)sD1) / d1count; } diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp index cafcfa796a..89d84a5156 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp @@ -264,8 +264,8 @@ bool AP_InertialSensor_MPU6000::update( void ) // wait for at least 1 sample wait_for_sample(); - // disable interrupts for mininum time - hal.scheduler->begin_atomic(); + // disable timer procs for mininum time + hal.scheduler->suspend_timer_procs(); for (int i=0; i<7; i++) { sum[i] = _sum[i]; _sum[i] = 0; @@ -277,7 +277,7 @@ bool AP_InertialSensor_MPU6000::update( void ) // record sample time _delta_time_micros = _last_sample_time_micros - _delta_time_start_micros; _delta_time_start_micros = _last_sample_time_micros; - hal.scheduler->end_atomic(); + hal.scheduler->resume_timer_procs(); count_scale = 1.0 / count;