From 0bfb1a983b6988970e6a2678288c3e5681b27a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 22 Sep 2021 13:19:52 +0200 Subject: [PATCH] px4iofirmware: avoid using hrt_elapsed_time_atomic It's only ever read and written in controls_tick() after startup --- src/modules/px4iofirmware/controls.c | 6 +----- src/modules/px4iofirmware/px4io.h | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/px4iofirmware/controls.c b/src/modules/px4iofirmware/controls.c index 9e668de4c2..b6d079d6f3 100644 --- a/src/modules/px4iofirmware/controls.c +++ b/src/modules/px4iofirmware/controls.c @@ -197,7 +197,6 @@ controls_init(void) /* no channels */ r_raw_rc_count = 0; system_state.rc_channels_timestamp_received = 0; - system_state.rc_channels_timestamp_valid = 0; /* DSM input (USART1) */ _dsm_fd = dsm_init("/dev/ttyS0"); @@ -378,9 +377,6 @@ controls_tick() /* update RC-received timestamp */ system_state.rc_channels_timestamp_received = hrt_absolute_time(); - /* update RC-received timestamp */ - system_state.rc_channels_timestamp_valid = system_state.rc_channels_timestamp_received; - /* map raw inputs to mapped inputs */ /* XXX mapping should be atomic relative to protocol */ for (unsigned i = 0; i < r_raw_rc_count; i++) { @@ -500,7 +496,7 @@ controls_tick() * If we haven't seen any new control data in 200ms, assume we * have lost input. */ - if (!rc_input_lost && hrt_elapsed_time_atomic(&system_state.rc_channels_timestamp_received) > 200000) { + if (!rc_input_lost && hrt_elapsed_time(&system_state.rc_channels_timestamp_received) > 200000) { rc_input_lost = true; /* clear the input-kind flags here */ diff --git a/src/modules/px4iofirmware/px4io.h b/src/modules/px4iofirmware/px4io.h index 7b61e99de8..5c2f305409 100644 --- a/src/modules/px4iofirmware/px4io.h +++ b/src/modules/px4iofirmware/px4io.h @@ -136,8 +136,7 @@ extern uint16_t r_page_servo_disarmed[]; /* PX4IO_PAGE_DISARMED_PWM */ */ struct sys_state_s { - volatile uint64_t rc_channels_timestamp_received; - volatile uint64_t rc_channels_timestamp_valid; + uint64_t rc_channels_timestamp_received; /** * Last FMU receive time, in microseconds since system boot