boards/nucleo-f446/include/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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 #include "periph_cpu.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 /* 0: no external high speed crystal available
33  * else: actual crystal frequency [in Hz] */
34 #define CLOCK_HSE (8000000U)
35 /* 0: no external low speed crystal available,
36  * 1: external crystal available (always 32.768kHz) */
37 #define CLOCK_LSE (1)
38 /* give the target core clock (HCLK) frequency [in Hz],
39  * maximum: 180MHz */
40 #define CLOCK_CORECLOCK (168000000U)
41 /* peripheral clock setup */
42 #define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1 /* min 25MHz */
43 #define CLOCK_AHB (CLOCK_CORECLOCK / 1)
44 #define CLOCK_APB1_DIV RCC_CFGR_PPRE1_DIV4 /* max 45MHz */
45 #define CLOCK_APB1 (CLOCK_CORECLOCK / 4)
46 #define CLOCK_APB2_DIV RCC_CFGR_PPRE2_DIV2 /* max 90MHz */
47 #define CLOCK_APB2 (CLOCK_CORECLOCK / 2)
48 
54 static const timer_conf_t timer_config[] = {
55  {
56  .dev = TIM5,
57  .max = 0xffffffff,
58  .rcc_mask = RCC_APB1ENR_TIM5EN,
59  .bus = APB1,
60  .irqn = TIM5_IRQn
61  }
62 };
63 
64 #define TIMER_0_ISR isr_tim5
65 
66 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
67 
73 static const uart_conf_t uart_config[] = {
74  {
75  .dev = USART2,
76  .rcc_mask = RCC_APB1ENR_USART2EN,
77  .rx_pin = GPIO_PIN(PORT_A, 3),
78  .tx_pin = GPIO_PIN(PORT_A, 2),
79  .rx_af = GPIO_AF7,
80  .tx_af = GPIO_AF7,
81  .bus = APB1,
82  .irqn = USART2_IRQn,
83 #ifdef UART_USE_DMA
84  .dma_stream = 6,
85  .dma_chan = 4
86 #endif
87  },
88  {
89  .dev = USART3,
90  .rcc_mask = RCC_APB1ENR_USART3EN,
91  .rx_pin = GPIO_PIN(PORT_C, 11),
92  .tx_pin = GPIO_PIN(PORT_C, 10),
93  .rx_af = GPIO_AF7,
94  .tx_af = GPIO_AF7,
95  .bus = APB1,
96  .irqn = USART3_IRQn,
97 #ifdef UART_USE_DMA
98  .dma_stream = 5,
99  .dma_chan = 4
100 #endif
101  },
102  {
103  .dev = USART1,
104  .rcc_mask = RCC_APB2ENR_USART1EN,
105  .rx_pin = GPIO_PIN(PORT_A, 10),
106  .tx_pin = GPIO_PIN(PORT_A, 9),
107  .rx_af = GPIO_AF7,
108  .tx_af = GPIO_AF7,
109  .bus = APB2,
110  .irqn = USART1_IRQn,
111 #ifdef UART_USE_DMA
112  .dma_stream = 4,
113  .dma_chan = 4
114 #endif
115  },
116 };
117 
118 #define UART_0_ISR (isr_usart2)
119 #define UART_0_DMA_ISR (isr_dma1_stream6)
120 #define UART_1_ISR (isr_usart3)
121 #define UART_1_DMA_ISR (isr_dma1_stream5)
122 #define UART_2_ISR (isr_usart1)
123 #define UART_2_DMA_ISR (isr_dma1_stream4)
124 
125 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
126 
132 static const pwm_conf_t pwm_config[] = {
133  {
134  .dev = TIM2,
135  .rcc_mask = RCC_APB1ENR_TIM2EN,
136  .chan = { { .pin = GPIO_PIN(PORT_A, 15), .cc_chan = 0},
137  { .pin = GPIO_PIN(PORT_B, 3), .cc_chan = 1},
138  { .pin = GPIO_PIN(PORT_B, 10), .cc_chan = 2},
139  { .pin = GPIO_PIN(PORT_B, 2), .cc_chan = 3} },
140  .af = GPIO_AF1,
141  .bus = APB1
142  },
143  {
144  .dev = TIM3,
145  .rcc_mask = RCC_APB1ENR_TIM3EN,
146  .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
147  { .pin = GPIO_UNDEF, .cc_chan = 0 },
148  { .pin = GPIO_UNDEF, .cc_chan = 0 },
149  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
150  .af = GPIO_AF2,
151  .bus = APB1
152  },
153  {
154  .dev = TIM8,
155  .rcc_mask = RCC_APB2ENR_TIM8EN,
156  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0},
157  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1},
158  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2},
159  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3} },
160  .af = GPIO_AF3,
161  .bus = APB2
162  },
163 };
164 
165 #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
166 
175 static const uint8_t spi_divtable[2][5] = {
176  { /* for APB1 @ 90000000Hz */
177  7, /* -> 351562Hz */
178  7, /* -> 351562Hz */
179  6, /* -> 703125Hz */
180  3, /* -> 5625000Hz */
181  2 /* -> 11250000Hz */
182  },
183  { /* for APB2 @ 180000000Hz */
184  7, /* -> 703125Hz */
185  7, /* -> 703125Hz */
186  7, /* -> 703125Hz */
187  4, /* -> 5625000Hz */
188  3 /* -> 11250000Hz */
189  }
190 };
191 
192 static const spi_conf_t spi_config[] = {
193  {
194  .dev = SPI1,
195  .mosi_pin = GPIO_PIN(PORT_A, 7),
196  .miso_pin = GPIO_PIN(PORT_A, 6),
197  .sclk_pin = GPIO_PIN(PORT_A, 5),
198  .cs_pin = GPIO_PIN(PORT_A, 4),
199  .af = GPIO_AF5,
200  .rccmask = RCC_APB2ENR_SPI1EN,
201  .apbbus = APB2
202  },
203  {
204  .dev = SPI2,
205  .mosi_pin = GPIO_PIN(PORT_B, 15),
206  .miso_pin = GPIO_PIN(PORT_B, 14),
207  .sclk_pin = GPIO_PIN(PORT_B, 13),
208  .cs_pin = GPIO_PIN(PORT_B, 12),
209  .af = GPIO_AF5,
210  .rccmask = RCC_APB1ENR_SPI2EN,
211  .apbbus = APB1
212  },
213  {
214  .dev = SPI3,
215  .mosi_pin = GPIO_PIN(PORT_C, 12),
216  .miso_pin = GPIO_PIN(PORT_C, 11),
217  .sclk_pin = GPIO_PIN(PORT_C, 10),
218  .cs_pin = GPIO_UNDEF,
219  .af = GPIO_AF6,
220  .rccmask = RCC_APB1ENR_SPI3EN,
221  .apbbus = APB1
222  }
223 };
224 
225 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
226 
233 #define I2C_NUMOF (1U)
234 #define I2C_0_EN 1
235 #define I2C_IRQ_PRIO 1
236 #define I2C_APBCLK (CLOCK_APB1)
237 
238 /* I2C 0 device configuration */
239 #define I2C_0_DEV I2C1
240 #define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
241 #define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
242 #define I2C_0_EVT_IRQ I2C1_EV_IRQn
243 #define I2C_0_EVT_ISR isr_i2c1_ev
244 #define I2C_0_ERR_IRQ I2C1_ER_IRQn
245 #define I2C_0_ERR_ISR isr_i2c1_er
246 /* I2C 0 pin configuration */
247 #define I2C_0_SCL_PORT GPIOB
248 #define I2C_0_SCL_PIN 8
249 #define I2C_0_SCL_AF 4
250 #define I2C_0_SCL_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN))
251 #define I2C_0_SDA_PORT GPIOB
252 #define I2C_0_SDA_PIN 9
253 #define I2C_0_SDA_AF 4
254 #define I2C_0_SDA_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN))
255 
267 #define ADC_NUMOF (6U)
268 #define ADC_CONFIG { \
269  {GPIO_PIN(PORT_A, 0), 0, 0}, \
270  {GPIO_PIN(PORT_A, 1), 0, 1}, \
271  {GPIO_PIN(PORT_A, 4), 0, 4}, \
272  {GPIO_PIN(PORT_B, 0), 0, 8}, \
273  {GPIO_PIN(PORT_C, 1), 0, 11}, \
274  {GPIO_PIN(PORT_C, 0), 0, 10}, \
275 }
276 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* PERIPH_CONF_H */
283 
use alternate function 7
USART_TypeDef * dev
USART device used.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
use alternate function 6
use alternate function 3
use alternate function 1
PWM configuration structure.
LPC_CTxxBx_Type * dev
PWM device.
use alternate function 5
UART device configuration.
#define GPIO_UNDEF
Define a custom GPIO_UNDEF value.
SPI configuration data structure.
cc2538_gptimer_t * dev
timer device
Timer configuration data.
use alternate function 2
cc2538_ssi_t * dev
SSI device.