Digital I/O interface. Main docs: https://pigweed.dev/pw_digital_io.
Typedefs | |
using | pw::digital_io::DigitalInOutMockImpl::State = ::pw::digital_io::State |
using | pw::digital_io::DigitalInOutMockImpl::Clock = ::pw::chrono::VirtualSystemClock |
Variables | |
pw::chrono::SystemClock::time_point | pw::digital_io::DigitalInOutMockImpl::Event::timestamp |
State | pw::digital_io::DigitalInOutMockImpl::Event::state |
|
inline |
Clears the interrupt handler and disables any existing interrupts that are enabled.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: The interrupt handler was cleared. * * Returns other status codes as defined by the backend. * *
|
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.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: The line is disabled. * * Returns other status codes as defined by the backend. * *
|
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.
embed:rst:leading-asterisk * * .. pw-status-codes:: * * OK: The interrupt handler was disabled. * * Returns other status codes as defined by the backend. * *
|
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.
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.
|
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.
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.
|
privatepure virtual |
Enables or disables interrupts which will trigger the interrupt handler.
DoSetInterruptHandler()
. 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.
|
finalprivatevirtual |
Enables or disables interrupts which will trigger the interrupt handler.
DoSetInterruptHandler()
. 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.
|
finalprivatevirtual |
Enables or disables interrupts which will trigger the interrupt handler.
DoSetInterruptHandler()
. 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.
|
finalprivatevirtual |
Enables or disables interrupts which will trigger the interrupt handler.
DoSetInterruptHandler()
. 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.
|
finalprivatevirtual |
Gets the state of the line.
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.
|
finalprivatevirtual |
Gets the state of the line.
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.
|
finalprivatevirtual |
Gets the state of the line.
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.
|
overrideprivatevirtual |
Gets the state of the line.
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.
|
privatepure virtual |
Gets the state of the line.
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.
|
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).
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.
|
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).
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.
|
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).
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.
|
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).
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.
|
privatepure virtual |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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.
|
overrideprivatevirtual |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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.
|
finalprivatevirtual |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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.
|
finalprivatevirtual |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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.
|
finalprivatevirtual |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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.
|
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.
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. * *
|
inline |
Enables interrupts which will trigger the interrupt handler.
SetInterruptHandler()
.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. * *
|
inline |
Gets the state of the line.
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. * *
|
inline |
Checks if the line is in the active state.
The line is in the active state when GetState()
returns State::kActive
.
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. * *
|
inlineconstexpr |
true
if input (getting state) is supported.
|
inlineconstexpr |
true
if interrupt handlers can be registered.
|
inlineconstexpr |
true
if output (setting state) is supported.
|
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.
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. * *
|
inline |
Sets the state of the line.
Callers are responsible to wait for the voltage level to settle after this call 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. * *
|
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.
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. * *
|
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.
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. * *