periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 iosabi
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
21 #include <stdint.h>
22 
23 #include "macros/units.h"
24 #include "cpu.h"
25 #include "periph_cpu.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #ifndef CLOCK_CORECLOCK
36 /* Using 32MHz internal oscillator as default clock source */
37 #define CLOCK_CORECLOCK MHZ(32)
38 #endif
48 static const adc_conf_t adc_config[] = {
58  ADC_CHANNEL_TEMP, /* temperature */
60 };
61 #define ADC_NUMOF ARRAY_SIZE(adc_config)
68 static const i2c_conf_t i2c_config[] = {
69  {
70  .dev = I2C0, /* Flexcomm 1 */
71  .pin_scl = GPIO_PIN(PORT_A, 6),
72  .pin_sda = GPIO_PIN(PORT_A, 7),
73  .speed = I2C_SPEED_FAST,
74  },
75 };
76 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
83 static const spi_conf_t spi_config[] = {
84  {
85  .dev = SPI0, /* Flexcomm 2 */
86  .cipo_pin = GPIO_PIN(PORT_A, 5),
87  .copi_pin = GPIO_PIN(PORT_A, 4),
88  .clk_pin = GPIO_PIN(PORT_A, 30),
89  .cs_pin = {
90  GPIO_PIN(PORT_A, 3), /* MX25R2035F CS# connected here. */
91  GPIO_UNDEF,
92  GPIO_UNDEF,
94  },
95  },
96 };
97 
98 #define SPI_NUMOF ARRAY_SIZE(spi_config)
105 static const uart_conf_t uart_config[] = {
106  {
107  .dev = USART0, /* Flexcomm 0 */
108  .rx_pin = GPIO_PIN(PORT_A, 17),
109  .tx_pin = GPIO_PIN(PORT_A, 16),
110  },
111 };
112 
113 #define UART_NUMOF ARRAY_SIZE(uart_config)
120 #define TIMER_NUMOF 4
123 /* put here the board peripherals definitions:
124  - Available clocks
125  - PWMs
126  - SPIs
127  - ADC
128  - RTC
129  - RTT
130  etc
131  */
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
@ 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 uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: periph_cpu.h:278
#define ADC_VREF_GAIN_X15
ADC Vref x1.5 multiplier flag.
Definition: periph_cpu.h:266
@ ADC_VINN_AVSS
Use Vinn := Vss.
Definition: periph_cpu.h:292
@ ADC_CHANNEL_ADC4_VINN
Sample ADC4 / Vinn.
Definition: periph_cpu.h:235
@ ADC_CHANNEL_ADC5_VINN
Sample ADC5 / Vinn.
Definition: periph_cpu.h:236
@ ADC_CHANNEL_TEMP
Sample internal temperature.
Definition: periph_cpu.h:239
@ ADC_CHANNEL_ADC0_ADC1
Sample ADC0 / ADC1.
Definition: periph_cpu.h:227
@ ADC_CHANNEL_ADC1_VINN
Sample ADC1 / Vinn.
Definition: periph_cpu.h:232
@ ADC_CHANNEL_ADC6_VINN
Sample ADC6 / Vinn.
Definition: periph_cpu.h:237
@ ADC_CHANNEL_ADC0_VINN
Sample ADC0 / Vinn.
Definition: periph_cpu.h:231
@ ADC_CHANNEL_ADC4_ADC5
Sample ADC4 / ADC5.
Definition: periph_cpu.h:229
@ ADC_CHANNEL_ADC6_ADC7
Sample ADC6 / ADC7.
Definition: periph_cpu.h:230
@ ADC_CHANNEL_ADC7_VINN
Sample ADC7 / Vinn.
Definition: periph_cpu.h:238
@ ADC_CHANNEL_VCC4_VINN
Sample 1/4 Vcc / Vinn.
Definition: periph_cpu.h:240
ADC device configuration.
Definition: periph_cpu.h:377
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218
Unit helper macros.