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 
9 #pragma once
10 
21 #include "periph_cpu.h"
22 #include "periph_conf_common.h"
23 #include "cfg_i2c_default.h"
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
34 static const spi_conf_t spi_config[] = {
35  {
36  .dev = SPI0,
37  .pin_miso = GPIO_PIN(PORT_C, 18),
38  .pin_mosi = GPIO_PIN(PORT_C, 17),
39  .pin_clk = GPIO_PIN(PORT_C, 16),
40  .pin_cs = {
41  GPIO_PIN(PORT_C, 19),
46  },
47  .pcr = GPIO_AF_2,
48  .simmask = SIM_SCGC6_SPI0_MASK
49  },
50  {
51  .dev = SPI1,
52  .pin_miso = GPIO_PIN(PORT_A, 17),
53  .pin_mosi = GPIO_PIN(PORT_A, 16),
54  .pin_clk = GPIO_PIN(PORT_A, 18),
55  .pin_cs = {
56  GPIO_PIN(PORT_A, 19),
61  },
62  .pcr = GPIO_AF_2,
63  .simmask = SIM_SCGC6_SPI1_MASK
64  }
65 };
66 #define SPI_NUMOF ARRAY_SIZE(spi_config)
73 static const adc_conf_t adc_config[] = {
74  /* dev, pin, channel */
75  /* ADC0_DP-ADC0_DM differential reading (Arduino A5 - A0) */
76  [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0 | ADC_SC1_DIFF_MASK, .avg = ADC_AVG_MAX },
77  /* ADC0_DP single ended reading (Arduino A5) */
78  [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0, .avg = ADC_AVG_MAX },
79  /* PTB2 (Arduino A2) */
80  [ 2] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 2), .chan = 3, .avg = ADC_AVG_MAX },
81  /* PTB3 (Arduino A3) */
82  [ 3] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 3), .chan = 2, .avg = ADC_AVG_MAX },
83  /* internal: temperature sensor */
84  /* The temperature sensor has a very high output impedance, it must not be
85  * sampled using hardware averaging, or the sampled values will be garbage */
86  [ 4] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
87  /* Note: the band gap buffer uses a bit of current and is turned off by default,
88  * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
89  /* internal: band gap */
90  [ 5] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
91  /* internal: DCDC divided battery level */
92  [ 6] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
93 };
94 #define ADC_NUMOF ARRAY_SIZE(adc_config)
95 /*
96  * KW41Z ADC reference settings:
97  * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
98  * 1: VDDA (analog supply input voltage)
99  * 2-3: reserved
100  *
101  * VREF_OUT and VREFH shares the pin on KW41Z and is only connected to a 100 nF
102  * capacitor on the FRDM-KW41Z board. So use VDDA by default on this board
103  * unless the application enables the VREF module.
104  */
105 #define ADC_REF_SETTING 1
108 #ifdef __cplusplus
109 }
110 #endif
111 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_C
port C
Definition: periph_cpu.h:48
@ 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