nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Types | Public Member Functions | Data Fields | Static Public Attributes
nrfcxx::nrf5::peripheral< S > Struct Template Reference

Capture information about an nRF5 peripheral instance. More...

#include <nrfcxx/core.hpp>

Public Types

using Type = S
 The structure describing the instance content, such as NRF_GPIO_Type or NRF_UART_Type.
 

Public Member Functions

constexpr peripheral (uintptr_t base, int8_t irqn=NO_IRQ, uint8_t instance=NO_INSTANCE, uint8_t aux=0)
 Create an object referencing a peripheral instance. More...
 
Typeinstance () const
 Get a type-correct pointer to the peripheral structure.
 
Typeoperator-> () const
 Allow dereferencing the instance as though it were a pointer to the peripheral structure.
 

Data Fields

const uintptr_t BASE
 The address of the instance.
 
const int8_t IRQn
 The interrupt number associated with the instance, or negative if the instance has no dedicated interrupt. More...
 
const uint8_t INSTANCE
 The peripheral instance, for peripherals like TIMER that have multiple instances. More...
 
const uint8_t AUX
 Auxiliary information relevant to the specific peripheral and type. More...
 

Static Public Attributes

static constexpr int8_t NO_IRQ = -128
 Flag value for IRQn indicating that the peripheral does not have an assign interrupt vector entry.
 
static constexpr uint8_t NO_INSTANCE = 255
 Flag value for INSTANCE indicating that the peripheral does not have enumerated instances (e.g. More...
 

Detailed Description

template<typename S>
struct nrfcxx::nrf5::peripheral< S >

Capture information about an nRF5 peripheral instance.

All instances of this clas, provided by the series-specific extension included through <nrfcxx/core.hpp>, are static constexpr so with standard optimization there is no data object taking up space and requiring memory access to get the peripheral address. An exception is for material in nrfcxx::periph where an abstraction object must capture the underlying peripheral instance by reference. The instances in different modules are at different addresses, but have identical content, so detecting whether a specific peripheral instance is used should be done by comparing the BASE field.

Template Parameters
Sthe type describing the peripheral structure, e.g. NRF_GPIO_Type.

Constructor & Destructor Documentation

◆ peripheral()

template<typename S>
constexpr nrfcxx::nrf5::peripheral< S >::peripheral ( uintptr_t  base,
int8_t  irqn = NO_IRQ,
uint8_t  instance = NO_INSTANCE,
uint8_t  aux = 0 
)
inlineexplicitconstexpr

Create an object referencing a peripheral instance.

Parameters
baseinitializes BASE
irqninitializes IRQn

Field Documentation

◆ AUX

template<typename S>
const uint8_t nrfcxx::nrf5::peripheral< S >::AUX

Auxiliary information relevant to the specific peripheral and type.

  • GPIO instances use this field to specify the number of pins supported by the instance.
  • GPIOTE and SAADC instances specify the number of channels available.
  • PPI instances specify the number of programmable interconnections.
  • TIMER and RTC instances use this field to specify the number of CC registers supported by the peripheral instance.
  • For other peripherals the value is zero.

◆ INSTANCE

template<typename S>
const uint8_t nrfcxx::nrf5::peripheral< S >::INSTANCE

The peripheral instance, for peripherals like TIMER that have multiple instances.

NO_INSTANCE is used for peripherals that have no instances, such as CLOCK.

◆ IRQn

template<typename S>
const int8_t nrfcxx::nrf5::peripheral< S >::IRQn

The interrupt number associated with the instance, or negative if the instance has no dedicated interrupt.

Note
The Nordic headers define IRQn_Type as an enumeration with default underlying type in a header that we can't see until we've declared this structure, so we can't declare this with the standard type unless we want to do horrifying dependency avoidance tricks, which we don't. A consequence is that, to satisfy C++'s type finickiness, CMSIS standard functions like NVIC_EnableIRQ() must be wrapped with customized versions like nvic_EnableIRQ() to perform the necessary cast operation.

◆ NO_INSTANCE

template<typename S>
constexpr uint8_t nrfcxx::nrf5::peripheral< S >::NO_INSTANCE = 255
staticconstexpr

Flag value for INSTANCE indicating that the peripheral does not have enumerated instances (e.g.

CLOCK, as compared to TIMER0).


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