A digital I/O line that may support input, output, and interrupts, but makes no guarantees about whether any operations are supported. You must check the various provides_*
flags before calling optional methods. Unsupported methods invoke PW_CRASH
.
All methods are potentially blocking. Unless otherwise specified, access from multiple threads to a single line must be externally synchronized - for example using pw::Borrowable
. Unless otherwise specified, none of the methods are safe to call from an interrupt handler. Therefore, this abstraction may not be suitable for bitbanging and other low-level uses of GPIO.
Note that the initial state of a line is not guaranteed to be consistent with either the "enabled" or "disabled" state. Users of the API who need to ensure the line is disabled (ex. output not driving the line) should call Disable()
.
This class should almost never be used in APIs directly. Instead, use one of the derived classes that explicitly supports the functionality that your API needs.
This class cannot be extended directly. Instead, extend one of the derived classes that explicitly support the functionality that you want to implement.
Public Member Functions | |
constexpr bool | provides_input () const |
constexpr bool | provides_output () const |
constexpr bool | provides_interrupt () const |
Result< State > | GetState () |
Status | SetState (State state) |
Result< bool > | IsStateActive () |
Status | SetStateActive () |
Status | SetStateInactive () |
Status | SetInterruptHandler (InterruptTrigger trigger, InterruptHandler &&handler) |
Status | ClearInterruptHandler () |
Status | EnableInterruptHandler () |
Status | DisableInterruptHandler () |
Status | Enable () |
Status | Disable () |
Private Member Functions | |
virtual Status | DoEnable (bool enable)=0 |
virtual Result< State > | DoGetState ()=0 |
virtual Status | DoSetState (State level)=0 |
virtual Status | DoSetInterruptHandler (InterruptTrigger trigger, InterruptHandler &&handler)=0 |
virtual Status | DoEnableInterruptHandler (bool enable)=0 |
Friends | |
class | DigitalInterrupt |
class | DigitalIn |
class | DigitalInInterrupt |
class | DigitalOut |
class | DigitalOutInterrupt |
class | DigitalInOut |
class | DigitalInOutInterrupt |