Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / NUCLEO-F401RE / board.h @ 2745c37f

History | View | Annotate | Download (86.726 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2020  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
#ifndef BOARD_H
20
#define BOARD_H
21

    
22
/*===========================================================================*/
23
/* Driver constants.                                                         */
24
/*===========================================================================*/
25

    
26
/*
27
 * Setup for STMicroelectronics STM32 Nucleo64-F401RE board.
28
 */
29

    
30
/*
31
 * Board identifier.
32
 */
33
#define BOARD_ST_NUCLEO64_F401RE
34
#define BOARD_NAME                  "STMicroelectronics STM32 Nucleo64-F401RE"
35

    
36
/*
37
 * Board oscillators-related settings.
38
 * NOTE: LSE not fitted.
39
 */
40
#if !defined(STM32_LSECLK)
41
#define STM32_LSECLK                0U
42
#endif
43

    
44
#if !defined(STM32_HSECLK)
45
#define STM32_HSECLK                8000000U
46
#endif
47

    
48
#define STM32_HSE_BYPASS
49

    
50
/*
51
 * Board voltages.
52
 * Required for performance limits calculation.
53
 */
54
#define STM32_VDD                   300U
55

    
56
/*
57
 * MCU type as defined in the ST header.
58
 */
59
#define STM32F401xE
60

    
61
/*
62
 * IO pins assignments.
63
 */
64
#define GPIOA_ARD_A0                0U
65
#define GPIOA_ADC1_IN0              0U
66
#define GPIOA_ARD_A1                1U
67
#define GPIOA_ADC1_IN1              1U
68
#define GPIOA_ARD_D1                2U
69
#define GPIOA_USART2_TX             2U
70
#define GPIOA_ARD_D0                3U
71
#define GPIOA_USART2_RX             3U
72
#define GPIOA_ARD_A2                4U
73
#define GPIOA_ADC1_IN4              4U
74
#define GPIOA_ARD_D13               5U
75
#define GPIOA_LED_GREEN             5U
76
#define GPIOA_ARD_D12               6U
77
#define GPIOA_ARD_D11               7U
78
#define GPIOA_ARD_D7                8U
79
#define GPIOA_ARD_D8                9U
80
#define GPIOA_ARD_D2                10U
81
#define GPIOA_OTG_FS_DM             11U
82
#define GPIOA_OTG_FS_DP             12U
83
#define GPIOA_SWDIO                 13U
84
#define GPIOA_SWCLK                 14U
85
#define GPIOA_PIN15                 15U
86

    
87
#define GPIOB_ARD_A3                0U
88
#define GPIOB_ADC1_IN8              0U
89
#define GPIOB_PIN1                  1U
90
#define GPIOB_PIN2                  2U
91
#define GPIOB_ARD_D3                3U
92
#define GPIOB_SWO                   3U
93
#define GPIOB_ARD_D5                4U
94
#define GPIOB_ARD_D4                5U
95
#define GPIOB_ARD_D10               6U
96
#define GPIOB_PIN7                  7U
97
#define GPIOB_ARD_D15               8U
98
#define GPIOB_ARD_D14               9U
99
#define GPIOB_ARD_D6                10U
100
#define GPIOB_PIN11                 11U
101
#define GPIOB_PIN12                 12U
102
#define GPIOB_PIN13                 13U
103
#define GPIOB_PIN14                 14U
104
#define GPIOB_PIN15                 15U
105

    
106
#define GPIOC_ARD_A5                0U
107
#define GPIOC_ADC1_IN10             0U
108
#define GPIOC_ARD_A4                1U
109
#define GPIOC_ADC1_IN11             1U
110
#define GPIOC_PIN2                  2U
111
#define GPIOC_PIN3                  3U
112
#define GPIOC_PIN4                  4U
113
#define GPIOC_PIN5                  5U
114
#define GPIOC_PIN6                  6U
115
#define GPIOC_ARD_D9                7U
116
#define GPIOC_PIN8                  8U
117
#define GPIOC_PIN9                  9U
118
#define GPIOC_PIN10                 10U
119
#define GPIOC_PIN11                 11U
120
#define GPIOC_PIN12                 12U
121
#define GPIOC_BUTTON                13U
122
#define GPIOC_OSC32_IN              14U
123
#define GPIOC_OSC32_OUT             15U
124

    
125
#define GPIOD_PIN0                  0U
126
#define GPIOD_PIN1                  1U
127
#define GPIOD_PIN2                  2U
128
#define GPIOD_PIN3                  3U
129
#define GPIOD_PIN4                  4U
130
#define GPIOD_PIN5                  5U
131
#define GPIOD_PIN6                  6U
132
#define GPIOD_PIN7                  7U
133
#define GPIOD_PIN8                  8U
134
#define GPIOD_PIN9                  9U
135
#define GPIOD_PIN10                 10U
136
#define GPIOD_PIN11                 11U
137
#define GPIOD_PIN12                 12U
138
#define GPIOD_PIN13                 13U
139
#define GPIOD_PIN14                 14U
140
#define GPIOD_PIN15                 15U
141

    
142
#define GPIOE_PIN0                  0U
143
#define GPIOE_PIN1                  1U
144
#define GPIOE_PIN2                  2U
145
#define GPIOE_PIN3                  3U
146
#define GPIOE_PIN4                  4U
147
#define GPIOE_PIN5                  5U
148
#define GPIOE_PIN6                  6U
149
#define GPIOE_PIN7                  7U
150
#define GPIOE_PIN8                  8U
151
#define GPIOE_PIN9                  9U
152
#define GPIOE_PIN10                 10U
153
#define GPIOE_PIN11                 11U
154
#define GPIOE_PIN12                 12U
155
#define GPIOE_PIN13                 13U
156
#define GPIOE_PIN14                 14U
157
#define GPIOE_PIN15                 15U
158

    
159
#define GPIOF_PIN0                  0U
160
#define GPIOF_PIN1                  1U
161
#define GPIOF_PIN2                  2U
162
#define GPIOF_PIN3                  3U
163
#define GPIOF_PIN4                  4U
164
#define GPIOF_PIN5                  5U
165
#define GPIOF_PIN6                  6U
166
#define GPIOF_PIN7                  7U
167
#define GPIOF_PIN8                  8U
168
#define GPIOF_PIN9                  9U
169
#define GPIOF_PIN10                 10U
170
#define GPIOF_PIN11                 11U
171
#define GPIOF_PIN12                 12U
172
#define GPIOF_PIN13                 13U
173
#define GPIOF_PIN14                 14U
174
#define GPIOF_PIN15                 15U
175

    
176
#define GPIOG_PIN0                  0U
177
#define GPIOG_PIN1                  1U
178
#define GPIOG_PIN2                  2U
179
#define GPIOG_PIN3                  3U
180
#define GPIOG_PIN4                  4U
181
#define GPIOG_PIN5                  5U
182
#define GPIOG_PIN6                  6U
183
#define GPIOG_PIN7                  7U
184
#define GPIOG_PIN8                  8U
185
#define GPIOG_PIN9                  9U
186
#define GPIOG_PIN10                 10U
187
#define GPIOG_PIN11                 11U
188
#define GPIOG_PIN12                 12U
189
#define GPIOG_PIN13                 13U
190
#define GPIOG_PIN14                 14U
191
#define GPIOG_PIN15                 15U
192

    
193
#define GPIOH_OSC_IN                0U
194
#define GPIOH_OSC_OUT               1U
195
#define GPIOH_PIN2                  2U
196
#define GPIOH_PIN3                  3U
197
#define GPIOH_PIN4                  4U
198
#define GPIOH_PIN5                  5U
199
#define GPIOH_PIN6                  6U
200
#define GPIOH_PIN7                  7U
201
#define GPIOH_PIN8                  8U
202
#define GPIOH_PIN9                  9U
203
#define GPIOH_PIN10                 10U
204
#define GPIOH_PIN11                 11U
205
#define GPIOH_PIN12                 12U
206
#define GPIOH_PIN13                 13U
207
#define GPIOH_PIN14                 14U
208
#define GPIOH_PIN15                 15U
209

    
210
#define GPIOI_PIN0                  0U
211
#define GPIOI_PIN1                  1U
212
#define GPIOI_PIN2                  2U
213
#define GPIOI_PIN3                  3U
214
#define GPIOI_PIN4                  4U
215
#define GPIOI_PIN5                  5U
216
#define GPIOI_PIN6                  6U
217
#define GPIOI_PIN7                  7U
218
#define GPIOI_PIN8                  8U
219
#define GPIOI_PIN9                  9U
220
#define GPIOI_PIN10                 10U
221
#define GPIOI_PIN11                 11U
222
#define GPIOI_PIN12                 12U
223
#define GPIOI_PIN13                 13U
224
#define GPIOI_PIN14                 14U
225
#define GPIOI_PIN15                 15U
226

    
227
/*
228
 * IO lines assignments.
229
 */
230
#define LINE_ARD_A0                 PAL_LINE(GPIOA, GPIOA_ARD_A0)
231
#define LINE_ADC1_IN0               PAL_LINE(GPIOA, GPIOA_ADC1_IN0)
232
#define LINE_ARD_A1                 PAL_LINE(GPIOA, GPIOA_ARD_A1)
233
#define LINE_ADC1_IN1               PAL_LINE(GPIOA, GPIOA_ADC1_IN1)
234
#define LINE_ARD_D1                 PAL_LINE(GPIOA, GPIOA_ARD_D1)
235
#define LINE_USART2_TX              PAL_LINE(GPIOA, GPIOA_USART2_TX)
236
#define LINE_ARD_D0                 PAL_LINE(GPIOA, GPIOA_ARD_D0)
237
#define LINE_USART2_RX              PAL_LINE(GPIOA, GPIOA_USART2_RX)
238
#define LINE_ARD_A2                 PAL_LINE(GPIOA, GPIOA_ARD_A2)
239
#define LINE_ADC1_IN4               PAL_LINE(GPIOA, GPIOA_ADC1_IN4)
240
#define LINE_ARD_D13                PAL_LINE(GPIOA, GPIOA_ARD_D13)
241
#define LINE_LED_GREEN              PAL_LINE(GPIOA, GPIOA_LED_GREEN)
242
#define LINE_ARD_D12                PAL_LINE(GPIOA, GPIOA_ARD_D12)
243
#define LINE_ARD_D11                PAL_LINE(GPIOA, GPIOA_ARD_D11)
244
#define LINE_ARD_D7                 PAL_LINE(GPIOA, GPIOA_ARD_D7)
245
#define LINE_ARD_D8                 PAL_LINE(GPIOA, GPIOA_ARD_D8)
246
#define LINE_ARD_D2                 PAL_LINE(GPIOA, GPIOA_ARD_D2)
247
#define LINE_OTG_FS_DM              PAL_LINE(GPIOA, GPIOA_OTG_FS_DM)
248
#define LINE_OTG_FS_DP              PAL_LINE(GPIOA, GPIOA_OTG_FS_DP)
249
#define LINE_SWDIO                  PAL_LINE(GPIOA, GPIOA_SWDIO)
250
#define LINE_SWCLK                  PAL_LINE(GPIOA, GPIOA_SWCLK)
251

    
252
#define LINE_ARD_A3                 PAL_LINE(GPIOB, GPIOB_ARD_A3)
253
#define LINE_ADC1_IN8               PAL_LINE(GPIOB, GPIOB_ADC1_IN8)
254
#define LINE_ARD_D3                 PAL_LINE(GPIOB, GPIOB_ARD_D3)
255
#define LINE_SWO                    PAL_LINE(GPIOB, GPIOB_SWO)
256
#define LINE_ARD_D5                 PAL_LINE(GPIOB, GPIOB_ARD_D5)
257
#define LINE_ARD_D4                 PAL_LINE(GPIOB, GPIOB_ARD_D4)
258
#define LINE_ARD_D10                PAL_LINE(GPIOB, GPIOB_ARD_D10)
259
#define LINE_ARD_D15                PAL_LINE(GPIOB, GPIOB_ARD_D15)
260
#define LINE_ARD_D14                PAL_LINE(GPIOB, GPIOB_ARD_D14)
261
#define LINE_ARD_D6                 PAL_LINE(GPIOB, GPIOB_ARD_D6)
262

    
263
#define LINE_ARD_A5                 PAL_LINE(GPIOC, GPIOC_ARD_A5)
264
#define LINE_ADC1_IN10              PAL_LINE(GPIOC, GPIOC_ADC1_IN10)
265
#define LINE_ARD_A4                 PAL_LINE(GPIOC, GPIOC_ARD_A4)
266
#define LINE_ADC1_IN11              PAL_LINE(GPIOC, GPIOC_ADC1_IN11)
267
#define LINE_ARD_D9                 PAL_LINE(GPIOC, GPIOC_ARD_D9)
268
#define LINE_BUTTON                 PAL_LINE(GPIOC, GPIOC_BUTTON)
269
#define LINE_OSC32_IN               PAL_LINE(GPIOC, GPIOC_OSC32_IN)
270
#define LINE_OSC32_OUT              PAL_LINE(GPIOC, GPIOC_OSC32_OUT)
271

    
272
#define LINE_OSC_IN                 PAL_LINE(GPIOH, GPIOH_OSC_IN)
273
#define LINE_OSC_OUT                PAL_LINE(GPIOH, GPIOH_OSC_OUT)
274

    
275
/*===========================================================================*/
276
/* Driver pre-compile time settings.                                         */
277
/*===========================================================================*/
278

    
279
/*===========================================================================*/
280
/* Derived constants and error checks.                                       */
281
/*===========================================================================*/
282

    
283
/*===========================================================================*/
284
/* Driver data structures and types.                                         */
285
/*===========================================================================*/
286

    
287
/*===========================================================================*/
288
/* Driver macros.                                                            */
289
/*===========================================================================*/
290

    
291
/*
292
 * I/O ports initial setup, this configuration is established soon after reset
293
 * in the initialization code.
294
 * Please refer to the STM32 Reference Manual for details.
295
 */
296
#define PIN_MODE_INPUT(n)           (0U << ((n) * 2U))
297
#define PIN_MODE_OUTPUT(n)          (1U << ((n) * 2U))
298
#define PIN_MODE_ALTERNATE(n)       (2U << ((n) * 2U))
299
#define PIN_MODE_ANALOG(n)          (3U << ((n) * 2U))
300
#define PIN_ODR_LOW(n)              (0U << (n))
301
#define PIN_ODR_HIGH(n)             (1U << (n))
302
#define PIN_OTYPE_PUSHPULL(n)       (0U << (n))
303
#define PIN_OTYPE_OPENDRAIN(n)      (1U << (n))
304
#define PIN_OSPEED_VERYLOW(n)       (0U << ((n) * 2U))
305
#define PIN_OSPEED_LOW(n)           (1U << ((n) * 2U))
306
#define PIN_OSPEED_MEDIUM(n)        (2U << ((n) * 2U))
307
#define PIN_OSPEED_HIGH(n)          (3U << ((n) * 2U))
308
#define PIN_PUPDR_FLOATING(n)       (0U << ((n) * 2U))
309
#define PIN_PUPDR_PULLUP(n)         (1U << ((n) * 2U))
310
#define PIN_PUPDR_PULLDOWN(n)       (2U << ((n) * 2U))
311
#define PIN_AFIO_AF(n, v)           ((v) << (((n) % 8U) * 4U))
312

    
313
/*
314
 * GPIOA setup:
315
 *
316
 * PA0  - ARD_A0 ADC1_IN0           (input pullup).
317
 * PA1  - ARD_A1 ADC1_IN1           (input pullup).
318
 * PA2  - ARD_D1 USART2_TX          (alternate 7).
319
 * PA3  - ARD_D0 USART2_RX          (alternate 7).
320
 * PA4  - ARD_A2 ADC1_IN4           (input pullup).
321
 * PA5  - LED_GREEN ARD_D13         (output pushpull high).
322
 * PA6  - ARD_D12                   (input pullup).
323
 * PA7  - ARD_D11                   (input pullup).