periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Freie Universität Berlin
3  * 2020 Philipp-Alexander Blum <philipp-blum@jakiku.de>
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
23 #include "periph_cpu_common.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 #define CLOCK_CORECLOCK (64000000U)
33 
37 #define PERIPH_CLOCK (16000000U)
38 
42 #ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
43 #define ADC_NUMOF (10U)
44 #else
45 #define ADC_NUMOF (9U)
46 #endif
47 
51 enum {
52  NRF52_AIN0 = 0,
53  NRF52_AIN1 = 1,
54  NRF52_AIN2 = 2,
55  NRF52_AIN3 = 3,
56  NRF52_AIN4 = 4,
57  NRF52_AIN5 = 5,
58  NRF52_AIN6 = 6,
59  NRF52_AIN7 = 7,
60  NRF52_VDD = 8,
61 #ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
62  NRF52_VDDHDIV5 = 9,
63 #endif
64 };
65 
66 #ifndef DOXYGEN
71 #define HAVE_ADC_RES_T
72 typedef enum {
73  ADC_RES_6BIT = 0xf0,
74  ADC_RES_8BIT = 0x00,
75  ADC_RES_10BIT = 0x01,
76  ADC_RES_12BIT = 0x02,
77  ADC_RES_14BIT = 0xf1,
78  ADC_RES_16BIT = 0xf2
79 } adc_res_t;
81 #endif /* ndef DOXYGEN */
82 
86 #ifndef UART_TXBUF_SIZE
87 #define UART_TXBUF_SIZE (64)
88 #endif
89 
95 typedef void (*spi_twi_irq_cb_t)(void *arg);
96 
104 void spi_twi_irq_register_spi(NRF_SPIM_Type *bus,
105  spi_twi_irq_cb_t cb, void *arg);
106 
114 void spi_twi_irq_register_i2c(NRF_TWIM_Type *bus,
115  spi_twi_irq_cb_t cb, void *arg);
116 
124 void nrf5x_i2c_acquire(NRF_TWIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
125 
131 void nrf5x_i2c_release(NRF_TWIM_Type *bus);
132 
140 void nrf5x_spi_acquire(NRF_SPIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
141 
147 void nrf5x_spi_release(NRF_SPIM_Type *bus);
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
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
void spi_twi_irq_register_i2c(NRF_TWIM_Type *bus, spi_twi_irq_cb_t cb, void *arg)
Register a I2C IRQ handler for a shared I2C/SPI irq vector.
void nrf5x_spi_release(NRF_SPIM_Type *bus)
Acquire the shared I2C/SPI peripheral in SPI mode.
void nrf5x_spi_acquire(NRF_SPIM_Type *bus, spi_twi_irq_cb_t cb, void *arg)
Acquire the shared I2C/SPI peripheral in SPI mode.
void(* spi_twi_irq_cb_t)(void *arg)
Common SPI/I2C interrupt callback.
Definition: periph_cpu.h:95
void spi_twi_irq_register_spi(NRF_SPIM_Type *bus, spi_twi_irq_cb_t cb, void *arg)
Register a SPI IRQ handler for a shared I2C/SPI irq vector.
@ NRF52_AIN2
Analog Input 2.
Definition: periph_cpu.h:54
@ NRF52_AIN6
Analog Input 6.
Definition: periph_cpu.h:58
@ NRF52_AIN0
Analog Input 0.
Definition: periph_cpu.h:52
@ NRF52_AIN1
Analog Input 1.
Definition: periph_cpu.h:53
@ NRF52_AIN4
Analog Input 4.
Definition: periph_cpu.h:56
@ NRF52_AIN3
Analog Input 3.
Definition: periph_cpu.h:55
@ NRF52_VDD
VDD, not useful if VDD is reference...
Definition: periph_cpu.h:60
@ NRF52_AIN7
Analog Input 7.
Definition: periph_cpu.h:59
@ NRF52_AIN5
Analog Input 5.
Definition: periph_cpu.h:57
void nrf5x_i2c_acquire(NRF_TWIM_Type *bus, spi_twi_irq_cb_t cb, void *arg)
Acquire the shared I2C/SPI peripheral in I2C mode.
void nrf5x_i2c_release(NRF_TWIM_Type *bus)
Release the shared I2C/SPI peripheral in I2C mode.