boards/nucleo32-f303/include/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 #include "periph_cpu.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
35 /* give the target core clock (HCLK) frequency [in Hz],
36  * maximum: 72MHz */
37 #define CLOCK_CORECLOCK (64000000U)
38 /* 0: no external high speed crystal available
39  * else: actual crystal frequency [in Hz] */
40 #define CLOCK_HSE (0U)
41 /* 0: no external low speed crystal available,
42  * 1: external crystal available (always 32.768kHz) */
43 #define CLOCK_LSE (0)
44 /* peripheral clock setup */
45 #define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1
46 #define CLOCK_AHB (CLOCK_CORECLOCK / 1)
47 #define CLOCK_APB1_DIV RCC_CFGR_PPRE1_DIV2 /* max 36MHz */
48 #define CLOCK_APB1 (CLOCK_CORECLOCK / 2)
49 #define CLOCK_APB2_DIV RCC_CFGR_PPRE2_DIV1 /* max 72MHz */
50 #define CLOCK_APB2 (CLOCK_CORECLOCK / 1)
51 
52 /* PLL factors */
53 #define CLOCK_PLL_PREDIV (2)
54 #define CLOCK_PLL_MUL (16)
55 
61 static const timer_conf_t timer_config[] = {
62  {
63  .dev = TIM2,
64  .max = 0xffffffff,
65  .rcc_mask = RCC_APB1ENR_TIM2EN,
66  .bus = APB1,
67  .irqn = TIM2_IRQn
68  }
69 };
70 
71 #define TIMER_0_ISR isr_tim2
72 
73 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
74 
80 static const uart_conf_t uart_config[] = {
81  {
82  .dev = USART2,
83  .rcc_mask = RCC_APB1ENR_USART2EN,
84  .rx_pin = GPIO_PIN(PORT_A, 15),
85  .tx_pin = GPIO_PIN(PORT_A, 2),
86  .rx_af = GPIO_AF7,
87  .tx_af = GPIO_AF7,
88  .bus = APB1,
89  .irqn = USART2_IRQn
90  },
91  {
92  .dev = USART1,
93  .rcc_mask = RCC_APB2ENR_USART1EN,
94  .rx_pin = GPIO_PIN(PORT_A, 10),
95  .tx_pin = GPIO_PIN(PORT_A, 9),
96  .rx_af = GPIO_AF7,
97  .tx_af = GPIO_AF7,
98  .bus = APB2,
99  .irqn = USART1_IRQn
100  }
101 };
102 
103 #define UART_0_ISR (isr_usart2)
104 #define UART_1_ISR (isr_usart1)
105 
106 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
107 
113 static const pwm_conf_t pwm_config[] = {
114  {
115  .dev = TIM3,
116  .rcc_mask = RCC_APB1ENR_TIM3EN,
117  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
118  { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 3 },
119  { .pin = GPIO_UNDEF, .cc_chan = 0 },
120  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
121  .af = GPIO_AF2,
122  .bus = APB1
123  },
124  {
125  .dev = TIM1,
126  .rcc_mask = RCC_APB2ENR_TIM1EN,
127  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
128  { .pin = GPIO_UNDEF, .cc_chan = 0 },
129  { .pin = GPIO_UNDEF, .cc_chan = 0 },
130  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
131  .af = GPIO_AF6,
132  .bus = APB2
133  }
134 };
135 
136 #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
137 
146 static const uint8_t spi_divtable[2][5] = {
147  { /* for APB1 @ 32000000Hz */
148  7, /* -> 125000Hz */
149  5, /* -> 500000Hz */
150  4, /* -> 1000000Hz */
151  2, /* -> 4000000Hz */
152  1 /* -> 8000000Hz */
153  },
154  { /* for APB2 @ 64000000Hz */
155  7, /* -> 250000Hz */
156  6, /* -> 500000Hz */
157  5, /* -> 1000000Hz */
158  3, /* -> 4000000Hz */
159  2 /* -> 8000000Hz */
160  }
161 };
162 
163 static const spi_conf_t spi_config[] = {
164  {
165  .dev = SPI1,
166  .mosi_pin = GPIO_PIN(PORT_B, 5),
167  .miso_pin = GPIO_PIN(PORT_B, 4),
168  .sclk_pin = GPIO_PIN(PORT_B, 3),
169  .cs_pin = GPIO_UNDEF,
170  .af = GPIO_AF0,
171  .rccmask = RCC_APB2ENR_SPI1EN,
172  .apbbus = APB2
173  }
174 };
175 
176 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
177 
183 #define RTC_NUMOF (0U)
184 
190 #define ADC_NUMOF (0)
191 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* PERIPH_CONF_H */
198 
use alternate function 7
void * dev
UART, USART or LEUART device used.
TIMER_TypeDef * dev
TIMER device used.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
use alternate function 6
PWM device configuration.
NRF_TIMER_Type * dev
timer device
use alternate function 0
UART device configuration.
#define GPIO_UNDEF
Define custom value to speficy undefined or unused GPIOs.
SPI module configuration options.
Timer configuration.
use alternate function 2
cc2538_ssi_t * dev
SSI device.