periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 /* Add specific clock configuration (HSE, LSE) for this board here */
23 #ifndef CONFIG_BOARD_HAS_LSE
24 #define CONFIG_BOARD_HAS_LSE 1
25 #endif
26 
27 #include "periph_cpu.h"
28 #include "clk_conf.h"
29 #include "cfg_i2c1_pb8_pb9.h"
30 #include "cfg_rtt_default.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const timer_conf_t timer_config[] = {
41  {
42  .dev = TIM2,
43  .max = 0xffffffff,
44  .rcc_mask = RCC_APB1ENR1_TIM2EN,
45  .bus = APB1,
46  .irqn = TIM2_IRQn
47  },
48  {
49  .dev = TIM5,
50  .max = 0xffffffff,
51  .rcc_mask = RCC_APB1ENR1_TIM5EN,
52  .bus = APB1,
53  .irqn = TIM5_IRQn
54  },
55 };
56 
57 #define TIMER_0_ISR isr_tim2
58 #define TIMER_1_ISR isr_tim5
59 
60 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
61 
67 static const uart_conf_t uart_config[] = {
68  {
69  .dev = LPUART1,
70  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
71  .rx_pin = GPIO_PIN(PORT_G, 8),
72  .tx_pin = GPIO_PIN(PORT_G, 7),
73  .rx_af = GPIO_AF8,
74  .tx_af = GPIO_AF8,
75  .bus = APB12,
76  .irqn = LPUART1_IRQn,
77  .type = STM32_LPUART,
78  .clk_src = 0,
79  },
80  {
81  .dev = USART3,
82  .rcc_mask = RCC_APB1ENR1_USART3EN,
83  .rx_pin = GPIO_PIN(PORT_D, 9),
84  .tx_pin = GPIO_PIN(PORT_D, 8),
85  .rx_af = GPIO_AF7,
86  .tx_af = GPIO_AF7,
87  .bus = APB1,
88  .irqn = USART3_IRQn,
89  .type = STM32_USART,
90  .clk_src = 0, /* Use APB clock */
91 #ifdef UART_USE_DMA
92  .dma_stream = 5,
93  .dma_chan = 4
94 #endif
95  }
96 };
97 
98 #define UART_0_ISR (isr_lpuart1)
99 #define UART_1_ISR (isr_usart3)
100 #define UART_1_DMA_ISR (isr_dma1_stream5)
101 
102 #define UART_NUMOF ARRAY_SIZE(uart_config)
103 
109 static const pwm_conf_t pwm_config[] = {
110  {
111  .dev = TIM1,
112  .rcc_mask = RCC_APB2ENR_TIM1EN,
113  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 */, .cc_chan = 0},
114  { .pin = GPIO_PIN(PORT_E, 11) /* D5 */, .cc_chan = 1},
115  { .pin = GPIO_PIN(PORT_E, 13) /* D3 */, .cc_chan = 2},
116  { .pin = GPIO_UNDEF, .cc_chan = 0} },
117  .af = GPIO_AF1,
118  .bus = APB2
119  },
120  {
121  .dev = TIM4,
122  .rcc_mask = RCC_APB1ENR1_TIM4EN,
123  .chan = { { .pin = GPIO_PIN(PORT_D, 15) /* D9 */, .cc_chan = 3},
124  { .pin = GPIO_UNDEF, .cc_chan = 0},
125  { .pin = GPIO_UNDEF, .cc_chan = 0},
126  { .pin = GPIO_UNDEF, .cc_chan = 0} },
127  .af = GPIO_AF2,
128  .bus = APB1
129  },
130 };
131 
132 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
133 
139 static const spi_conf_t spi_config[] = {
140  {
141  .dev = SPI1,
142  .mosi_pin = GPIO_PIN(PORT_A, 7),
143  .miso_pin = GPIO_PIN(PORT_A, 6),
144  .sclk_pin = GPIO_PIN(PORT_A, 5),
145  .cs_pin = GPIO_UNDEF,
146  .mosi_af = GPIO_AF5,
147  .miso_af = GPIO_AF5,
148  .sclk_af = GPIO_AF5,
149  .cs_af = GPIO_AF5,
150  .rccmask = RCC_APB2ENR_SPI1EN,
151  .apbbus = APB2
152  }
153 };
154 
155 #define SPI_NUMOF ARRAY_SIZE(spi_config)
156 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* PERIPH_CONF_H */
163 
GPIO_AF8
@ GPIO_AF8
use alternate function 8
Definition: periph_cpu_common.h:94
PORT_E
@ PORT_E
port E
Definition: periph_cpu.h:40
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
GPIO_AF5
@ GPIO_AF5
use alternate function 5
Definition: periph_cpu_common.h:91
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
PORT_D
@ PORT_D
port D
Definition: periph_cpu.h:39
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
STM32_USART
@ STM32_USART
STM32 USART module type.
Definition: periph_cpu.h:583
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
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
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
GPIO_AF2
@ GPIO_AF2
use alternate function 2
Definition: periph_cpu_common.h:88
STM32_LPUART
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: periph_cpu.h:584
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
spi_conf_t::dev
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:465
PORT_G
@ PORT_G
port G
Definition: periph_cpu.h:42
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176