periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Eistec AB
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 #include "periph_cpu.h"
23 #include "periph_conf_common.h"
24 #include "cfg_i2c_default.h"
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
35 static const spi_conf_t spi_config[] = {
36  {
37  .dev = SPI0,
38  .pin_miso = GPIO_PIN(PORT_C, 18),
39  .pin_mosi = GPIO_PIN(PORT_C, 17),
40  .pin_clk = GPIO_PIN(PORT_C, 16),
41  .pin_cs = {
42  GPIO_PIN(PORT_C, 19),
43  GPIO_UNDEF,
44  GPIO_UNDEF,
45  GPIO_UNDEF,
47  },
48  .pcr = GPIO_AF_2,
49  .simmask = SIM_SCGC6_SPI0_MASK
50  },
51  {
52  .dev = SPI1,
53  .pin_miso = GPIO_PIN(PORT_A, 17),
54  .pin_mosi = GPIO_PIN(PORT_A, 16),
55  .pin_clk = GPIO_PIN(PORT_A, 18),
56  .pin_cs = {
57  GPIO_PIN(PORT_A, 19),
58  GPIO_UNDEF,
59  GPIO_UNDEF,
60  GPIO_UNDEF,
62  },
63  .pcr = GPIO_AF_2,
64  .simmask = SIM_SCGC6_SPI1_MASK
65  }
66 };
67 #define SPI_NUMOF ARRAY_SIZE(spi_config)
68 
74 static const adc_conf_t adc_config[] = {
75  /* dev, pin, channel */
76  /* ADC0_DP-ADC0_DM differential reading (Arduino A5 - A0) */
77  [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0 | ADC_SC1_DIFF_MASK, .avg = ADC_AVG_MAX },
78  /* ADC0_DP single ended reading (Arduino A5) */
79  [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0, .avg = ADC_AVG_MAX },
80  /* PTB2 (Arduino A2) */
81  [ 2] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 2), .chan = 3, .avg = ADC_AVG_MAX },
82  /* PTB3 (Arduino A3) */
83  [ 3] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 3), .chan = 2, .avg = ADC_AVG_MAX },
84  /* internal: temperature sensor */
85  /* The temperature sensor has a very high output impedance, it must not be
86  * sampled using hardware averaging, or the sampled values will be garbage */
87  [ 4] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
88  /* Note: the band gap buffer uses a bit of current and is turned off by default,
89  * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
90  /* internal: band gap */
91  [ 5] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
92  /* internal: DCDC divided battery level */
93  [ 6] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
94 };
95 #define ADC_NUMOF ARRAY_SIZE(adc_config)
96 /*
97  * KW41Z ADC reference settings:
98  * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
99  * 1: VDDA (analog supply input voltage)
100  * 2-3: reserved
101  *
102  * VREF_OUT and VREFH shares the pin on KW41Z and is only connected to a 100 nF
103  * capacitor on the FRDM-KW41Z board. So use VDDA by default on this board
104  * unless the application enables the VREF module.
105  */
106 #define ADC_REF_SETTING 1
107 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* PERIPH_CONF_H */
114 
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
adc_conf_t::dev
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:75
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
ADC_AVG_NONE
#define ADC_AVG_NONE
Disable hardware averaging.
Definition: periph_cpu.h:362
adc_conf_t
ADC device configuration.
Definition: periph_cpu.h:74
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
spi_conf_t::dev
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:465
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
ADC_AVG_MAX
#define ADC_AVG_MAX
Maximum hardware averaging (32 samples)
Definition: periph_cpu.h:366