Browse Source

px4iofirmware: avoid using hrt_elapsed_time_atomic

It's only ever read and written in controls_tick() after startup
master
Beat Küng 3 years ago
parent
commit
0bfb1a983b
  1. 6
      src/modules/px4iofirmware/controls.c
  2. 3
      src/modules/px4iofirmware/px4io.h

6
src/modules/px4iofirmware/controls.c

@ -197,7 +197,6 @@ controls_init(void) @@ -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() @@ -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() @@ -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 */

3
src/modules/px4iofirmware/px4io.h

@ -136,8 +136,7 @@ extern uint16_t r_page_servo_disarmed[]; /* PX4IO_PAGE_DISARMED_PWM */ @@ -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

Loading…
Cancel
Save