From 34521ea9d72066a02d4b562eb6d2dd628e424e58 Mon Sep 17 00:00:00 2001 From: Jonathon Reinhart Date: Wed, 8 Jan 2025 19:36:58 -0800 Subject: [PATCH] pw_digital_io_mcuxpresso: Introduce McuxpressoPintInterrupt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This class is essentially the same as McuxpressoDigitalInInterrupt but does not provide "In" functionality: It derives from DigitalInterrupt instead of DigitalInInterrupt. McuxpressoDigitalInInterrupt is now deprecated and will be removed. Bug: 337927184 Change-Id: I965b71d3af7d1f9fdd25dab8f2750f9908367f29 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/258994 Commit-Queue: Jonathon Reinhart Lint: Lint 🤖 Docs-Not-Needed: Jonathon Reinhart Presubmit-Verified: CQ Bot Account Reviewed-by: Austin Foxley --- pw_digital_io_mcuxpresso/interrupt_line.cc | 25 +++++++++++++++++++ .../pw_digital_io_mcuxpresso/interrupt_line.h | 23 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/pw_digital_io_mcuxpresso/interrupt_line.cc b/pw_digital_io_mcuxpresso/interrupt_line.cc index a4fc4d3118..498e455510 100644 --- a/pw_digital_io_mcuxpresso/interrupt_line.cc +++ b/pw_digital_io_mcuxpresso/interrupt_line.cc @@ -22,6 +22,31 @@ namespace pw::digital_io { +// McuxpressoPintInterrupt + +McuxpressoPintInterrupt::McuxpressoPintInterrupt( + pw::sync::Borrowable& controller, + pint_pin_int_t pin) + : controller_(controller), pin_(pin) {} + +pw::Status McuxpressoPintInterrupt::DoEnable(bool) { + // Can not enabled at individual line level. Only at controller level, which + // is always enabled. + return pw::OkStatus(); +} + +pw::Status McuxpressoPintInterrupt::DoSetInterruptHandler( + pw::digital_io::InterruptTrigger trigger, + pw::digital_io::InterruptHandler&& handler) { + return controller_.acquire()->Config(pin_, trigger, std::move(handler)); +} + +pw::Status McuxpressoPintInterrupt::DoEnableInterruptHandler(bool enable) { + return controller_.acquire()->EnableHandler(pin_, enable); +} + +// McuxpressoDigitalInInterrupt (deprecated) + McuxpressoDigitalInInterrupt::McuxpressoDigitalInInterrupt( pw::sync::Borrowable& controller, pint_pin_int_t pin) diff --git a/pw_digital_io_mcuxpresso/public/pw_digital_io_mcuxpresso/interrupt_line.h b/pw_digital_io_mcuxpresso/public/pw_digital_io_mcuxpresso/interrupt_line.h index 929c5497a2..2c91e9fca1 100644 --- a/pw_digital_io_mcuxpresso/public/pw_digital_io_mcuxpresso/interrupt_line.h +++ b/pw_digital_io_mcuxpresso/public/pw_digital_io_mcuxpresso/interrupt_line.h @@ -21,6 +21,29 @@ namespace pw::digital_io { +class McuxpressoPintInterrupt : public pw::digital_io::DigitalInterrupt { + public: + McuxpressoPintInterrupt( + pw::sync::Borrowable& controller, + pint_pin_int_t pin); + + McuxpressoPintInterrupt(const McuxpressoPintInterrupt&) = delete; + McuxpressoPintInterrupt& operator=(const McuxpressoPintInterrupt&) = delete; + + private: + // pw::digital_io::DigitalInterrupt implementation + pw::Status DoEnable(bool enable) override; + pw::Status DoSetInterruptHandler( + pw::digital_io::InterruptTrigger trigger, + pw::digital_io::InterruptHandler&& handler) override; + pw::Status DoEnableInterruptHandler(bool enable) override; + + pw::sync::Borrowable& controller_; + pint_pin_int_t pin_; +}; + +// Deprecated. Use McuxpressoPintInterrupt. +// TODO: https://pwbug.dev/337927184 - Remove after downstreams have migrated. class McuxpressoDigitalInInterrupt : public pw::digital_io::DigitalInInterrupt { public: McuxpressoDigitalInInterrupt(