From 9c0cf0871b3635640951624d39d8ad8fe8f89db9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jan 2020 13:21:54 +1100 Subject: [PATCH] HAL_ChibiOS: added disable() API for pulse input --- libraries/AP_HAL_ChibiOS/SoftSigReader.cpp | 6 ++++++ libraries/AP_HAL_ChibiOS/SoftSigReader.h | 1 + libraries/AP_HAL_ChibiOS/SoftSigReaderInt.cpp | 5 +++++ libraries/AP_HAL_ChibiOS/SoftSigReaderInt.h | 1 + 4 files changed, 13 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/SoftSigReader.cpp b/libraries/AP_HAL_ChibiOS/SoftSigReader.cpp index d13a41f0af..02550ed427 100644 --- a/libraries/AP_HAL_ChibiOS/SoftSigReader.cpp +++ b/libraries/AP_HAL_ChibiOS/SoftSigReader.cpp @@ -91,6 +91,12 @@ bool SoftSigReader::attach_capture_timer(ICUDriver* icu_drv, icuchannel_t chan, return true; } +void SoftSigReader::disable(void) +{ + icuStopCapture(_icu_drv); + dmaStreamDisable(dma); +} + void SoftSigReader::_irq_handler(void* self, uint32_t flags) { SoftSigReader* sig_reader = (SoftSigReader*)self; diff --git a/libraries/AP_HAL_ChibiOS/SoftSigReader.h b/libraries/AP_HAL_ChibiOS/SoftSigReader.h index 3727ae0683..e39ed24ec0 100644 --- a/libraries/AP_HAL_ChibiOS/SoftSigReader.h +++ b/libraries/AP_HAL_ChibiOS/SoftSigReader.h @@ -36,6 +36,7 @@ class ChibiOS::SoftSigReader { friend class ChibiOS::RCInput; public: bool attach_capture_timer(ICUDriver* icu_drv, icuchannel_t chan, uint8_t dma_stream, uint32_t dma_channel); + void disable(void); private: uint32_t *signal; diff --git a/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.cpp b/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.cpp index 3343766937..d757fee904 100644 --- a/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.cpp +++ b/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.cpp @@ -90,6 +90,11 @@ void SoftSigReaderInt::init(EICUDriver* icu_drv, eicuchannel_t chan) eicuEnable(_icu_drv); } +void SoftSigReaderInt::disable(void) +{ + eicuDisable(_icu_drv); +} + void SoftSigReaderInt::_irq_handler(EICUDriver *eicup, eicuchannel_t aux_channel) { eicuchannel_t channel = get_pair_channel(aux_channel); diff --git a/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.h b/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.h index 7f982a49d3..567f57d32b 100644 --- a/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.h +++ b/libraries/AP_HAL_ChibiOS/SoftSigReaderInt.h @@ -42,6 +42,7 @@ public: void init(EICUDriver* icu_drv, eicuchannel_t chan); bool read(uint32_t &widths0, uint32_t &widths1); + void disable(void); private: // singleton static SoftSigReaderInt *_singleton;