From 30903f2acb141543b36c2bd7aa93e9d79cae5368 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Jan 2018 16:37:14 +1100 Subject: [PATCH] AP_IOMCU: support oneshot mode --- libraries/AP_IOMCU/AP_IOMCU.cpp | 14 +++++++++++++- libraries/AP_IOMCU/AP_IOMCU.h | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index f0867654a8..48d528bf99 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -67,7 +67,6 @@ enum ioevents { IOEVENT_FORCE_SAFETY_OFF, IOEVENT_FORCE_SAFETY_ON, IOEVENT_SET_ONESHOT_ON, - IOEVENT_SET_ONESHOT_OFF, IOEVENT_SET_RATES, IOEVENT_GET_RCIN, IOEVENT_ENABLE_SBUS, @@ -217,6 +216,13 @@ void AP_IOMCU::thread_main(void) continue; } } + + if (mask & EVENT_MASK(IOEVENT_SET_ONESHOT_ON)) { + if (!modify_register(PAGE_SETUP, PAGE_REG_SETUP_FEATURES, 0, P_SETUP_FEATURES_ONESHOT)) { + event_failed(IOEVENT_SET_ONESHOT_ON); + continue; + } + } // check for regular timed events uint32_t now = AP_HAL::millis(); @@ -548,4 +554,10 @@ void AP_IOMCU::set_default_rate(uint16_t rate_hz) trigger_event(IOEVENT_SET_DEFAULT_RATE); } +// setup for oneshot mode +void AP_IOMCU::set_oneshot_mode(void) +{ + trigger_event(IOEVENT_SET_ONESHOT_ON); +} + #endif // HAL_WITH_IO_MCU diff --git a/libraries/AP_IOMCU/AP_IOMCU.h b/libraries/AP_IOMCU/AP_IOMCU.h index 27e88dff82..47a46856b4 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.h +++ b/libraries/AP_IOMCU/AP_IOMCU.h @@ -69,7 +69,10 @@ public: // set default output rate void set_default_rate(uint16_t rate_hz); - + + // set to oneshot mode + void set_oneshot_mode(void); + private: AP_HAL::UARTDriver &uart;