nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Member Functions
nrfcxx::gpio::generic_pin Class Reference

Class supporting a generic GPIO pin interface. More...

#include <nrfcxx/gpio.hpp>

Inheritance diagram for nrfcxx::gpio::generic_pin:
nrfcxx::board::iox_pin nrfcxx::gpio::gpio_pin

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.
 

Detailed Description

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.

Member Function Documentation

◆ configuration()

virtual unsigned int nrfcxx::gpio::generic_pin::configuration ( ) const
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.

◆ configure()

virtual void nrfcxx::gpio::generic_pin::configure ( unsigned int  pin_cnf)
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.

Parameters
pin_cnfa description of the desired pin configuration. This should

Reimplemented in nrfcxx::gpio::gpio_pin, and nrfcxx::board::iox_pin.

◆ valid()

virtual bool nrfcxx::gpio::generic_pin::valid ( ) const
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.


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