boards/nucleo32-f042/include/periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 OTA keys
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 #include "periph_cpu.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
37 /* give the target core clock (HCLK) frequency [in Hz],
38  * maximum: 48MHz */
39 #define CLOCK_CORECLOCK (48000000U)
40 /* 0: no external high speed crystal available
41  * else: actual crystal frequency [in Hz] */
42 #define CLOCK_HSE (0U)
43 /* 0: no external low speed crystal available,
44  * 1: external crystal available (always 32.768kHz) */
45 #define CLOCK_LSE (0)
46 /* peripheral clock setup */
47 #define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1
48 #define CLOCK_AHB (CLOCK_CORECLOCK / 1)
49 #define CLOCK_APB1_DIV RCC_CFGR_PPRE_DIV1 /* max 48MHz */
50 #define CLOCK_APB1 (CLOCK_CORECLOCK / 1)
51 #define CLOCK_APB2 (CLOCK_APB1)
52 
53 /* PLL factors */
54 #define CLOCK_PLL_PREDIV (2)
55 #define CLOCK_PLL_MUL (12)
56 
63 static const timer_conf_t timer_config[] = {
64  {
65  .dev = TIM2,
66  .max = 0xffffffff,
67  .rcc_mask = RCC_APB1ENR_TIM2EN,
68  .bus = APB1,
69  .irqn = TIM2_IRQn
70  }
71 };
72 
73 #define TIMER_0_ISR isr_tim2
74 
75 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
76 
82 static const uart_conf_t uart_config[] = {
83  {
84  .dev = USART2,
85  .rcc_mask = RCC_APB1ENR_USART2EN,
86  .rx_pin = GPIO_PIN(PORT_A, 15),
87  .tx_pin = GPIO_PIN(PORT_A, 2),
88  .rx_af = GPIO_AF1,
89  .tx_af = GPIO_AF1,
90  .bus = APB1,
91  .irqn = USART2_IRQn
92  },
93  {
94  .dev = USART1,
95  .rcc_mask = RCC_APB2ENR_USART1EN,
96  .rx_pin = GPIO_PIN(PORT_A, 10),
97  .tx_pin = GPIO_PIN(PORT_A, 9),
98  .rx_af = GPIO_AF1,
99  .tx_af = GPIO_AF1,
100  .bus = APB2,
101  .irqn = USART1_IRQn
102  }
103 };
104 
105 #define UART_0_ISR (isr_usart2)
106 #define UART_1_ISR (isr_usart1)
107 
108 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
109 
115 static const pwm_conf_t pwm_config[] = {
116  {
117  .dev = TIM1,
118  .rcc_mask = RCC_APB2ENR_TIM1EN,
119  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
120  { .pin = GPIO_UNDEF, .cc_chan = 0 },
121  { .pin = GPIO_UNDEF, .cc_chan = 0 },
122  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
123  .af = GPIO_AF2,
124  .bus = APB2
125  },
126  {
127  .dev = TIM14,
128  .rcc_mask = RCC_APB1ENR_TIM14EN,
129  .chan = { { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 0 },
130  { .pin = GPIO_UNDEF, .cc_chan = 0 },
131  { .pin = GPIO_UNDEF, .cc_chan = 0 },
132  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
133  .af = GPIO_AF0,
134  .bus = APB1
135  },
136  {
137  .dev = TIM3,
138  .rcc_mask = RCC_APB1ENR_TIM3EN,
139  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
140  { .pin = GPIO_UNDEF, .cc_chan = 0 },
141  { .pin = GPIO_UNDEF, .cc_chan = 0 },
142  { .pin = GPIO_UNDEF, .cc_chan = 0 }},
143  .af = GPIO_AF1,
144  .bus = APB1
145  }
146 };
147 
148 #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
149 
158 static const uint8_t spi_divtable[2][5] = {
159  { /* for APB1 @ 48000000Hz */
160  7, /* -> 187500Hz */
161  6, /* -> 375000Hz */
162  5, /* -> 750000Hz */
163  2, /* -> 6000000Hz */
164  1 /* -> 12000000Hz */
165  },
166  { /* for APB2 @ 48000000Hz */
167  7, /* -> 187500Hz */
168  6, /* -> 375000Hz */
169  5, /* -> 750000Hz */
170  2, /* -> 6000000Hz */
171  1 /* -> 12000000Hz */
172  }
173 };
174 
175 static const spi_conf_t spi_config[] = {
176  {
177  .dev = SPI1,
178  .mosi_pin = GPIO_PIN(PORT_B, 5),
179  .miso_pin = GPIO_PIN(PORT_B, 4),
180  .sclk_pin = GPIO_PIN(PORT_B, 3),
181  .cs_pin = GPIO_UNDEF,
182  .af = GPIO_AF0,
183  .rccmask = RCC_APB2ENR_SPI1EN,
184  .apbbus = APB2
185  }
186 };
187 
188 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
189 
199 #define RTC_NUMOF (0U)
200 
206 #define ADC_CONFIG { \
207  { GPIO_PIN(PORT_A, 0), 0 }, \
208  { GPIO_PIN(PORT_A, 1), 1 }, \
209  { GPIO_PIN(PORT_A, 3), 3 }, \
210  { GPIO_PIN(PORT_A, 4), 4 }, \
211  { GPIO_PIN(PORT_A, 7), 7 } \
212 }
213 
214 #define ADC_NUMOF (5)
215 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* PERIPH_CONF_H */
222 
cc2538_uart_t * dev
pointer to the used UART device
TIMER_TypeDef * dev
TIMER device used.
use alternate function 1
PWM device configuration.
NRF_TIMER_Type * dev
timer device
use alternate function 0
UART device configuration.
SPI module configuration options.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Timer configuration.
use alternate function 2
cc2538_ssi_t * dev
SSI device.