Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Eistec AB
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "periph_cpu.h"
19#include "periph_conf_common.h"
20#include "cfg_i2c_default.h"
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26
31static const spi_conf_t spi_config[] = {
32 {
33 .dev = SPI0,
34 .pin_miso = GPIO_PIN(PORT_C, 18),
35 .pin_mosi = GPIO_PIN(PORT_C, 17),
36 .pin_clk = GPIO_PIN(PORT_C, 16),
37 .pin_cs = {
38 GPIO_PIN(PORT_C, 19),
43 },
44 .pcr = GPIO_AF_2,
45 .simmask = SIM_SCGC6_SPI0_MASK
46 },
47 {
48 .dev = SPI1,
49 .pin_miso = GPIO_PIN(PORT_A, 17),
50 .pin_mosi = GPIO_PIN(PORT_A, 16),
51 .pin_clk = GPIO_PIN(PORT_A, 18),
52 .pin_cs = {
53 GPIO_PIN(PORT_A, 19),
58 },
59 .pcr = GPIO_AF_2,
60 .simmask = SIM_SCGC6_SPI1_MASK
61 }
62};
63#define SPI_NUMOF ARRAY_SIZE(spi_config)
65
70static const adc_conf_t adc_config[] = {
71 /* dev, pin, channel */
72 /* ADC0_DP-ADC0_DM differential reading (Arduino A5 - A0) */
73 [ 0] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0 | ADC_SC1_DIFF_MASK, .avg = ADC_AVG_MAX },
74 /* ADC0_DP single ended reading (Arduino A5) */
75 [ 1] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 0, .avg = ADC_AVG_MAX },
76 /* PTB2 (Arduino A2) */
77 [ 2] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 2), .chan = 3, .avg = ADC_AVG_MAX },
78 /* PTB3 (Arduino A3) */
79 [ 3] = { .dev = ADC0, .pin = GPIO_PIN(PORT_B, 3), .chan = 2, .avg = ADC_AVG_MAX },
80 /* internal: temperature sensor */
81 /* The temperature sensor has a very high output impedance, it must not be
82 * sampled using hardware averaging, or the sampled values will be garbage */
83 [ 4] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 26, .avg = ADC_AVG_NONE },
84 /* Note: the band gap buffer uses a bit of current and is turned off by default,
85 * Set PMC->REGSC |= PMC_REGSC_BGBE_MASK before reading or the input will be floating */
86 /* internal: band gap */
87 [ 5] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 27, .avg = ADC_AVG_MAX },
88 /* internal: DCDC divided battery level */
89 [ 6] = { .dev = ADC0, .pin = GPIO_UNDEF, .chan = 23, .avg = ADC_AVG_MAX },
90};
91#define ADC_NUMOF ARRAY_SIZE(adc_config)
92/*
93 * KW41Z ADC reference settings:
94 * 0: VREFH external pin or VREF_OUT 1.2 V signal (if VREF module is enabled)
95 * 1: VDDA (analog supply input voltage)
96 * 2-3: reserved
97 *
98 * VREF_OUT and VREFH shares the pin on KW41Z and is only connected to a 100 nF
99 * capacitor on the FRDM-KW41Z board. So use VDDA by default on this board
100 * unless the application enables the VREF module.
101 */
102#define ADC_REF_SETTING 1
104
105#ifdef __cplusplus
106}
107#endif
108
@ PORT_B
port B
Definition periph_cpu.h:44
@ PORT_C
port C
Definition periph_cpu.h:45
@ PORT_A
port A
Definition periph_cpu.h:43
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
#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:374
SPI device configuration.
Definition periph_cpu.h:333