periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
34 static const spi_conf_t spi_config[] = {
35  {
36  .dev = SPI1,
37  .pin_miso = GPIO_PIN(PORT_A, 17),
38  .pin_mosi = GPIO_PIN(PORT_A, 16),
39  .pin_clk = GPIO_PIN(PORT_A, 18),
40  .pin_cs = {
41  GPIO_PIN(PORT_A, 19),
42  GPIO_UNDEF,
43  GPIO_UNDEF,
44  GPIO_UNDEF,
46  },
47  .pcr = GPIO_AF_2,
48  .simmask = SIM_SCGC6_SPI1_MASK
49  }
50 };
51 #define SPI_NUMOF ARRAY_SIZE(spi_config)
52 
58 static const adc_conf_t adc_config[] = {
59  /* dev, pin, channel */
60  /* internal: temperature sensor */
61  /* The temperature sensor has a very high output impedance, it must not be
62  * sampled using hardware averaging, or the sampled values will be garbage */
63  [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
64  /* Note: the band gap buffer uses a bit of current and is turned off by default,
65  * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
66  /* internal: band gap */
67  [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
68  /* internal: DCDC divided battery level */
69  [ 2] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
70 };
71 #define ADC_NUMOF ARRAY_SIZE(adc_config)
72 /*
73  * KW41Z ADC reference settings:
74  * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
75  * 1: VDDA (analog supply input voltage)
76  * 2-3: reserved
77  *
78  * VREF_OUT and VREFH shares the pin on KW41Z and is tied to VDDA on the
79  * USB-KW41Z board, so it does not matter which setting is chosen here for this
80  * board.
81  */
82 #define ADC_REF_SETTING 1
83 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* PERIPH_CONF_H */
90 
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