forked from Archive/PX4-Autopilot
Use hrt_elapsed_time() in cases where we can't be sure the timestamp won't change under us.
This commit is contained in:
parent
923a7cc505
commit
f245d6b1a7
|
@ -154,7 +154,7 @@ adc_measure(unsigned channel)
|
|||
while (!(rSR & ADC_SR_EOC)) {
|
||||
|
||||
/* never spin forever - this will give a bogus result though */
|
||||
if ((hrt_absolute_time() - now) > 1000) {
|
||||
if (hrt_elapsed_time(&now) > 1000) {
|
||||
debug("adc timeout");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ controls_tick() {
|
|||
* If we haven't seen any new control data in 200ms, assume we
|
||||
* have lost input.
|
||||
*/
|
||||
if ((hrt_absolute_time() - system_state.rc_channels_timestamp) > 200000) {
|
||||
if (hrt_elapsed_time(&system_state.rc_channels_timestamp) > 200000) {
|
||||
rc_input_lost = true;
|
||||
|
||||
/* clear the input-kind flags here */
|
||||
|
@ -294,7 +294,7 @@ ppm_input(uint16_t *values, uint16_t *num_values)
|
|||
* If we have received a new PPM frame within the last 200ms, accept it
|
||||
* and then invalidate it.
|
||||
*/
|
||||
if ((hrt_absolute_time() - ppm_last_valid_decode) < 200000) {
|
||||
if (hrt_elapsed_time(&ppm_last_valid_decode) < 200000) {
|
||||
|
||||
/* PPM data exists, copy it */
|
||||
*num_values = ppm_decoded_channels;
|
||||
|
|
|
@ -88,7 +88,7 @@ void
|
|||
mixer_tick(void)
|
||||
{
|
||||
/* check that we are receiving fresh data from the FMU */
|
||||
if ((hrt_absolute_time() - system_state.fmu_data_received_time) > FMU_INPUT_DROP_LIMIT_US) {
|
||||
if (hrt_elapsed_time(&system_state.fmu_data_received_time) > FMU_INPUT_DROP_LIMIT_US) {
|
||||
|
||||
/* too long without FMU input, time to go to failsafe */
|
||||
if (r_status_flags & PX4IO_P_STATUS_FLAGS_FMU_OK) {
|
||||
|
|
|
@ -105,12 +105,12 @@ extern uint16_t r_page_servo_failsafe[]; /* PX4IO_PAGE_FAILSAFE_PWM */
|
|||
*/
|
||||
struct sys_state_s {
|
||||
|
||||
uint64_t rc_channels_timestamp;
|
||||
volatile uint64_t rc_channels_timestamp;
|
||||
|
||||
/**
|
||||
* Last FMU receive time, in microseconds since system boot
|
||||
*/
|
||||
uint64_t fmu_data_received_time;
|
||||
volatile uint64_t fmu_data_received_time;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue