Skip to content

Commit

Permalink
pw_digital_io_mcuxpresso: Introduce McuxpressoPintInterrupt
Browse files Browse the repository at this point in the history
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 <[email protected]>
Lint: Lint 🤖 <[email protected]>
Docs-Not-Needed: Jonathon Reinhart <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Reviewed-by: Austin Foxley <[email protected]>
  • Loading branch information
JonathonReinhart authored and CQ Bot Account committed Jan 9, 2025
1 parent 3085c62 commit 34521ea
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pw_digital_io_mcuxpresso/interrupt_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@

namespace pw::digital_io {

// McuxpressoPintInterrupt

McuxpressoPintInterrupt::McuxpressoPintInterrupt(
pw::sync::Borrowable<McuxpressoInterruptController>& 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<McuxpressoInterruptController>& controller,
pint_pin_int_t pin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@

namespace pw::digital_io {

class McuxpressoPintInterrupt : public pw::digital_io::DigitalInterrupt {
public:
McuxpressoPintInterrupt(
pw::sync::Borrowable<McuxpressoInterruptController>& 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<McuxpressoInterruptController>& 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(
Expand Down

0 comments on commit 34521ea

Please sign in to comment.