periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef PERIPH_CPU_H
20 #define PERIPH_CPU_H
21 
22 #include "periph_cpu_common.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
31 #define CLOCK_CORECLOCK (64000000U)
32 
36 #define PERIPH_CLOCK (16000000U)
37 
42 #define SPI_SCKSEL (dev(bus)->PSEL.SCK)
43 #define SPI_MOSISEL (dev(bus)->PSEL.MOSI)
44 #define SPI_MISOSEL (dev(bus)->PSEL.MISO)
45 #ifndef CPU_MODEL_NRF52840XXAA
46 #define UART_IRQN (UARTE0_UART0_IRQn)
47 #endif
48 
53 #define ADC_NUMOF (9U)
54 
58 enum {
59  NRF52_AIN0 = 0,
60  NRF52_AIN1 = 1,
61  NRF52_AIN2 = 2,
62  NRF52_AIN3 = 3,
63  NRF52_AIN4 = 4,
64  NRF52_AIN5 = 5,
65  NRF52_AIN6 = 6,
66  NRF52_AIN7 = 7,
67  NRF52_VDD = 8,
68 };
69 
74 #define HAVE_ADC_RES_T
75 typedef enum {
76  ADC_RES_6BIT = 0xf0,
77  ADC_RES_8BIT = 0x00,
78  ADC_RES_10BIT = 0x01,
79  ADC_RES_12BIT = 0x02,
80  ADC_RES_14BIT = 0xf1,
81  ADC_RES_16BIT = 0xf2
82 } adc_res_t;
89 #define HAVE_I2C_SPEED_T
90 typedef enum {
91  I2C_SPEED_LOW = 0xff,
92  I2C_SPEED_NORMAL = TWIM_FREQUENCY_FREQUENCY_K100,
93  I2C_SPEED_FAST = TWIM_FREQUENCY_FREQUENCY_K400,
95  I2C_SPEED_HIGH = 0xfd,
96 } i2c_speed_t;
102 typedef struct {
103  NRF_TWIM_Type *dev;
104  uint8_t scl;
105  uint8_t sda;
106  i2c_speed_t speed;
107 } i2c_conf_t;
114 #define PERIPH_I2C_NEED_READ_REG
115 #define PERIPH_I2C_NEED_WRITE_REG
116 
121 #define PWM_CHANNELS (4U)
122 
130 #define PWM_MODE(ud, pol) (ud | (pol << 15))
131 
136 #define HAVE_PWM_MODE_T
137 typedef enum {
138  PWM_LEFT = PWM_MODE(0, 1),
139  PWM_RIGHT = PWM_MODE(0, 0),
140  PWM_CENTER = PWM_MODE(1, 1),
141  PWM_CENTER_INV = PWM_MODE(1, 0)
142 } pwm_mode_t;
155 typedef struct {
156  NRF_PWM_Type *dev;
157  uint32_t pin[PWM_CHANNELS];
158 } pwm_conf_t;
159 
160 #ifdef CPU_MODEL_NRF52840XXAA
161 
164 typedef struct {
165  NRF_UARTE_Type *dev;
166  uint8_t rx_pin;
167  uint8_t tx_pin;
168  uint8_t rts_pin;
169  uint8_t cts_pin;
170  uint8_t irqn;
171 } uart_conf_t;
172 #endif
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* PERIPH_CPU_H */
179 
fast mode: ~400kbit/s
Definition: periph_cpu.h:117
not supported
Definition: periph_cpu.h:119
I2C configuration options.
Definition: periph_cpu.h:125
not supported
Definition: periph_cpu.h:140
Analog Input 7.
Definition: periph_cpu.h:66
ADC resolution: 12 bit.
Definition: periph_cpu.h:298
NRF_TWIM_Type * dev
TWIM hardware device.
Definition: periph_cpu.h:103
uint8_t scl
SCL pin.
Definition: periph_cpu.h:104
adc_res_t
Definition: periph_cpu.h:292
VDD, not useful if VDD is reference...
Definition: periph_cpu.h:67
Analog Input 1.
Definition: periph_cpu.h:60
uint8_t sda
SDA pin.
Definition: periph_cpu.h:105
Analog Input 2.
Definition: periph_cpu.h:61
Analog Input 3.
Definition: periph_cpu.h:62
PWM configuration.
Analog Input 4.
Definition: periph_cpu.h:63
Analog Input 6.
Definition: periph_cpu.h:65
i2c_speed_t
Definition: periph_cpu.h:114
not supported by hardware
Definition: periph_cpu.h:299
left aligned PWM
Definition: periph_cpu.h:138
ADC resolution: 10 bit.
Definition: periph_cpu.h:297
NRF_PWM_Type * dev
PWM device descriptor.
Definition: periph_cpu.h:156
not supported by hardware
Definition: periph_cpu.h:300
Analog Input 5.
Definition: periph_cpu.h:64
not supported by hardware
Definition: periph_cpu.h:295
not supported by hardware
Definition: periph_cpu.h:293
Analog Input 0.
Definition: periph_cpu.h:59
pwm_mode_t
Definition: periph_cpu.h:137
UART device configuration.
Definition: periph_cpu.h:162
not supported
Definition: periph_cpu.h:141
not supported
Definition: periph_cpu.h:115
normal mode: ~100kbit/s
Definition: periph_cpu.h:116
right aligned PWM
Definition: periph_cpu.h:139
not supported
Definition: periph_cpu.h:118