nrf52/include/periph_cpu.h File Reference

nRF52 specific definitions for handling peripherals More...

Detailed Description

nRF52 specific definitions for handling peripherals

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file nrf52/include/periph_cpu.h.

#include "periph_cpu_common.h"
+ Include dependency graph for nrf52/include/periph_cpu.h:

Go to the source code of this file.

Data Structures

struct  i2c_conf_t
 I2C configuration options. More...
 
struct  pwm_conf_t
 PWM device configuration. More...
 

Macros

#define ADC_NUMOF   (9U)
 The nRF52 family of CPUs provides a fixed number of 9 ADC lines.
 

Enumerations

enum  {
  NRF52_AIN0 = 0, NRF52_AIN1 = 1, NRF52_AIN2 = 2, NRF52_AIN3 = 3,
  NRF52_AIN4 = 4, NRF52_AIN5 = 5, NRF52_AIN6 = 6, NRF52_AIN7 = 7,
  NRF52_VDD = 8
}
 nRF52 specific naming of ADC lines (for convenience) More...
 
#define CLOCK_CORECLOCK   (64000000U)
 System core clock speed, fixed to 64MHz for all NRF52x CPUs.
 

Peripheral clock speed (fixed to 16MHz for nRF52 based CPUs)

#define PERIPH_CLOCK   (16000000U)
 
#define UART_IRQN   (UARTE0_UART0_IRQn)
 Redefine some peripheral names to unify them between nRF51 and 52.
 
#define SPI_SCKSEL   (dev(bus)->PSEL.SCK)
 
#define SPI_MOSISEL   (dev(bus)->PSEL.MOSI)
 
#define SPI_MISOSEL   (dev(bus)->PSEL.MISO)
 
#define HAVE_ADC_RES_T
 Override ADC resolution values.
 
enum  adc_res_t {
  ADC_RES_6BIT = (0xa00), ADC_RES_7BIT = (0 << 4), ADC_RES_8BIT = (0xb00), ADC_RES_9BIT = (1 << 4),
  ADC_RES_10BIT = (2 << 4), ADC_RES_12BIT = (3 << 4), ADC_RES_14BIT = (0xc00), ADC_RES_16BIT = (0xd00),
  ADC_RES_9BIT = 0, ADC_RES_10BIT, ADC_RES_11BIT, ADC_RES_12BIT,
  ADC_RES_10BIT, ADC_RES_6BIT = 0xf0, ADC_RES_8BIT = 0x00, ADC_RES_10BIT = 0x02,
  ADC_RES_12BIT = 0xf1, ADC_RES_14BIT = 0xf2, ADC_RES_16BIT = 0xf3, ADC_RES_6BIT = 0xf0,
  ADC_RES_8BIT = 0x00, ADC_RES_10BIT = 0x01, ADC_RES_12BIT = 0x02, ADC_RES_14BIT = 0xf1,
  ADC_RES_16BIT = 0xf2, ADC_RES_6BIT = 0x1, ADC_RES_8BIT = 0x2, ADC_RES_10BIT = ADC_MR_LOWRES_BITS_10,
  ADC_RES_12BIT = ADC_MR_LOWRES_BITS_12, ADC_RES_14BIT = 0x4, ADC_RES_16BIT = 0x8, ADC_RES_6BIT = 0xff,
  ADC_RES_8BIT = ADC_CTRLB_RESSEL_8BIT, ADC_RES_10BIT = ADC_CTRLB_RESSEL_10BIT, ADC_RES_12BIT = ADC_CTRLB_RESSEL_12BIT, ADC_RES_14BIT = 0xfe,
  ADC_RES_16BIT = 0xfd, ADC_RES_6BIT = 0xff, ADC_RES_8BIT = ADC_CTRLC_RESSEL_8BIT, ADC_RES_10BIT = ADC_CTRLC_RESSEL_10BIT,
  ADC_RES_12BIT = ADC_CTRLC_RESSEL_12BIT, ADC_RES_14BIT = 0xfe, ADC_RES_16BIT = 0xfd, ADC_RES_6BIT = 0x03000000,
  ADC_RES_8BIT = 0x02000000, ADC_RES_10BIT = 0x01000000, ADC_RES_12BIT = 0x00000000, ADC_RES_14BIT = 1,
  ADC_RES_16BIT = 2, ADC_RES_6BIT = (ADC_CR1_RES_0 | ADC_CR1_RES_1), ADC_RES_8BIT = (ADC_CR1_RES_1), ADC_RES_10BIT = (ADC_CR1_RES_0),
  ADC_RES_12BIT = (0x00), ADC_RES_14BIT = (0xfe), ADC_RES_16BIT = (0xff), ADC_RES_6BIT = 0,
  ADC_RES_8BIT, ADC_RES_10BIT, ADC_RES_12BIT, ADC_RES_14BIT,
  ADC_RES_16BIT
}
 
#define HAVE_I2C_SPEED_T
 Override I2C speed settings.
 
enum  i2c_speed_t {
  I2C_SPEED_LOW = 0x01, I2C_SPEED_NORMAL = 100000U, I2C_SPEED_FAST = 400000U, I2C_SPEED_FAST_PLUS = 0x02,
  I2C_SPEED_HIGH = 0x03, I2C_SPEED_LOW = 0x01, I2C_SPEED_NORMAL = TWI_FREQUENCY_FREQUENCY_K100, I2C_SPEED_FAST = TWI_FREQUENCY_FREQUENCY_K400,
  I2C_SPEED_FAST_PLUS = 0x02, I2C_SPEED_HIGH = 0x03, I2C_SPEED_LOW = 0xff, I2C_SPEED_NORMAL = TWIM_FREQUENCY_FREQUENCY_K100,
  I2C_SPEED_FAST = TWIM_FREQUENCY_FREQUENCY_K400, I2C_SPEED_FAST_PLUS = 0xfe, I2C_SPEED_HIGH = 0xfd, I2C_SPEED_LOW = 10000U,
  I2C_SPEED_NORMAL = 100000U, I2C_SPEED_FAST = 400000U, I2C_SPEED_FAST_PLUS = 1000000U, I2C_SPEED_HIGH = 3400000U,
  I2C_SPEED_NORMAL, I2C_SPEED_FAST, I2C_SPEED_LOW = 0, I2C_SPEED_NORMAL,
  I2C_SPEED_FAST, I2C_SPEED_FAST_PLUS, I2C_SPEED_HIGH
}
 

The PWM unit on the nRF52 supports 4 channels per device

#define PWM_CHANNELS   (4U)
 

Generate PWM mode values

To encode the PWM mode, we use two bit:

  • bit 0: select up or up-and-down counting
  • bit 15: select polarity
#define PWM_MODE(ud, pol)   (ud | (pol << 15))
 
#define HAVE_PWM_MODE_T
 Override the PWM mode definitions.
 
enum  pwm_mode_t {
  PWM_LEFT = PWM_MODE(0, 1), PWM_RIGHT = PWM_MODE(0, 0), PWM_CENTER = PWM_MODE(1, 1), PWM_CENTER_INV = PWM_MODE(1, 0),
  PWM_LEFT, PWM_RIGHT, PWM_CENTER
}
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

nRF52 specific naming of ADC lines (for convenience)

Enumerator
NRF52_AIN0 

Analog Input 0.

NRF52_AIN1 

Analog Input 1.

NRF52_AIN2 

Analog Input 2.

NRF52_AIN3 

Analog Input 3.

NRF52_AIN4 

Analog Input 4.

NRF52_AIN5 

Analog Input 5.

NRF52_AIN6 

Analog Input 6.

NRF52_AIN7 

Analog Input 7.

NRF52_VDD 

VDD, not useful if VDD is reference...

Definition at line 56 of file nrf52/include/periph_cpu.h.

◆ adc_res_t

enum adc_res_t
Enumerator
ADC_RES_6BIT 

not supported by hardware

ADC_RES_7BIT 

ADC resolution: 7 bit.

ADC_RES_8BIT 

not supported by hardware

ADC_RES_9BIT 

ADC resolution: 9 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

not supported by hardware

ADC_RES_16BIT 

not supported by hardware

ADC_RES_9BIT 

ADC resolution: 9 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_11BIT 

ADC resolution: 11 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_6BIT 

ADC resolution: 6 bit (not supported)

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit (not supported)

ADC_RES_14BIT 

ADC resolution: 14 bit (not supported)

ADC_RES_16BIT 

ADC resolution: 16 bit (not supported)

ADC_RES_6BIT 

not supported by hardware

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

supported with oversampling, not implemented

ADC_RES_16BIT 

not supported by hardware

ADC_RES_6BIT 

not applicable

ADC_RES_8BIT 

not applicable

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

not applicable

ADC_RES_16BIT 

not applicable

ADC_RES_6BIT 

not supported

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

not supported

ADC_RES_16BIT 

not supported

ADC_RES_6BIT 

not supported

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

not supported

ADC_RES_16BIT 

not supported

ADC_RES_6BIT 

ADC resolution: 6 bit.

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

ADC resolution: 14 bit (not supported)

ADC_RES_16BIT 

ADC resolution: 16 bit (not supported)

ADC_RES_6BIT 

ADC resolution: 6 bit.

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

not applicable

ADC_RES_16BIT 

not applicable

ADC_RES_6BIT 

ADC resolution: 6 bit.

ADC_RES_8BIT 

ADC resolution: 8 bit.

ADC_RES_10BIT 

ADC resolution: 10 bit.

ADC_RES_12BIT 

ADC resolution: 12 bit.

ADC_RES_14BIT 

ADC resolution: 14 bit.

ADC_RES_16BIT 

ADC resolution: 16 bit.

Definition at line 73 of file nrf52/include/periph_cpu.h.

◆ i2c_speed_t

Enumerator
I2C_SPEED_LOW 

not supported

I2C_SPEED_NORMAL 

normal mode: ~100kbit/s

I2C_SPEED_FAST 

fast mode: ~400kbit/s

I2C_SPEED_FAST_PLUS 

not supported

I2C_SPEED_HIGH 

not supported

I2C_SPEED_LOW 

not supported

I2C_SPEED_NORMAL 

100kbit/s

I2C_SPEED_FAST 

400kbit/s

I2C_SPEED_FAST_PLUS 

not supported

I2C_SPEED_HIGH 

not supported

I2C_SPEED_LOW 

not supported

I2C_SPEED_NORMAL 

100kbit/s

I2C_SPEED_FAST 

400kbit/s

I2C_SPEED_FAST_PLUS 

not supported

I2C_SPEED_HIGH 

not supported

I2C_SPEED_LOW 

low speed mode: ~10kbit/s

I2C_SPEED_NORMAL 

normal mode: ~100kbit/s

I2C_SPEED_FAST 

fast mode: ~400kbit/s

I2C_SPEED_FAST_PLUS 

fast plus mode: ~1Mbit/s

I2C_SPEED_HIGH 

high speed mode: ~3.4Mbit/s

I2C_SPEED_NORMAL 

normal mode: ~100kbit/s

I2C_SPEED_FAST 

fast mode: ~400kbit/s

I2C_SPEED_LOW 

low speed mode: ~10 kbit/s

I2C_SPEED_NORMAL 

normal mode: ~100 kbit/s

I2C_SPEED_FAST 

fast mode: ~400 kbit/s

I2C_SPEED_FAST_PLUS 

fast plus mode: ~1000 kbit/s

I2C_SPEED_HIGH 

high speed mode: ~3400 kbit/s

Definition at line 88 of file nrf52/include/periph_cpu.h.

◆ pwm_mode_t

enum pwm_mode_t
Enumerator
PWM_LEFT 

left aligned PWM

PWM_RIGHT 

right aligned PWM

PWM_CENTER 

not supported

PWM_CENTER_INV 

not supported

Definition at line 135 of file nrf52/include/periph_cpu.h.