periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Inria
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 
21 #ifndef PERIPH_CONF_H
22 #define PERIPH_CONF_H
23 
24 /* This board provides an LSE */
25 #ifndef CONFIG_BOARD_HAS_LSE
26 #define CONFIG_BOARD_HAS_LSE 1
27 #endif
28 
29 /* This board provides an HSE */
30 #ifndef CONFIG_BOARD_HAS_HSE
31 #define CONFIG_BOARD_HAS_HSE 1
32 #endif
33 
34 #include "periph_cpu.h"
35 #include "f0/cfg_clock_default.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 static const timer_conf_t timer_config[] = {
46  {
47  .dev = TIM1,
48  .max = 0x0000ffff,
49  .rcc_mask = RCC_APB2ENR_TIM1EN,
50  .bus = APB2,
51  .irqn = TIM1_CC_IRQn
52  }
53 };
54 
55 #define TIMER_0_ISR (isr_tim1_cc)
56 
57 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
58 
64 static const uart_conf_t uart_config[] = {
65  {
66  .dev = USART2,
67  .rcc_mask = RCC_APB1ENR_USART2EN,
68  .rx_pin = GPIO_PIN(PORT_A, 3),
69  .tx_pin = GPIO_PIN(PORT_A, 2),
70  .rx_af = GPIO_AF1,
71  .tx_af = GPIO_AF1,
72  .bus = APB1,
73  .irqn = USART2_IRQn
74  },
75  {
76  .dev = USART1,
77  .rcc_mask = RCC_APB2ENR_USART1EN,
78  .rx_pin = GPIO_PIN(PORT_A, 10),
79  .tx_pin = GPIO_PIN(PORT_A, 9),
80  .rx_af = GPIO_AF1,
81  .tx_af = GPIO_AF1,
82  .bus = APB2,
83  .irqn = USART1_IRQn
84  }
85 };
86 
87 #define UART_0_ISR (isr_usart2)
88 #define UART_1_ISR (isr_usart1)
89 
90 #define UART_NUMOF ARRAY_SIZE(uart_config)
91 
97 static const pwm_conf_t pwm_config[] = {
98  {
99  .dev = TIM3,
100  .rcc_mask = RCC_APB1ENR_TIM3EN,
101  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0},
102  { .pin = GPIO_PIN(PORT_B, 5) /* D4 */, .cc_chan = 1},
103  { .pin = GPIO_UNDEF, .cc_chan = 0},
104  { .pin = GPIO_UNDEF, .cc_chan = 0} },
105  .af = GPIO_AF1,
106  .bus = APB1
107  },
108  {
109  .dev = TIM15,
110  .rcc_mask = RCC_APB2ENR_TIM15EN,
111  .chan = { { .pin = GPIO_PIN(PORT_B, 14), .cc_chan = 0},
112  { .pin = GPIO_PIN(PORT_B, 15), .cc_chan = 1},
113  { .pin = GPIO_UNDEF, .cc_chan = 0},
114  { .pin = GPIO_UNDEF, .cc_chan = 0} },
115  .af = GPIO_AF1,
116  .bus = APB2
117  }
118 };
119 
120 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
121 
127 static const spi_conf_t spi_config[] = {
128  {
129  .dev = SPI1,
130  .mosi_pin = GPIO_PIN(PORT_A, 7),
131  .miso_pin = GPIO_PIN(PORT_A, 6),
132  .sclk_pin = GPIO_PIN(PORT_A, 5),
133  .cs_pin = GPIO_PIN(PORT_A, 4),
134  .mosi_af = GPIO_AF0,
135  .miso_af = GPIO_AF0,
136  .sclk_af = GPIO_AF0,
137  .cs_af = GPIO_AF0,
138  .rccmask = RCC_APB2ENR_SPI1EN,
139  .apbbus = APB2
140  },
141  {
142  .dev = SPI2,
143  .mosi_pin = GPIO_PIN(PORT_B, 15),
144  .miso_pin = GPIO_PIN(PORT_B, 14),
145  .sclk_pin = GPIO_PIN(PORT_B, 13),
146  .cs_pin = GPIO_PIN(PORT_B, 12),
147  .mosi_af = GPIO_AF0,
148  .miso_af = GPIO_AF0,
149  .sclk_af = GPIO_AF0,
150  .cs_af = GPIO_AF0,
151  .rccmask = RCC_APB1ENR_SPI2EN,
152  .apbbus = APB1
153  },
154 };
155 
156 #define SPI_NUMOF ARRAY_SIZE(spi_config)
157 
163 static const adc_conf_t adc_config[] = {
164  { GPIO_PIN(PORT_A, 0), 0 },
165  { GPIO_PIN(PORT_A, 1), 1 },
166  { GPIO_PIN(PORT_A, 4), 4 },
167  { GPIO_PIN(PORT_B, 0), 8 },
168  { GPIO_PIN(PORT_C, 1), 11 },
169  { GPIO_PIN(PORT_C, 0), 10 }
170 };
171 
172 #define ADC_NUMOF ARRAY_SIZE(adc_config)
173 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* PERIPH_CONF_H */
180 
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
pwm_conf_t
PWM device configuration.
Definition: periph_cpu_common.h:153
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
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
APB2
@ APB2
APB2 bus.
Definition: periph_cpu.h:177
cfg_clock_default.h
Default clock configuration for STM32F0.
GPIO_AF0
@ GPIO_AF0
use alternate function 0
Definition: periph_cpu_common.h:86
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
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
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176