Skip to content

Commit

Permalink
pw_digital_io: Remove conditional interrupt disabling requirements
Browse files Browse the repository at this point in the history
Removes conditional interrupt handler disabling requirements from the
DoEnable and DoSetInterruptHandler private virtual APIs for
concrete implementations. Instead the NVI API first calls
DisableInterruptHandler (or DoEnableInterruptHandler(false)) to
simplify implementations and their requirements.

Change-Id: Ie1855d13f7e1ea688305c5b750c5391ce7e72471
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/187668
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Ewout van Bekkum <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
Reviewed-by: Anton Markov <[email protected]>
  • Loading branch information
Ewout van Bekkum authored and CQ Bot Account committed Jan 13, 2024
1 parent aadaf20 commit ed3b51b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pw_digital_io/public/pw_digital_io/digital_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class DigitalIoOptional {
/// * @pw_status{OK} - The interrupt handler was cleared.
/// * Other status codes as defined by the backend.
Status ClearInterruptHandler() {
PW_TRY(DisableInterruptHandler());
return DoSetInterruptHandler(InterruptTrigger::kActivatingEdge, nullptr);
}

Expand Down Expand Up @@ -246,7 +247,12 @@ class DigitalIoOptional {
/// @returns
/// * @pw_status{OK} - The line is disabled.
/// * Other status codes as defined by the backend.
Status Disable() { return DoEnable(false); }
Status Disable() {
if (provides_interrupt()) {
PW_TRY(DisableInterruptHandler());
}
return DoEnable(false);
}

private:
friend class DigitalInterrupt;
Expand Down

0 comments on commit ed3b51b

Please sign in to comment.