From fde635ef5ab2fbf45a576719406095481a3b5d43 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Mar 2016 19:10:45 +1100 Subject: [PATCH] px4iofirmware: fixed display of sbus rate in px4io status --- src/drivers/px4io/px4io.cpp | 1 + src/lib/rc/sbus.c | 6 ++++-- src/modules/px4iofirmware/registers.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index dbcf1ef9bc..2e2a217823 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -2614,6 +2614,7 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg) /* set override immediate flag */ ret = io_reg_modify(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_ARMING, 0, PX4IO_P_SETUP_ARMING_OVERRIDE_IMMEDIATE); } + break; case PWM_SERVO_SET_SBUS_RATE: diff --git a/src/lib/rc/sbus.c b/src/lib/rc/sbus.c index ba1ff6078c..ca4edd2208 100644 --- a/src/lib/rc/sbus.c +++ b/src/lib/rc/sbus.c @@ -117,7 +117,7 @@ static enum SBUS2_DECODE_STATE { static uint8_t sbus_frame[SBUS_FRAME_SIZE + (SBUS_FRAME_SIZE / 2)]; static unsigned partial_frame_count; -static unsigned sbus1_frame_delay = (1000U*1000U)/SBUS1_DEFAULT_RATE_HZ; +static unsigned sbus1_frame_delay = (1000U * 1000U) / SBUS1_DEFAULT_RATE_HZ; static unsigned sbus_frame_drops; @@ -646,8 +646,10 @@ void sbus1_set_output_rate_hz(uint16_t rate_hz) if (rate_hz > SBUS1_MAX_RATE_HZ) { rate_hz = SBUS1_MAX_RATE_HZ; } + if (rate_hz < SBUS1_MIN_RATE_HZ) { rate_hz = SBUS1_MIN_RATE_HZ; } - sbus1_frame_delay = (1000U*1000U) / rate_hz; + + sbus1_frame_delay = (1000U * 1000U) / rate_hz; } diff --git a/src/modules/px4iofirmware/registers.c b/src/modules/px4iofirmware/registers.c index de7615a8ab..3a7d90aecf 100644 --- a/src/modules/px4iofirmware/registers.c +++ b/src/modules/px4iofirmware/registers.c @@ -685,6 +685,7 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value) break; case PX4IO_P_SETUP_SBUS_RATE: + r_page_setup[offset] = value; sbus1_set_output_rate_hz(value); break;