amiro-os / modules / STM32F4Discovery / board.h @ 07ff44a7
History | View | Annotate | Download (85.503 KB)
1 |
/*
|
---|---|
2 |
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
|
3 |
|
4 |
Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
you may not use this file except in compliance with the License.
|
6 |
You may obtain a copy of the License at
|
7 |
|
8 |
http://www.apache.org/licenses/LICENSE-2.0
|
9 |
|
10 |
Unless required by applicable law or agreed to in writing, software
|
11 |
distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
See the License for the specific language governing permissions and
|
14 |
limitations under the License.
|
15 |
*/
|
16 |
|
17 |
/*
|
18 |
* This file has been automatically generated using ChibiStudio board
|
19 |
* generator plugin. Do not edit manually.
|
20 |
*/
|
21 |
|
22 |
#ifndef BOARD_H
|
23 |
#define BOARD_H
|
24 |
|
25 |
/*===========================================================================*/
|
26 |
/* Driver constants. */
|
27 |
/*===========================================================================*/
|
28 |
|
29 |
/*
|
30 |
* Setup for STMicroelectronics STM32F4-Discovery board.
|
31 |
*/
|
32 |
|
33 |
/*
|
34 |
* Board identifier.
|
35 |
*/
|
36 |
#define BOARD_ST_STM32F4_DISCOVERY
|
37 |
#define BOARD_NAME "STMicroelectronics STM32F4-Discovery" |
38 |
|
39 |
/*
|
40 |
* Board oscillators-related settings.
|
41 |
* NOTE: LSE not fitted.
|
42 |
*/
|
43 |
#if !defined(STM32_LSECLK)
|
44 |
#define STM32_LSECLK 0U |
45 |
#endif
|
46 |
|
47 |
#if !defined(STM32_HSECLK)
|
48 |
#define STM32_HSECLK 8000000U |
49 |
#endif
|
50 |
|
51 |
/*
|
52 |
* Board voltages.
|
53 |
* Required for performance limits calculation.
|
54 |
*/
|
55 |
#define STM32_VDD 300U |
56 |
|
57 |
/*
|
58 |
* MCU type as defined in the ST header.
|
59 |
*/
|
60 |
#define STM32F407xx
|
61 |
|
62 |
/*
|
63 |
* IO pins assignments.
|
64 |
*/
|
65 |
#define GPIOA_BUTTON 0U |
66 |
#define GPIOA_PIN1 1U |
67 |
#define GPIOA_PIN2 2U |
68 |
#define GPIOA_PIN3 3U |
69 |
#define GPIOA_LRCK 4U |
70 |
#define GPIOA_SPC 5U |
71 |
#define GPIOA_SDO 6U |
72 |
#define GPIOA_SDI 7U |
73 |
#define GPIOA_PIN8 8U |
74 |
#define GPIOA_VBUS_FS 9U |
75 |
#define GPIOA_OTG_FS_ID 10U |
76 |
#define GPIOA_OTG_FS_DM 11U |
77 |
#define GPIOA_OTG_FS_DP 12U |
78 |
#define GPIOA_SWDIO 13U |
79 |
#define GPIOA_SWCLK 14U |
80 |
#define GPIOA_PIN15 15U |
81 |
|
82 |
#define GPIOB_PIN0 0U |
83 |
#define GPIOB_PIN1 1U |
84 |
#define GPIOB_PIN2 2U |
85 |
#define GPIOB_SWO 3U |
86 |
#define GPIOB_PIN4 4U |
87 |
#define GPIOB_PIN5 5U |
88 |
#define GPIOB_SCL 6U |
89 |
#define GPIOB_PIN7 7U |
90 |
#define GPIOB_PIN8 8U |
91 |
#define GPIOB_SDA 9U |
92 |
#define GPIOB_CLK_IN 10U |
93 |
#define GPIOB_PIN11 11U |
94 |
#define GPIOB_PIN12 12U |
95 |
#define GPIOB_PIN13 13U |
96 |
#define GPIOB_PIN14 14U |
97 |
#define GPIOB_PIN15 15U |
98 |
|
99 |
#define GPIOC_OTG_FS_POWER_ON 0U |
100 |
#define GPIOC_PIN1 1U |
101 |
#define GPIOC_PIN2 2U |
102 |
#define GPIOC_PDM_OUT 3U |
103 |
#define GPIOC_PIN4 4U |
104 |
#define GPIOC_PIN5 5U |
105 |
#define GPIOC_PIN6 6U |
106 |
#define GPIOC_MCLK 7U |
107 |
#define GPIOC_PIN8 8U |
108 |
#define GPIOC_PIN9 9U |
109 |
#define GPIOC_SCLK 10U |
110 |
#define GPIOC_PIN11 11U |
111 |
#define GPIOC_SDIN 12U |
112 |
#define GPIOC_PIN13 13U |
113 |
#define GPIOC_PIN14 14U |
114 |
#define GPIOC_PIN15 15U |
115 |
|
116 |
#define GPIOD_PIN0 0U |
117 |
#define GPIOD_PIN1 1U |
118 |
#define GPIOD_PIN2 2U |
119 |
#define GPIOD_PIN3 3U |
120 |
#define GPIOD_RESET 4U |
121 |
#define GPIOD_OVER_CURRENT 5U |
122 |
#define GPIOD_PIN6 6U |
123 |
#define GPIOD_PIN7 7U |
124 |
#define GPIOD_PIN8 8U |
125 |
#define GPIOD_PIN9 9U |
126 |
#define GPIOD_PIN10 10U |
127 |
#define GPIOD_PIN11 11U |
128 |
#define GPIOD_LED4 12U |
129 |
#define GPIOD_LED3 13U |
130 |
#define GPIOD_LED5 14U |
131 |
#define GPIOD_LED6 15U |
132 |
|
133 |
#define GPIOE_INT1 0U |
134 |
#define GPIOE_INT2 1U |
135 |
#define GPIOE_PIN2 2U |
136 |
#define GPIOE_CS_SPI 3U |
137 |
#define GPIOE_PIN4 4U |
138 |
#define GPIOE_PIN5 5U |
139 |
#define GPIOE_PIN6 6U |
140 |
#define GPIOE_PIN7 7U |
141 |
#define GPIOE_PIN8 8U |
142 |
#define GPIOE_PIN9 9U |
143 |
#define GPIOE_PIN10 10U |
144 |
#define GPIOE_PIN11 11U |
145 |
#define GPIOE_PIN12 12U |
146 |
#define GPIOE_PIN13 13U |
147 |
#define GPIOE_PIN14 14U |
148 |
#define GPIOE_PIN15 15U |
149 |
|
150 |
#define GPIOF_PIN0 0U |
151 |
#define GPIOF_PIN1 1U |
152 |
#define GPIOF_PIN2 2U |
153 |
#define GPIOF_PIN3 3U |
154 |
#define GPIOF_PIN4 4U |
155 |
#define GPIOF_PIN5 5U |
156 |
#define GPIOF_PIN6 6U |
157 |
#define GPIOF_PIN7 7U |
158 |
#define GPIOF_PIN8 8U |
159 |
#define GPIOF_PIN9 9U |
160 |
#define GPIOF_PIN10 10U |
161 |
#define GPIOF_PIN11 11U |
162 |
#define GPIOF_PIN12 12U |
163 |
#define GPIOF_PIN13 13U |
164 |
#define GPIOF_PIN14 14U |
165 |
#define GPIOF_PIN15 15U |
166 |
|
167 |
#define GPIOG_PIN0 0U |
168 |
#define GPIOG_PIN1 1U |
169 |
#define GPIOG_PIN2 2U |
170 |
#define GPIOG_PIN3 3U |
171 |
#define GPIOG_PIN4 4U |
172 |
#define GPIOG_PIN5 5U |
173 |
#define GPIOG_PIN6 6U |
174 |
#define GPIOG_PIN7 7U |
175 |
#define GPIOG_PIN8 8U |
176 |
#define GPIOG_PIN9 9U |
177 |
#define GPIOG_PIN10 10U |
178 |
#define GPIOG_PIN11 11U |
179 |
#define GPIOG_PIN12 12U |
180 |
#define GPIOG_PIN13 13U |
181 |
#define GPIOG_PIN14 14U |
182 |
#define GPIOG_PIN15 15U |
183 |
|
184 |
#define GPIOH_OSC_IN 0U |
185 |
#define GPIOH_OSC_OUT 1U |
186 |
#define GPIOH_PIN2 2U |
187 |
#define GPIOH_PIN3 3U |
188 |
#define GPIOH_PIN4 4U |
189 |
#define GPIOH_PIN5 5U |
190 |
#define GPIOH_PIN6 6U |
191 |
#define GPIOH_PIN7 7U |
192 |
#define GPIOH_PIN8 8U |
193 |
#define GPIOH_PIN9 9U |
194 |
#define GPIOH_PIN10 10U |
195 |
#define GPIOH_PIN11 11U |
196 |
#define GPIOH_PIN12 12U |
197 |
#define GPIOH_PIN13 13U |
198 |
#define GPIOH_PIN14 14U |
199 |
#define GPIOH_PIN15 15U |
200 |
|
201 |
#define GPIOI_PIN0 0U |
202 |
#define GPIOI_PIN1 1U |
203 |
#define GPIOI_PIN2 2U |
204 |
#define GPIOI_PIN3 3U |
205 |
#define GPIOI_PIN4 4U |
206 |
#define GPIOI_PIN5 5U |
207 |
#define GPIOI_PIN6 6U |
208 |
#define GPIOI_PIN7 7U |
209 |
#define GPIOI_PIN8 8U |
210 |
#define GPIOI_PIN9 9U |
211 |
#define GPIOI_PIN10 10U |
212 |
#define GPIOI_PIN11 11U |
213 |
#define GPIOI_PIN12 12U |
214 |
#define GPIOI_PIN13 13U |
215 |
#define GPIOI_PIN14 14U |
216 |
#define GPIOI_PIN15 15U |
217 |
|
218 |
/*
|
219 |
* IO lines assignments.
|
220 |
*/
|
221 |
#define LINE_BUTTON PAL_LINE(GPIOA, 0U) |
222 |
#define LINE_LRCK PAL_LINE(GPIOA, 4U) |
223 |
#define LINE_SPC PAL_LINE(GPIOA, 5U) |
224 |
#define LINE_SDO PAL_LINE(GPIOA, 6U) |
225 |
#define LINE_SDI PAL_LINE(GPIOA, 7U) |
226 |
#define LINE_VBUS_FS PAL_LINE(GPIOA, 9U) |
227 |
#define LINE_OTG_FS_ID PAL_LINE(GPIOA, 10U) |
228 |
#define LINE_OTG_FS_DM PAL_LINE(GPIOA, 11U) |
229 |
#define LINE_OTG_FS_DP PAL_LINE(GPIOA, 12U) |
230 |
#define LINE_SWDIO PAL_LINE(GPIOA, 13U) |
231 |
#define LINE_SWCLK PAL_LINE(GPIOA, 14U) |
232 |
#define LINE_SWO PAL_LINE(GPIOB, 3U) |
233 |
#define LINE_SCL PAL_LINE(GPIOB, 6U) |
234 |
#define LINE_SDA PAL_LINE(GPIOB, 9U) |
235 |
#define LINE_CLK_IN PAL_LINE(GPIOB, 10U) |
236 |
#define LINE_OTG_FS_POWER_ON PAL_LINE(GPIOC, 0U) |
237 |
#define LINE_PDM_OUT PAL_LINE(GPIOC, 3U) |
238 |
#define LINE_MCLK PAL_LINE(GPIOC, 7U) |
239 |
#define LINE_SCLK PAL_LINE(GPIOC, 10U) |
240 |
#define LINE_SDIN PAL_LINE(GPIOC, 12U) |
241 |
#define LINE_RESET PAL_LINE(GPIOD, 4U) |
242 |
#define LINE_OVER_CURRENT PAL_LINE(GPIOD, 5U) |
243 |
#define LINE_LED4 PAL_LINE(GPIOD, 12U) |
244 |
#define LINE_LED3 PAL_LINE(GPIOD, 13U) |
245 |
#define LINE_LED5 PAL_LINE(GPIOD, 14U) |
246 |
#define LINE_LED6 PAL_LINE(GPIOD, 15U) |
247 |
#define LINE_INT1 PAL_LINE(GPIOE, 0U) |
248 |
#define LINE_INT2 PAL_LINE(GPIOE, 1U) |
249 |
#define LINE_CS_SPI PAL_LINE(GPIOE, 3U) |
250 |
#define LINE_OSC_IN PAL_LINE(GPIOH, 0U) |
251 |
#define LINE_OSC_OUT PAL_LINE(GPIOH, 1U) |
252 |
|
253 |
/*===========================================================================*/
|
254 |
/* Driver pre-compile time settings. */
|
255 |
/*===========================================================================*/
|
256 |
|
257 |
/*===========================================================================*/
|
258 |
/* Derived constants and error checks. */
|
259 |
/*===========================================================================*/
|
260 |
|
261 |
/*===========================================================================*/
|
262 |
/* Driver data structures and types. */
|
263 |
/*===========================================================================*/
|
264 |
|
265 |
/*===========================================================================*/
|
266 |
/* Driver macros. */
|
267 |
/*===========================================================================*/
|
268 |
|
269 |
/*
|
270 |
* I/O ports initial setup, this configuration is established soon after reset
|
271 |
* in the initialization code.
|
272 |
* Please refer to the STM32 Reference Manual for details.
|
273 |
*/
|
274 |
#define PIN_MODE_INPUT(n) (0U << ((n) * 2U)) |
275 |
#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) |
276 |
#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U)) |
277 |
#define PIN_MODE_ANALOG(n) (3U << ((n) * 2U)) |
278 |
#define PIN_ODR_LOW(n) (0U << (n)) |
279 |
#define PIN_ODR_HIGH(n) (1U << (n)) |
280 |
#define PIN_OTYPE_PUSHPULL(n) (0U << (n)) |
281 |
#define PIN_OTYPE_OPENDRAIN(n) (1U << (n)) |
282 |
#define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U)) |
283 |
#define PIN_OSPEED_LOW(n) (1U << ((n) * 2U)) |
284 |
#define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U)) |
285 |
#define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U)) |
286 |
#define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U)) |
287 |
#define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U)) |
288 |
#define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U)) |
289 |
#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U)) |
290 |
|
291 |
/*
|
292 |
* GPIOA setup:
|
293 |
*
|
294 |
* PA0 - BUTTON (input floating).
|
295 |
* PA1 - PIN1 (input pullup).
|
296 |
* PA2 - PIN2 (input pullup).
|
297 |
* PA3 - PIN3 (input pullup).
|
298 |
* PA4 - LRCK (alternate 6).
|
299 |
* PA5 - SPC (alternate 5).
|
300 |
* PA6 - SDO (alternate 5).
|
301 |
* PA7 - SDI (alternate 5).
|
302 |
* PA8 - PIN8 (input pullup).
|
303 |
* PA9 - VBUS_FS (input floating).
|
304 |
* PA10 - OTG_FS_ID (alternate 10).
|
305 |
* PA11 - OTG_FS_DM (alternate 10).
|
306 |
* PA12 - OTG_FS_DP (alternate 10).
|
307 |
* PA13 - SWDIO (alternate 0).
|
308 |
* PA14 - SWCLK (alternate 0).
|
309 |
* PA15 - PIN15 (input pullup).
|
310 |
*/
|
311 |
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON) | \
|
312 |
PIN_MODE_INPUT(GPIOA_PIN1) | \ |
313 |
PIN_MODE_ALTERNATE(GPIOA_PIN2) | \ |
314 |
PIN_MODE_ALTERNATE(GPIOA_PIN3) | \ |
315 |
PIN_MODE_ALTERNATE(GPIOA_LRCK) | \ |
316 |
PIN_MODE_ALTERNATE(GPIOA_SPC) | \ |
317 |
PIN_MODE_ALTERNATE(GPIOA_SDO) | \ |
318 |
PIN_MODE_ALTERNATE(GPIOA_SDI) | \ |
319 |
PIN_MODE_INPUT(GPIOA_PIN8) | \ |
320 |
PIN_MODE_INPUT(GPIOA_VBUS_FS) | \ |
321 |
PIN_MODE_ALTERNATE(GPIOA_OTG_FS_ID) | \ |
322 |
|