Pigweed
 
Loading...
Searching...
No Matches
pw::digital_io::DigitalOut Class Reference
Inheritance diagram for pw::digital_io::DigitalOut:
pw::digital_io::DigitalIoOptional pw::digital_io::McuxpressoDigitalOut

Public Member Functions

Status SetState (State state)
 
Status SetStateActive ()
 
Status SetStateInactive ()
 
- Public Member Functions inherited from pw::digital_io::DigitalIoOptional
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

Result< State > DoGetState () final
 
Status DoSetInterruptHandler (InterruptTrigger, InterruptHandler &&) final
 
Status DoEnableInterruptHandler (bool) final
 

Member Function Documentation

◆ DoEnableInterruptHandler()

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.

◆ DoGetState()

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.

◆ DoSetInterruptHandler()

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.

◆ 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.
* 
*  

The documentation for this class was generated from the following file: