nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
Class supporting a generic GPIO pin interface. More...
#include <nrfcxx/gpio.hpp>
Public Member Functions | |
virtual bool | valid () const |
Indicate whether the pin is functional. More... | |
virtual void | set () |
Set the pin to drive the output high. | |
virtual void | clear () |
Set the pin to drive the output low. | |
virtual void | toggle () |
Toggle the pin drive state. | |
virtual void | configure (unsigned int pin_cnf) |
Set the PIN_CNF entry for the pin if the reference is valid. More... | |
virtual unsigned int | configuration () const |
Return implementation-specific information about the pin configuration. More... | |
virtual bool | read () const |
Return the input signal observed at the pin, or zero if the reference is invalid. | |
virtual bool | is_set () const |
Return true iff the pin is valid and is configured to drive the output high. | |
Class supporting a generic GPIO pin interface.
The pin_reference class requires a valid GPIO pin, making it unsuitable for applications where a signal may not be connected on the board (e.g. where RESETn
is pulled high in hardware).
This class provides a generic API for pins, and does nothing in the base class. Subclasses can be implemented that delegate to a pin_reference instance, or to an external GPIO extender, allowing a common API in re-usable code without assumptions about hardware configuration.
|
inlinevirtual |
Return implementation-specific information about the pin configuration.
Values should be as with pin_cnf
in configure().
Reimplemented in nrfcxx::gpio::gpio_pin, and nrfcxx::board::iox_pin.
|
inlinevirtual |
Set the PIN_CNF
entry for the pin if the reference is valid.
This API should always use the standard bit encoding of DIR, INPUT, PULL, DRIVE, and SENSE of Nordic nRF5 GPIO peripherals, even if the underlying implementation is a non-Nordic system.
Subclasses should provide access to any contained instance of a non-Nordic pin reference if the providing implementation requires configuration that is not supported in the Nordic GPIO bit encoding.
pin_cnf | a description of the desired pin configuration. This should |
Reimplemented in nrfcxx::gpio::gpio_pin, and nrfcxx::board::iox_pin.
|
inlinevirtual |
Indicate whether the pin is functional.
Base class returns false
. Subclasses should override to return true
in cases where invoking the other methods provides or affects pin state.
Reimplemented in nrfcxx::gpio::gpio_pin, and nrfcxx::board::iox_pin.