periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Eistec AB
3  * Copyright (C) 2018 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
21 #ifndef PERIPH_CONF_H
22 #define PERIPH_CONF_H
23 
24 #include "periph_cpu.h"
25 #include "periph_conf_common.h"
26 #include "cfg_i2c_default.h"
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
37 static const spi_conf_t spi_config[] = {
38  {
39  .dev = SPI1,
40  .pin_miso = GPIO_PIN(PORT_A, 17),
41  .pin_mosi = GPIO_PIN(PORT_A, 16),
42  .pin_clk = GPIO_PIN(PORT_A, 18),
43  .pin_cs = {
44  GPIO_PIN(PORT_A, 19),
45  GPIO_UNDEF,
46  GPIO_UNDEF,
47  GPIO_UNDEF,
49  },
50  .pcr = GPIO_AF_2,
51  .simmask = SIM_SCGC6_SPI1_MASK
52  }
53 };
54 #define SPI_NUMOF ARRAY_SIZE(spi_config)
55 
61 static const adc_conf_t adc_config[] = {
62  /* dev, pin, channel */
63  /* internal: temperature sensor */
64  /* The temperature sensor has a very high output impedance, it must not be
65  * sampled using hardware averaging, or the sampled values will be garbage */
66  [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
67  /* Note: the band gap buffer uses a bit of current and is turned off by default,
68  * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
69  /* internal: band gap */
70  [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
71  /* internal: DCDC divided battery level */
72  [ 2] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
73 };
74 #define ADC_NUMOF ARRAY_SIZE(adc_config)
75 /*
76  * KW41Z ADC reference settings:
77  * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
78  * 1: VDDA (analog supply input voltage)
79  * 2-3: reserved
80  *
81  * VREF_OUT and VREFH shares the pin on KW41Z and is tied to VDDA on the
82  * USB-KW41Z board, so it does not matter which setting is chosen here for this
83  * board.
84  */
85 #define ADC_REF_SETTING 1
86 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* PERIPH_CONF_H */
93 
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
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