nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
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... | |
Type * | instance () const |
Get a type-correct pointer to the peripheral structure. | |
Type * | operator-> () 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... | |
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.
S | the type describing the peripheral structure, e.g. NRF_GPIO_Type . |
|
inlineexplicitconstexpr |
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.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
.
const int8_t nrfcxx::nrf5::peripheral< S >::IRQn |
The interrupt number associated with the instance, or negative if the instance has no dedicated interrupt.
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.
|
staticconstexpr |
Flag value for INSTANCE indicating that the peripheral does not have enumerated instances (e.g.
CLOCK
, as compared to TIMER0
).