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

Oveview

Digital I/O for NXP MCUXpresso. Main docs: https://pigweed.dev/pw_digital_io_mcuxpresso.

Classes

class  pw::digital_io::McuxpressoDigitalOut
 
class  pw::digital_io::McuxpressoDigitalIn
 
class  pw::digital_io::McuxpressoDigitalInOutInterrupt
 
class  pw::digital_io::McuxpressoPintController
 
class  pw::digital_io::McuxpressoPintInterrupt
 

Functions

PW_EXTERN_C void pw::digital_io::GPIO_INTA_DriverIRQHandler ()
 
 pw::digital_io::McuxpressoDigitalOut::McuxpressoDigitalOut (GPIO_Type *base, uint32_t port, uint32_t pin, pw::digital_io::State initial_state)
 
bool pw::digital_io::McuxpressoDigitalOut::is_enabled () const
 Returns true if the output is enabled.
 
pw::Status pw::digital_io::McuxpressoDigitalOut::DoEnable (bool enable) override
 
pw::Status pw::digital_io::McuxpressoDigitalOut::DoSetState (pw::digital_io::State state) override
 
 pw::digital_io::McuxpressoDigitalIn::McuxpressoDigitalIn (GPIO_Type *base, uint32_t port, uint32_t pin)
 
bool pw::digital_io::McuxpressoDigitalIn::is_enabled () const
 Returns true if the input is enabled.
 
pw::Status pw::digital_io::McuxpressoDigitalIn::DoEnable (bool enable) override
 
pw::Result< pw::digital_io::State > pw::digital_io::McuxpressoDigitalIn::DoGetState () override
 
 pw::digital_io::McuxpressoDigitalInOutInterrupt::McuxpressoDigitalInOutInterrupt (GPIO_Type *base, uint32_t port, uint32_t pin, bool output)
 
bool pw::digital_io::McuxpressoDigitalInOutInterrupt::is_enabled () const
 Returns true if the line is enabled (in any state).
 
pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoEnable (bool enable) override
 
pw::Result< pw::digital_io::State > pw::digital_io::McuxpressoDigitalInOutInterrupt::DoGetState () override
 
pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoSetState (pw::digital_io::State state) override
 
pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoSetInterruptHandler (pw::digital_io::InterruptTrigger trigger, pw::digital_io::InterruptHandler &&handler) override
 
pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoEnableInterruptHandler (bool enable) override
 
 pw::digital_io::McuxpressoPintController::McuxpressoPintController (PINT_Type *base)
 
 pw::digital_io::McuxpressoPintController::McuxpressoPintController (const McuxpressoPintController &)=delete
 
McuxpressoPintControllerpw::digital_io::McuxpressoPintController::operator= (const McuxpressoPintController &)=delete
 
 pw::digital_io::McuxpressoPintInterrupt::McuxpressoPintInterrupt (pw::sync::Borrowable< McuxpressoPintController > &controller, pint_pin_int_t pin)
 
 pw::digital_io::McuxpressoPintInterrupt::McuxpressoPintInterrupt (const McuxpressoPintInterrupt &)=delete
 
McuxpressoPintInterruptpw::digital_io::McuxpressoPintInterrupt::operator= (const McuxpressoPintInterrupt &)=delete
 
pw::Status pw::digital_io::McuxpressoPintInterrupt::DoEnable (bool enable) override
 
pw::Status pw::digital_io::McuxpressoPintInterrupt::DoSetInterruptHandler (pw::digital_io::InterruptTrigger trigger, pw::digital_io::InterruptHandler &&handler) override
 
pw::Status pw::digital_io::McuxpressoPintInterrupt::DoEnableInterruptHandler (bool enable) override
 

Friends

class pw::digital_io::McuxpressoPintController::McuxpressoPintInterrupt
 
void pw::digital_io::McuxpressoDigitalInOutInterrupt::GPIO_INTA_DriverIRQHandler ()
 

Function Documentation

◆ DoEnable() [1/4]

pw::Status pw::digital_io::McuxpressoDigitalOut::DoEnable ( bool  enable)
overrideprivatevirtual

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.

◆ DoEnable() [2/4]

pw::Status pw::digital_io::McuxpressoDigitalIn::DoEnable ( bool  enable)
overrideprivatevirtual

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.

◆ DoEnable() [3/4]

pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoEnable ( bool  enable)
overrideprivatevirtual

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.

◆ DoEnable() [4/4]

pw::Status pw::digital_io::McuxpressoPintInterrupt::DoEnable ( bool  enable)
overrideprivatevirtual

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/2]

pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoEnableInterruptHandler ( bool  enable)
overrideprivatevirtual

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() [2/2]

pw::Status pw::digital_io::McuxpressoPintInterrupt::DoEnableInterruptHandler ( bool  enable)
overrideprivatevirtual

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/2]

pw::Result< pw::digital_io::State > pw::digital_io::McuxpressoDigitalIn::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() [2/2]

pw::Result< pw::digital_io::State > pw::digital_io::McuxpressoDigitalInOutInterrupt::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.

◆ DoSetInterruptHandler() [1/2]

pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoSetInterruptHandler ( pw::digital_io::InterruptTrigger  trigger,
pw::digital_io::InterruptHandler &&  handler 
)
overrideprivatevirtual

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() [2/2]

pw::Status pw::digital_io::McuxpressoPintInterrupt::DoSetInterruptHandler ( pw::digital_io::InterruptTrigger  trigger,
pw::digital_io::InterruptHandler &&  handler 
)
overrideprivatevirtual

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/2]

pw::Status pw::digital_io::McuxpressoDigitalOut::DoSetState ( pw::digital_io::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() [2/2]

pw::Status pw::digital_io::McuxpressoDigitalInOutInterrupt::DoSetState ( pw::digital_io::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.

◆ McuxpressoDigitalIn()

pw::digital_io::McuxpressoDigitalIn::McuxpressoDigitalIn ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin 
)

Constructs a McuxpressoDigitalIn for a specific GPIO module+port+pin.

Parameters
[in]baseThe base address of the GPIO module (e.g. GPIO).
[in]portThe port number on the given GPIO module.
[in]pinThe pin number on the given GPIO port.

◆ McuxpressoDigitalInOutInterrupt()

pw::digital_io::McuxpressoDigitalInOutInterrupt::McuxpressoDigitalInOutInterrupt ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin,
bool  output 
)

Constructs a McuxpressoDigitalInOutInterrupt for a specific GPIO module+port+pin.

Parameters
[in]baseThe base address of the GPIO module (e.g. GPIO).
[in]portThe port number on the given GPIO module.
[in]pinThe pin number on the given GPIO port.
[in]outputTrue if the line should be configured as an output on enable; False if it should be an input.

◆ McuxpressoDigitalOut()

pw::digital_io::McuxpressoDigitalOut::McuxpressoDigitalOut ( GPIO_Type *  base,
uint32_t  port,
uint32_t  pin,
pw::digital_io::State  initial_state 
)

Constructs a McuxpressoDigitalOut for a specific GPIO module+port+pin.

Parameters
[in]baseThe base address of the GPIO module (e.g. GPIO).
[in]portThe port number on the given GPIO module.
[in]pinThe pin number on the given GPIO port.
[in]initial_stateThe state to be driven when the line is enabled.

◆ McuxpressoPintController()

pw::digital_io::McuxpressoPintController::McuxpressoPintController ( PINT_Type *  base)

Constructs a McuxpressoPintController for an instance of the PINT module.

Parameters
[in]baseThe base address of the PINT module (e.g. PINT).

◆ McuxpressoPintInterrupt()

pw::digital_io::McuxpressoPintInterrupt::McuxpressoPintInterrupt ( pw::sync::Borrowable< McuxpressoPintController > &  controller,
pint_pin_int_t  pin 
)

Constructs a McuxpressoPintInterrupt for a specific pin.

Parameters
[in]controllerA pw::sync::Borrowable reference to the McuxpressoPintInterrupt representing the PINT module.
[in]pinThe pint_pin_int_t enum member identifying the pin interrupt on the PINT module.