C/C++ API Reference
Loading...
Searching...
No Matches
pw_digital_io

Oveview

Digital I/O interface. Main docs: https://pigweed.dev/pw_digital_io.

Classes

class  pw::digital_io::DigitalIoOptional
 
class  pw::digital_io::DigitalInterrupt
 
class  pw::digital_io::DigitalIn
 
class  pw::digital_io::DigitalInInterrupt
 
class  pw::digital_io::DigitalOut
 
class  pw::digital_io::DigitalOutInterrupt
 
class  pw::digital_io::DigitalInOut
 
class  pw::digital_io::DigitalInOutInterrupt
 
class  pw::digital_io::DigitalInOutMockImpl
 
struct  pw::digital_io::DigitalInOutMockImpl::Event
 
class  pw::digital_io::DigitalInOutMock< kCapacity >
 

Typedefs

using pw::digital_io::DigitalInOutMockImpl::State = ::pw::digital_io::State
 
using pw::digital_io::DigitalInOutMockImpl::Clock = ::pw::chrono::VirtualSystemClock
 

Functions

constexpr bool pw::digital_io::DigitalIoOptional::provides_input () const
 
constexpr bool pw::digital_io::DigitalIoOptional::provides_output () const
 
constexpr bool pw::digital_io::DigitalIoOptional::provides_interrupt () const
 
Result< State > pw::digital_io::DigitalIoOptional::GetState ()
 
Status pw::digital_io::DigitalIoOptional::SetState (State state)
 
Result< bool > pw::digital_io::DigitalIoOptional::IsStateActive ()
 
Status pw::digital_io::DigitalIoOptional::SetStateActive ()
 
Status pw::digital_io::DigitalIoOptional::SetStateInactive ()
 
Status pw::digital_io::DigitalIoOptional::SetInterruptHandler (InterruptTrigger trigger, InterruptHandler &&handler)
 
Status pw::digital_io::DigitalIoOptional::ClearInterruptHandler ()
 
Status pw::digital_io::DigitalIoOptional::EnableInterruptHandler ()
 
Status pw::digital_io::DigitalIoOptional::DisableInterruptHandler ()
 
Status pw::digital_io::DigitalIoOptional::Enable ()
 
Status pw::digital_io::DigitalIoOptional::Disable ()
 
virtual Status pw::digital_io::DigitalIoOptional::DoEnable (bool enable)=0
 
virtual Result< State > pw::digital_io::DigitalIoOptional::DoGetState ()=0
 
virtual Status pw::digital_io::DigitalIoOptional::DoSetState (State level)=0
 
virtual Status pw::digital_io::DigitalIoOptional::DoSetInterruptHandler (InterruptTrigger trigger, InterruptHandler &&handler)=0
 
virtual Status pw::digital_io::DigitalIoOptional::DoEnableInterruptHandler (bool enable)=0
 
Status pw::digital_io::DigitalInterrupt::DoSetState (State) final
 
Result< State > pw::digital_io::DigitalInterrupt::DoGetState () final
 
Status pw::digital_io::DigitalIn::DoSetState (State) final
 
Status pw::digital_io::DigitalIn::DoSetInterruptHandler (InterruptTrigger, InterruptHandler &&) final
 
Status pw::digital_io::DigitalIn::DoEnableInterruptHandler (bool) final
 
Status pw::digital_io::DigitalInInterrupt::DoSetState (State) final
 
Result< State > pw::digital_io::DigitalOut::DoGetState () final
 
Status pw::digital_io::DigitalOut::DoSetInterruptHandler (InterruptTrigger, InterruptHandler &&) final
 
Status pw::digital_io::DigitalOut::DoEnableInterruptHandler (bool) final
 
Result< State > pw::digital_io::DigitalOutInterrupt::DoGetState () final
 
Status pw::digital_io::DigitalInOut::DoSetInterruptHandler (InterruptTrigger, InterruptHandler &&) final
 
Status pw::digital_io::DigitalInOut::DoEnableInterruptHandler (bool) final
 
pw::InlineDeque< Event > & pw::digital_io::DigitalInOutMockImpl::events ()
 
 pw::digital_io::DigitalInOutMockImpl::DigitalInOutMockImpl (Clock &clock, pw::InlineDeque< Event > &events)
 
pw::Status pw::digital_io::DigitalInOutMockImpl::DoEnable (bool) override
 
pw::Result< State > pw::digital_io::DigitalInOutMockImpl::DoGetState () override
 
pw::Status pw::digital_io::DigitalInOutMockImpl::DoSetState (State state) override
 
 pw::digital_io::DigitalInOutMock< kCapacity >::DigitalInOutMock (Clock &clock)
 

Variables

pw::chrono::SystemClock::time_point pw::digital_io::DigitalInOutMockImpl::Event::timestamp
 
State pw::digital_io::DigitalInOutMockImpl::Event::state
 

Friends

class pw::digital_io::DigitalIoOptional::DigitalInterrupt
 
class pw::digital_io::DigitalIoOptional::DigitalIn
 
class pw::digital_io::DigitalIoOptional::DigitalInInterrupt
 
class pw::digital_io::DigitalIoOptional::DigitalOut
 
class pw::digital_io::DigitalIoOptional::DigitalOutInterrupt
 
class pw::digital_io::DigitalIoOptional::DigitalInOut
 
class pw::digital_io::DigitalIoOptional::DigitalInOutInterrupt
 

Function Documentation

◆ ClearInterruptHandler()

Status pw::digital_io::DigitalIoOptional::ClearInterruptHandler ( )
inline

Clears the interrupt handler and disables any existing interrupts that are enabled.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was cleared.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ Disable()

Status pw::digital_io::DigitalIoOptional::Disable ( )
inline

Disables the line to power down any pull-up/down resistors and disconnect from any voltage sources.

This is usually done to save power. Interrupt handlers are automatically disabled.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The line is disabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ DisableInterruptHandler()

Status pw::digital_io::DigitalIoOptional::DisableInterruptHandler ( )
inline

Disables the interrupt handler. This is a no-op if interrupts are disabled.

This method can be called inside the interrupt handler for this line without any external synchronization. However, the exact behavior is backend-specific. There may be queued events that will trigger the handler again after this call returns.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was disabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ DoEnable() [1/2]

virtual Status pw::digital_io::DigitalIoOptional::DoEnable ( bool  enable)
privatepure virtual

Enables the line to initialize it into the default state as determined by the backend or disables the line to power down any pull-up/down resistors and disconnect from any voltage sources.

This may enable pull-up/down resistors, drive the line high/low, etc. The line must be enabled before getting/setting the state or enabling interrupts. Callers are responsible for waiting for the voltage level to settle after this call returns.

Calling DoEnable(true) on an already-enabled line should be a no-op, it shouldn't reset the line back to the "default state".

Calling DoEnable(false) should force the line into the disabled state, If the line was not initialized at object construction time.

Precondition
This method cannot be used in interrupt contexts.
When disabling, the interrupt handler must already be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The line is enabled and ready for use.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implemented in pw::digital_io::McuxpressoDigitalOut, pw::digital_io::McuxpressoDigitalIn, pw::digital_io::McuxpressoDigitalInOutInterrupt, pw::digital_io::McuxpressoPintInterrupt, and pw::digital_io::DigitalInOutMockImpl.

◆ DoEnable() [2/2]

pw::Status pw::digital_io::DigitalInOutMockImpl::DoEnable ( bool  enable)
inlineoverrideprivatevirtual

Enables the line to initialize it into the default state as determined by the backend or disables the line to power down any pull-up/down resistors and disconnect from any voltage sources.

This may enable pull-up/down resistors, drive the line high/low, etc. The line must be enabled before getting/setting the state or enabling interrupts. Callers are responsible for waiting for the voltage level to settle after this call returns.

Calling DoEnable(true) on an already-enabled line should be a no-op, it shouldn't reset the line back to the "default state".

Calling DoEnable(false) should force the line into the disabled state, If the line was not initialized at object construction time.

Precondition
This method cannot be used in interrupt contexts.
When disabling, the interrupt handler must already be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The line is enabled and ready for use.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoEnableInterruptHandler() [1/4]

virtual Status pw::digital_io::DigitalIoOptional::DoEnableInterruptHandler ( bool  enable)
privatepure virtual

Enables or disables interrupts which will trigger the interrupt handler.

Warning
This interrupt handler disabling must be both thread-safe and, interrupt-safe, however enabling is not interrupt-safe and not thread-safe.
Precondition
When enabling, a handler must have been set using DoSetInterruptHandler().
Interrupt handler enabling cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implemented in pw::digital_io::McuxpressoDigitalInOutInterrupt, pw::digital_io::McuxpressoPintInterrupt, pw::digital_io::DigitalIn, pw::digital_io::DigitalOut, and pw::digital_io::DigitalInOut.

◆ DoEnableInterruptHandler() [2/4]

Status pw::digital_io::DigitalIn::DoEnableInterruptHandler ( bool  enable)
finalprivatevirtual

Enables or disables interrupts which will trigger the interrupt handler.

Warning
This interrupt handler disabling must be both thread-safe and, interrupt-safe, however enabling is not interrupt-safe and not thread-safe.
Precondition
When enabling, a handler must have been set using DoSetInterruptHandler().
Interrupt handler enabling cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoEnableInterruptHandler() [3/4]

Status pw::digital_io::DigitalOut::DoEnableInterruptHandler ( bool  enable)
finalprivatevirtual

Enables or disables interrupts which will trigger the interrupt handler.

Warning
This interrupt handler disabling must be both thread-safe and, interrupt-safe, however enabling is not interrupt-safe and not thread-safe.
Precondition
When enabling, a handler must have been set using DoSetInterruptHandler().
Interrupt handler enabling cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoEnableInterruptHandler() [4/4]

Status pw::digital_io::DigitalInOut::DoEnableInterruptHandler ( bool  enable)
finalprivatevirtual

Enables or disables interrupts which will trigger the interrupt handler.

Warning
This interrupt handler disabling must be both thread-safe and, interrupt-safe, however enabling is not interrupt-safe and not thread-safe.
Precondition
When enabling, a handler must have been set using DoSetInterruptHandler().
Interrupt handler enabling cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoGetState() [1/5]

Result< State > pw::digital_io::DigitalInterrupt::DoGetState ( )
finalprivatevirtual

Gets the state of the line.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: An active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoGetState() [2/5]

Result< State > pw::digital_io::DigitalOut::DoGetState ( )
finalprivatevirtual

Gets the state of the line.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: An active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoGetState() [3/5]

Result< State > pw::digital_io::DigitalOutInterrupt::DoGetState ( )
finalprivatevirtual

Gets the state of the line.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: An active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoGetState() [4/5]

pw::Result< State > pw::digital_io::DigitalInOutMockImpl::DoGetState ( )
overrideprivatevirtual

Gets the state of the line.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: An active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoGetState() [5/5]

virtual Result< State > pw::digital_io::DigitalIoOptional::DoGetState ( )
privatepure virtual

Gets the state of the line.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: An active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implemented in pw::digital_io::DigitalInterrupt, pw::digital_io::DigitalOut, pw::digital_io::DigitalOutInterrupt, pw::digital_io::DigitalInOutMockImpl, pw::digital_io::McuxpressoDigitalIn, and pw::digital_io::McuxpressoDigitalInOutInterrupt.

◆ DoSetInterruptHandler() [1/4]

virtual Status pw::digital_io::DigitalIoOptional::DoSetInterruptHandler ( InterruptTrigger  trigger,
InterruptHandler &&  handler 
)
privatepure virtual

Sets or clears an interrupt handler to execute when an interrupt is triggered, and configures the condition for triggering the interrupt.

The handler is executed in a backend-specific context—this may be a system interrupt handler or a shared notification thread.

The implementation is expected to provide the handler the last known state of the input. The intention is to either sample the current state and provide that or if not possible provide the state which triggerred the interrupt (e.g. active for activating edge, and inactive for deactivating edge).

The handler is cleared by passing an empty handler, this can be checked by comparing the handler to a nullptr. The implementation must guarantee that the handler is not currently executing and (and will never execute again) after returning from DoSetInterruptHandler(_, nullptr).

Precondition
This method cannot be used in interrupt contexts.
If setting a handler, no handler is permitted to be currently set.
When cleaing a handler, the interrupt handler must be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implemented in pw::digital_io::DigitalIn, pw::digital_io::DigitalOut, pw::digital_io::DigitalInOut, pw::digital_io::McuxpressoDigitalInOutInterrupt, and pw::digital_io::McuxpressoPintInterrupt.

◆ DoSetInterruptHandler() [2/4]

Status pw::digital_io::DigitalIn::DoSetInterruptHandler ( InterruptTrigger  trigger,
InterruptHandler &&  handler 
)
finalprivatevirtual

Sets or clears an interrupt handler to execute when an interrupt is triggered, and configures the condition for triggering the interrupt.

The handler is executed in a backend-specific context—this may be a system interrupt handler or a shared notification thread.

The implementation is expected to provide the handler the last known state of the input. The intention is to either sample the current state and provide that or if not possible provide the state which triggerred the interrupt (e.g. active for activating edge, and inactive for deactivating edge).

The handler is cleared by passing an empty handler, this can be checked by comparing the handler to a nullptr. The implementation must guarantee that the handler is not currently executing and (and will never execute again) after returning from DoSetInterruptHandler(_, nullptr).

Precondition
This method cannot be used in interrupt contexts.
If setting a handler, no handler is permitted to be currently set.
When cleaing a handler, the interrupt handler must be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetInterruptHandler() [3/4]

Status pw::digital_io::DigitalOut::DoSetInterruptHandler ( InterruptTrigger  trigger,
InterruptHandler &&  handler 
)
finalprivatevirtual

Sets or clears an interrupt handler to execute when an interrupt is triggered, and configures the condition for triggering the interrupt.

The handler is executed in a backend-specific context—this may be a system interrupt handler or a shared notification thread.

The implementation is expected to provide the handler the last known state of the input. The intention is to either sample the current state and provide that or if not possible provide the state which triggerred the interrupt (e.g. active for activating edge, and inactive for deactivating edge).

The handler is cleared by passing an empty handler, this can be checked by comparing the handler to a nullptr. The implementation must guarantee that the handler is not currently executing and (and will never execute again) after returning from DoSetInterruptHandler(_, nullptr).

Precondition
This method cannot be used in interrupt contexts.
If setting a handler, no handler is permitted to be currently set.
When cleaing a handler, the interrupt handler must be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetInterruptHandler() [4/4]

Status pw::digital_io::DigitalInOut::DoSetInterruptHandler ( InterruptTrigger  trigger,
InterruptHandler &&  handler 
)
finalprivatevirtual

Sets or clears an interrupt handler to execute when an interrupt is triggered, and configures the condition for triggering the interrupt.

The handler is executed in a backend-specific context—this may be a system interrupt handler or a shared notification thread.

The implementation is expected to provide the handler the last known state of the input. The intention is to either sample the current state and provide that or if not possible provide the state which triggerred the interrupt (e.g. active for activating edge, and inactive for deactivating edge).

The handler is cleared by passing an empty handler, this can be checked by comparing the handler to a nullptr. The implementation must guarantee that the handler is not currently executing and (and will never execute again) after returning from DoSetInterruptHandler(_, nullptr).

Precondition
This method cannot be used in interrupt contexts.
If setting a handler, no handler is permitted to be currently set.
When cleaing a handler, the interrupt handler must be disabled.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetState() [1/5]

virtual Status pw::digital_io::DigitalIoOptional::DoSetState ( State  level)
privatepure virtual

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implemented in pw::digital_io::McuxpressoDigitalOut, pw::digital_io::McuxpressoDigitalInOutInterrupt, pw::digital_io::DigitalInOutMockImpl, pw::digital_io::DigitalInterrupt, pw::digital_io::DigitalIn, and pw::digital_io::DigitalInInterrupt.

◆ DoSetState() [2/5]

pw::Status pw::digital_io::DigitalInOutMockImpl::DoSetState ( State  level)
overrideprivatevirtual

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetState() [3/5]

Status pw::digital_io::DigitalInterrupt::DoSetState ( State  level)
finalprivatevirtual

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetState() [4/5]

Status pw::digital_io::DigitalIn::DoSetState ( State  level)
finalprivatevirtual

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ DoSetState() [5/5]

Status pw::digital_io::DigitalInInterrupt::DoSetState ( State  level)
finalprivatevirtual

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Precondition
This method cannot be used in interrupt contexts.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

Implements pw::digital_io::DigitalIoOptional.

◆ Enable()

Status pw::digital_io::DigitalIoOptional::Enable ( )
inline

Enables the line to initialize it into the default state as determined by the backend.

This may enable pull-up/down resistors, drive the line high/low, etc. The line must be enabled before getting/setting the state or enabling interrupts. Callers are responsible for waiting for the voltage level to settle after this call returns.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The line is enabled and ready for use.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ EnableInterruptHandler()

Status pw::digital_io::DigitalIoOptional::EnableInterruptHandler ( )
inline

Enables interrupts which will trigger the interrupt handler.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Precondition
A handler has been set using SetInterruptHandler().
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ GetState()

Result< State > pw::digital_io::DigitalIoOptional::GetState ( )
inline

Gets the state of the line.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: Returns an active or inactive state.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns Other status codes as defined by the backend.
* 
*  

◆ IsStateActive()

Result< bool > pw::digital_io::DigitalIoOptional::IsStateActive ( )
inline

Checks if the line is in the active state.

The line is in the active state when GetState() returns State::kActive.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: ``true`` if the line is in the active state, otherwise ``false``.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ provides_input()

constexpr bool pw::digital_io::DigitalIoOptional::provides_input ( ) const
inlineconstexpr
Returns
true if input (getting state) is supported.

◆ provides_interrupt()

constexpr bool pw::digital_io::DigitalIoOptional::provides_interrupt ( ) const
inlineconstexpr
Returns
true if interrupt handlers can be registered.

◆ provides_output()

constexpr bool pw::digital_io::DigitalIoOptional::provides_output ( ) const
inlineconstexpr
Returns
true if output (setting state) is supported.

◆ SetInterruptHandler()

Status pw::digital_io::DigitalIoOptional::SetInterruptHandler ( InterruptTrigger  trigger,
InterruptHandler &&  handler 
)
inline

Sets an interrupt handler to execute when an interrupt is triggered, and configures the condition for triggering the interrupt.

The handler is executed in a backend-specific context—this may be a system interrupt handler or a shared notification thread. Do not do any blocking or expensive work in the handler. The only universally safe operations are the IRQ-safe functions on pw_sync primitives.

In particular, it is NOT safe to get the state of a DigitalIo line—either from this line or any other DigitalIoOptional instance—inside the handler.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Precondition
No handler is currently set.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The interrupt handler was configured.
* 
*     INVALID_ARGUMENT: The handler is empty.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ SetState()

Status pw::digital_io::DigitalIoOptional::SetState ( State  state)
inline

Sets the state of the line.

Callers are responsible to wait for the voltage level to settle after this call returns.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ SetStateActive()

Status pw::digital_io::DigitalIoOptional::SetStateActive ( )
inline

Sets the line to the active state. Equivalent to SetState(State::kActive).

Callers are responsible to wait for the voltage level to settle after this call returns.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*  

◆ SetStateInactive()

Status pw::digital_io::DigitalIoOptional::SetStateInactive ( )
inline

Sets the line to the inactive state. Equivalent to SetState(State::kInactive).

Callers are responsible to wait for the voltage level to settle after this call returns.

Warning
This method is not thread-safe and cannot be used in interrupt handlers.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The state has been set.
* 
*     FAILED_PRECONDITION: The line has not been enabled.
* 
*  Returns other status codes as defined by the backend.
* 
*