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 
10 #pragma once
11 
23 #include "periph_cpu.h"
24 #include "periph_conf_common.h"
25 #include "cfg_i2c_default.h"
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
36 static const spi_conf_t spi_config[] = {
37  {
38  .dev = SPI1,
39  .pin_miso = GPIO_PIN(PORT_A, 17),
40  .pin_mosi = GPIO_PIN(PORT_A, 16),
41  .pin_clk = GPIO_PIN(PORT_A, 18),
42  .pin_cs = {
43  GPIO_PIN(PORT_A, 19),
48  },
49  .pcr = GPIO_AF_2,
50  .simmask = SIM_SCGC6_SPI1_MASK
51  }
52 };
53 #define SPI_NUMOF ARRAY_SIZE(spi_config)
60 static const adc_conf_t adc_config[] = {
61  /* dev, pin, channel */
62  /* internal: temperature sensor */
63  /* The temperature sensor has a very high output impedance, it must not be
64  * sampled using hardware averaging, or the sampled values will be garbage */
65  [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
66  /* Note: the band gap buffer uses a bit of current and is turned off by default,
67  * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
68  /* internal: band gap */
69  [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
70  /* internal: DCDC divided battery level */
71  [ 2] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
72 };
73 #define ADC_NUMOF ARRAY_SIZE(adc_config)
74 /*
75  * KW41Z ADC reference settings:
76  * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
77  * 1: VDDA (analog supply input voltage)
78  * 2-3: reserved
79  *
80  * VREF_OUT and VREFH shares the pin on KW41Z and is tied to VDDA on the
81  * USB-KW41Z board, so it does not matter which setting is chosen here for this
82  * board.
83  */
84 #define ADC_REF_SETTING 1
87 #ifdef __cplusplus
88 }
89 #endif
90 
@ PORT_A
port A
Definition: periph_cpu.h:46
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
#define ADC_AVG_NONE
Disable hardware averaging.
Definition: periph_cpu.h:369
#define ADC_AVG_MAX
Maximum hardware averaging (32 samples)
Definition: periph_cpu.h:373
ADC device configuration.
Definition: periph_cpu.h:377
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:378
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337