Pigweed
 
Loading...
Searching...
No Matches
pw::digital_io::DigitalInterrupt Class Reference
Inheritance diagram for pw::digital_io::DigitalInterrupt:
pw::digital_io::DigitalIoOptional pw::digital_io::McuxpressoPintInterrupt

Public Member Functions

Status ClearInterruptHandler ()
 
Status DisableInterruptHandler ()
 
Status EnableInterruptHandler ()
 
Status SetInterruptHandler (InterruptTrigger trigger, InterruptHandler &&handler)
 
- 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

Status DoSetState (State) final
 
Result< State > DoGetState () final
 

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

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

◆ DoGetState()

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.

◆ DoSetState()

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.

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

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

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