From ce0b7a895725ea632080bacec4a35a8e2c353734 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Mar 2022 21:03:09 +1100 Subject: [PATCH] AP_IOMCU: fixed handling of RC_OPTIONS bit to ignore RC failsafe bit this worked on FMU but not on IOMCU --- libraries/AP_IOMCU/iofirmware/iofirmware.cpp | 6 ++++-- libraries/AP_IOMCU/iofirmware/ioprotocol.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp index 4bf32f98c8..ea30c0077a 100644 --- a/libraries/AP_IOMCU/iofirmware/iofirmware.cpp +++ b/libraries/AP_IOMCU/iofirmware/iofirmware.cpp @@ -301,12 +301,14 @@ void AP_IOMCU_FW::rcin_update() { ((ChibiOS::RCInput *)hal.rcin)->_timer_tick(); if (hal.rcin->new_input()) { + const auto &rc = AP::RC(); rc_input.count = hal.rcin->num_channels(); rc_input.flags_rc_ok = true; hal.rcin->read(rc_input.pwm, IOMCU_MAX_CHANNELS); rc_last_input_ms = last_ms; - rc_input.rc_protocol = (uint16_t)AP::RC().protocol_detected(); - rc_input.rssi = AP::RC().get_RSSI(); + rc_input.rc_protocol = (uint16_t)rc.protocol_detected(); + rc_input.rssi = rc.get_RSSI(); + rc_input.flags_failsafe = rc.failsafe_active(); } else if (last_ms - rc_last_input_ms > 200U) { rc_input.flags_rc_ok = false; } diff --git a/libraries/AP_IOMCU/iofirmware/ioprotocol.h b/libraries/AP_IOMCU/iofirmware/ioprotocol.h index 7dbf319e66..4256b6d195 100644 --- a/libraries/AP_IOMCU/iofirmware/ioprotocol.h +++ b/libraries/AP_IOMCU/iofirmware/ioprotocol.h @@ -159,9 +159,11 @@ struct page_mixing { // enabled needs to be 1 to enable mixing uint8_t enabled; - uint8_t pad; // pad to even size + uint8_t pad; }; +static_assert(sizeof(struct page_mixing) % 2 == 0, "page_mixing must be even size"); + struct __attribute__((packed, aligned(2))) page_GPIO { uint8_t channel_mask; uint8_t output_mask;