nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Member Functions | Static Public Member Functions | Data Fields
nrfcxx::gpio::pin_reference Class Reference

Generalized reference to a GPIO pin using a global psel ordinal. More...

#include <nrfcxx/gpio.hpp>

Public Member Functions

void set () const
 Set the pin to drive the output high.
 
void clear () const
 Set the pin to drive the output low.
 
void toggle () const
 Toggle the pin drive state.
 
uint32_t configuration () const
 Return the PIN_CNF entry for the pin, or zero if the reference is invalid.
 
void configure (uint32_t pin_cnf) const
 Set the PIN_CNF entry for the pin.
 
bool read () const
 Return the input signal observed at the pin, or zero if the reference is invalid.
 
bool is_set () const
 Return true iff the pin is valid and is configured to drive the output high.
 

Static Public Member Functions

static pin_reference create (int psel)
 Construct the instance for the given global ordinal GPIO pin. More...
 

Data Fields

uint8_t const global_psel
 The pin selector index across all GPIO instances.
 
uint8_t const local_psel
 The pin selector index within peripheral.
 
uint32_t const local_bit
 A mask isolating the local_psel bit within the value space of peripheral.
 
const nrf5::GPIO_Typeperipheral
 Reference to a valid GPIO peripheral wrapper. More...
 

Detailed Description

Generalized reference to a GPIO pin using a global psel ordinal.

This allows using psel values like 42 at runtime to identify the 10th GPIO on the second GPIO peripheral.

Warning
An attempt to create an instance for a psel that does not exist on the device will produce FailsafeCode::API_VIOLATION.

Member Function Documentation

◆ create()

static pin_reference nrfcxx::gpio::pin_reference::create ( int  psel)
static

Construct the instance for the given global ordinal GPIO pin.

Warning
An attempt to create an instance for a psel that does not exist on the device will produce FailSsafeCode::NO_SUCH_PERIPHERAL.
Parameters
psela valid pin index from 0 to nrf5::GPIO_PSEL_COUNT.
Returns
a GPIO pin reference.

Field Documentation

◆ peripheral

const nrf5::GPIO_Type& nrfcxx::gpio::pin_reference::peripheral

Reference to a valid GPIO peripheral wrapper.

This is the GPIO peripheral to which the pin belongs.


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