From ceeade582259877dde67106b2bef88c4bdbe3c73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Dec 2017 09:26:11 +1100 Subject: [PATCH] AP_IOMCU: added periodic reading of RC input --- libraries/AP_IOMCU/AP_IOMCU.cpp | 4 ++++ libraries/AP_IOMCU/AP_IOMCU.h | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index c327e19be2..2c450b52d9 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -66,6 +66,7 @@ enum ioevents { IOEVENT_SET_ONESHOT_ON, IOEVENT_SET_ONESHOT_OFF, IOEVENT_SET_RATES, + IOEVENT_GET_RCIN, }; // setup page registers @@ -186,6 +187,9 @@ void AP_IOMCU::send_servo_out() */ void AP_IOMCU::read_rc_input() { + // read a min of 9 channels and max of max_channels + uint8_t n = MIN(MAX(9, rc_input.count), max_channels); + read_registers(PAGE_RAW_RCIN, 0, 6+n, (uint16_t *)&rc_input); } /* diff --git a/libraries/AP_IOMCU/AP_IOMCU.h b/libraries/AP_IOMCU/AP_IOMCU.h index 2fc17be584..933dae3496 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.h +++ b/libraries/AP_IOMCU/AP_IOMCU.h @@ -113,6 +113,17 @@ private: uint16_t prssi; } reg_status; + // PAGE_RAW_RCIN values + struct PACKED { + uint16_t count; + uint16_t flags; + uint16_t nrssi; + uint16_t data; + uint16_t frame_count; + uint16_t lost_frame_count; + uint16_t pwm[max_channels]; + } rc_input; + // output pwm values struct { uint8_t num_channels;