periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2017 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 
9 #pragma once
10 
21 #include "periph_cpu_common.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
30 #define CLOCK_CORECLOCK (16000000U)
31 
36 #define SPI_SCKSEL (dev(bus)->PSELSCK)
37 #define SPI_MOSISEL (dev(bus)->PSELMOSI)
38 #define SPI_MISOSEL (dev(bus)->PSELMISO)
41 #ifndef DOXYGEN
46 #define HAVE_I2C_SPEED_T
47 typedef enum {
48  I2C_SPEED_LOW = 0x01,
49  I2C_SPEED_NORMAL = TWI_FREQUENCY_FREQUENCY_K100,
50  I2C_SPEED_FAST = TWI_FREQUENCY_FREQUENCY_K400,
51  I2C_SPEED_FAST_PLUS = 0x02,
52  I2C_SPEED_HIGH = 0x03,
53 } i2c_speed_t;
55 #endif /* ndef DOXYGEN */
56 
62 #define PERIPH_I2C_NEED_READ_REG
64 #define PERIPH_I2C_NEED_WRITE_REG
67 #ifndef DOXYGEN
72 #define HAVE_ADC_RES_T
73 typedef enum {
74  ADC_RES_6BIT = 0xf0,
75  ADC_RES_8BIT = 0x00,
76  ADC_RES_10BIT = 0x02,
77  ADC_RES_12BIT = 0xf1,
78  ADC_RES_14BIT = 0xf2,
79  ADC_RES_16BIT = 0xf3
80 } adc_res_t;
82 #endif /* ndef DOXYGEN */
83 
87 typedef gpio_t adc_conf_t;
88 
92 typedef struct {
93  NRF_TWI_Type *dev;
94  gpio_t pin_scl;
95  gpio_t pin_sda;
96  uint8_t ppi;
97  i2c_speed_t speed;
98 } i2c_conf_t;
99 
103 typedef struct {
104  NRF_SPI_Type *dev;
105  gpio_t sclk;
106  gpio_t mosi;
107  gpio_t miso;
108 } spi_conf_t;
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
i2c_speed_t
Definition: periph_cpu.h:275
gpio_t adc_conf_t
ADC configuration wrapper.
Definition: periph_cpu.h:336
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:92
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition: adc.h:98
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition: adc.h:94
@ ADC_RES_14BIT
ADC resolution: 14 bit.
Definition: adc.h:97
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:93
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition: adc.h:95
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition: adc.h:96
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
@ I2C_SPEED_FAST_PLUS
fast plus mode: ~1000 kbit/s
Definition: periph_cpu.h:279
@ I2C_SPEED_LOW
low speed mode: ~10 kbit/s
Definition: periph_cpu.h:276
@ I2C_SPEED_HIGH
high speed mode: ~3400 kbit/s
Definition: periph_cpu.h:281
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: periph_cpu.h:278
I2C configuration structure.
Definition: periph_cpu.h:298
uint8_t ppi
PPI channel to use.
Definition: periph_cpu.h:96
NRF_TWI_Type * dev
hardware device
Definition: periph_cpu.h:93
gpio_t pin_sda
SDA pin.
Definition: periph_cpu.h:95
gpio_t pin_scl
SCL pin.
Definition: periph_cpu.h:94
SPI device configuration.
Definition: periph_cpu.h:336
NRF_SPI_Type * dev
SPI device used.
Definition: periph_cpu.h:104