nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Data Structures | Typedefs | Functions | Variables
nrfcxx::nrf5::series Namespace Reference

Namespace holding series-specific implementations that support the genericized API of nrfcxx. More...

Data Structures

struct  ADC_Base
 Material common to all ADC peripheral implementations. More...
 
struct  ADC_Peripheral
 Constants and function specific to the nRF51 ADC peripheral. More...
 
struct  SAADC_Peripheral
 Constants and function specific to the nRF52 SAADC peripheral. More...
 

Typedefs

using ADC_Variant = ADC_Peripheral
 

Functions

void delay_cycles (unsigned int cycles)
 Loop to delay for a requested number of cycles.
 
void enable_pinreset ()
 Enable the nRESET functionality. More...
 

Variables

static constexpr unsigned int CLOCK_MHz = 16
 CPU clock speed in MHz.
 
static constexpr unsigned int DELAY_US_OVERHEAD_cyc = 11
 Overhead setting up the call to delay_cycles() in the standard delay_us() implementation. More...
 
static constexpr unsigned int CLOCK_MHz = 64
 CPU clock speed in MHz.
 
static constexpr unsigned int DELAY_US_OVERHEAD_cyc = 12
 Overhead setting up the call to delay_cycles() in the standard delay_us() implementation. More...
 

Detailed Description

Namespace holding series-specific implementations that support the genericized API of nrfcxx.

Function Documentation

◆ enable_pinreset()

void nrfcxx::nrf5::series::enable_pinreset ( )

Enable the nRESET functionality.

Nordic dev boards have a nice button labelled "RESET", but it only resets if you build system_nr52.c with CONFIG_GPIO_AS_PINRESET defined. Having done that, it's sticky until UICR is cleared and won't go away if you rebuild with that undefined. Horrible API.

Instead use this function to enable the reset pin functionality. To disable it, wait until we have UICR support or use:

nrfjprog -f NRF52 --eraseuicr
Note
Generally only one pin is supported for nRESET. On nRF52832 it's 21; on nRF52840 it's 18. The function picks the one it thinks is right.
Warning
This function will move to the UICR module once that's designed and implemented.

Variable Documentation

◆ DELAY_US_OVERHEAD_cyc [1/2]

constexpr unsigned int nrfcxx::nrf5::series::DELAY_US_OVERHEAD_cyc = 12
staticconstexpr

Overhead setting up the call to delay_cycles() in the standard delay_us() implementation.

The value must be strictly less than CLOCK_MHz.

This value has been estimated from biased measurement, and is conservative (smaller than the actual overhead). Note that the resolution of the used value depends on the number of cycles per delay_cycles() iteration: at the nRF52 value of 3 there is no difference between 12 and 14. 12 is chosen because the measured overhead for single-pass loop with a non-zero overhead is about 225 ns, with the overhead of the scope operation probably around 32 ns. 12 is 187.5 ns which is close to the difference without exceeding it.

◆ DELAY_US_OVERHEAD_cyc [2/2]

constexpr unsigned int nrfcxx::nrf5::series::DELAY_US_OVERHEAD_cyc = 11
staticconstexpr

Overhead setting up the call to delay_cycles() in the standard delay_us() implementation.

The value must be strictly less than CLOCK_MHz.

This value has been estimated from biased measurement, and is conservative (smaller than the actual overhead). Note that the resolution of the used value depends on the number of cycles per delay_cycles() iteration: at the nRF51 value of 4 there is no difference between 8 and 11. 11 is chosen because the measured overhead for single-pass loop is about 820 ns, with the overhead of the scope operation probably around 125 ns. 11 is 687.5 ns which is close to the difference without exceeding it.