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 /* Adjust PLL factors:
23  - On nucleo-f303k8, there's no HSE and PREDIV is hard-wired to 2
24  - to reach the maximum possible system clock (64MHz) set PLL_MUL to 16
25  so system clock = (HSI8 / 2) * 16 = 64MHz */
26 #define CONFIG_CLOCK_PLL_PREDIV (2)
27 #ifndef CONFIG_CLOCK_PLL_MUL
28 #define CONFIG_CLOCK_PLL_MUL (16)
29 #endif
30 
31 #include "periph_cpu.h"
32 #include "clk_conf.h"
33 #include "cfg_timer_tim2.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
49 static const adc_conf_t adc_config[] = {
50  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
51  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
52  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 4 }, /* ADC1_IN4, fast */
53  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
54  { .pin = GPIO_PIN(PORT_A, 7), .dev = 1, .chan = 4 }, /* ADC2_IN4, fast */
55 };
56 
57 #define ADC_NUMOF ARRAY_SIZE(adc_config)
58 
64 static const dma_conf_t dma_config[] = {
65  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX */
66  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
67  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
68  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
69 };
70 
71 #define DMA_0_ISR isr_dma1_channel2
72 #define DMA_1_ISR isr_dma1_channel3
73 #define DMA_2_ISR isr_dma1_channel4
74 #define DMA_3_ISR isr_dma1_channel7
75 
76 #define DMA_NUMOF ARRAY_SIZE(dma_config)
77 
83 static const uart_conf_t uart_config[] = {
84  {
85  .dev = USART2,
86  .rcc_mask = RCC_APB1ENR_USART2EN,
87  .rx_pin = GPIO_PIN(PORT_A, 15),
88  .tx_pin = GPIO_PIN(PORT_A, 2),
89  .rx_af = GPIO_AF7,
90  .tx_af = GPIO_AF7,
91  .bus = APB1,
92  .irqn = USART2_IRQn,
93 #ifdef MODULE_PERIPH_DMA
94  .dma = 3,
95  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
96 #endif
97  },
98  {
99  .dev = USART1,
100  .rcc_mask = RCC_APB2ENR_USART1EN,
101  .rx_pin = GPIO_PIN(PORT_A, 10),
102  .tx_pin = GPIO_PIN(PORT_A, 9),
103  .rx_af = GPIO_AF7,
104  .tx_af = GPIO_AF7,
105  .bus = APB2,
106  .irqn = USART1_IRQn,
107 #ifdef MODULE_PERIPH_DMA
108  .dma = 2,
109  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
110 #endif
111  }
112 };
113 
114 #define UART_0_ISR (isr_usart2)
115 #define UART_1_ISR (isr_usart1)
116 
117 #define UART_NUMOF ARRAY_SIZE(uart_config)
118 
124 static const pwm_conf_t pwm_config[] = {
125  {
126  .dev = TIM3,
127  .rcc_mask = RCC_APB1ENR_TIM3EN,
128  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
129  { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 3 },
130  { .pin = GPIO_UNDEF, .cc_chan = 0 },
131  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
132  .af = GPIO_AF2,
133  .bus = APB1
134  },
135  {
136  .dev = TIM1,
137  .rcc_mask = RCC_APB2ENR_TIM1EN,
138  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
139  { .pin = GPIO_UNDEF, .cc_chan = 0 },
140  { .pin = GPIO_UNDEF, .cc_chan = 0 },
141  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
142  .af = GPIO_AF6,
143  .bus = APB2
144  }
145 };
146 
147 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
148 
154 static const spi_conf_t spi_config[] = {
155  {
156  .dev = SPI1,
157  .mosi_pin = GPIO_PIN(PORT_B, 5),
158  .miso_pin = GPIO_PIN(PORT_B, 4),
159  .sclk_pin = GPIO_PIN(PORT_B, 3),
160  .cs_pin = GPIO_UNDEF,
161  .mosi_af = GPIO_AF5,
162  .miso_af = GPIO_AF5,
163  .sclk_af = GPIO_AF5,
164  .cs_af = GPIO_AF5,
165  .rccmask = RCC_APB2ENR_SPI1EN,
166  .apbbus = APB2,
167 #ifdef MODULE_PERIPH_DMA
168  .tx_dma = 1,
169  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
170  .rx_dma = 0,
171  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
172 #endif
173  }
174 };
175 
176 #define SPI_NUMOF ARRAY_SIZE(spi_config)
177 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* PERIPH_CONF_H */
184 
DMA_CHAN_CONFIG_UNSUPPORTED
#define DMA_CHAN_CONFIG_UNSUPPORTED
DMA channel/trigger configuration for DMA peripherals without channel/trigger filtering such as the s...
Definition: periph_cpu.h:464
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
adc_conf_t::pin
gpio_t pin
pin to use
Definition: periph_cpu.h:343
dma_conf_t::stream
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:443
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
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
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
GPIO_AF6
@ GPIO_AF6
use alternate function 6
Definition: periph_cpu_common.h:92
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
GPIO_AF2
@ GPIO_AF2
use alternate function 2
Definition: periph_cpu_common.h:88
cfg_timer_tim2.h
Common configuration for STM32 Timer peripheral based on TIM2.
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