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 periph_cpu.h.

#include "periph_cpu_common.h"
+ Include dependency graph for 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 SPI_SCKSEL   (dev(bus)->PSEL.SCK)
 Redefine some peripheral names to unify them between nRF51 and 52.
 
#define SPI_MOSISEL   (dev(bus)->PSEL.MOSI)
 
#define SPI_MISOSEL   (dev(bus)->PSEL.MISO)
 
#define UART_IRQN   (UARTE0_UART0_IRQn)
 

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 = (TPM_CnSC_MSB_MASK | TPM_CnSC_ELSB_MASK), PWM_RIGHT = (TPM_CnSC_MSB_MASK | TPM_CnSC_ELSA_MASK), PWM_CENTER = (TPM_CnSC_MSB_MASK), 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 58 of file 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

PWM_LEFT 

left aligned

PWM_RIGHT 

right aligned

PWM_CENTER 

center aligned

Definition at line 141 of file periph_cpu.h.