periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015-2018 Freie Universität Berlin
3  * SPDX-FileCopyrightText: 2020 Philipp-Alexander Blum <philipp-blum@jakiku.de>
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
20 #include "periph_cpu_common.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 #define CLOCK_CORECLOCK (64000000U)
30 
34 #define PERIPH_CLOCK (16000000U)
35 
39 #ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
40 #define ADC_NUMOF (10U)
41 #else
42 #define ADC_NUMOF (9U)
43 #endif
44 
48 enum {
49  NRF52_AIN0 = 0,
50  NRF52_AIN1 = 1,
51  NRF52_AIN2 = 2,
52  NRF52_AIN3 = 3,
53  NRF52_AIN4 = 4,
54  NRF52_AIN5 = 5,
55  NRF52_AIN6 = 6,
56  NRF52_AIN7 = 7,
57  NRF52_VDD = 8,
58 #ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
59  NRF52_VDDHDIV5 = 9,
60 #endif
61 };
62 
63 #ifndef DOXYGEN
68 #define HAVE_ADC_RES_T
69 typedef enum {
70  ADC_RES_6BIT = 0xf0,
71  ADC_RES_8BIT = 0x00,
72  ADC_RES_10BIT = 0x01,
73  ADC_RES_12BIT = 0x02,
74  ADC_RES_14BIT = 0xf1,
75  ADC_RES_16BIT = 0xf2
76 } adc_res_t;
78 #endif /* ndef DOXYGEN */
79 
83 #ifndef UART_TXBUF_SIZE
84 #define UART_TXBUF_SIZE (64)
85 #endif
86 
92 typedef void (*spi_twi_irq_cb_t)(void *arg);
93 
101 void spi_twi_irq_register_spi(NRF_SPIM_Type *bus,
102  spi_twi_irq_cb_t cb, void *arg);
103 
111 void spi_twi_irq_register_i2c(NRF_TWIM_Type *bus,
112  spi_twi_irq_cb_t cb, void *arg);
113 
121 void nrf5x_i2c_acquire(NRF_TWIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
122 
128 void nrf5x_i2c_release(NRF_TWIM_Type *bus);
129 
137 void nrf5x_spi_acquire(NRF_SPIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
138 
144 void nrf5x_spi_release(NRF_SPIM_Type *bus);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
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:92
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:51
@ NRF52_AIN6
Analog Input 6.
Definition: periph_cpu.h:55
@ NRF52_AIN0
Analog Input 0.
Definition: periph_cpu.h:49
@ NRF52_AIN1
Analog Input 1.
Definition: periph_cpu.h:50
@ NRF52_AIN4
Analog Input 4.
Definition: periph_cpu.h:53
@ NRF52_AIN3
Analog Input 3.
Definition: periph_cpu.h:52
@ NRF52_VDD
VDD, not useful if VDD is reference...
Definition: periph_cpu.h:57
@ NRF52_AIN7
Analog Input 7.
Definition: periph_cpu.h:56
@ NRF52_AIN5
Analog Input 5.
Definition: periph_cpu.h:54
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.