Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / NUCLEO-L476RG / board.h @ 542939ea

History | View | Annotate | Download (96.54 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  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-L476RG board.
28
 */
29

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

    
36
/*
37
 * Board oscillators-related settings.
38
 */
39
#if !defined(STM32_LSECLK)
40
#define STM32_LSECLK                32768U
41
#endif
42

    
43
#define STM32_LSEDRV                (3U << 3U)
44

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

    
49
#define STM32_HSE_BYPASS
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 STM32L476xx
61

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

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

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

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

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

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

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

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

    
211
/*
212
 * IO lines assignments.
213
 */
214
#define LINE_ARD_A0                 PAL_LINE(GPIOA, 0U)
215
#define LINE_ACD12_IN5              PAL_LINE(GPIOA, 0U)
216
#define LINE_ARD_A1                 PAL_LINE(GPIOA, 1U)
217
#define LINE_ACD12_IN6              PAL_LINE(GPIOA, 1U)
218
#define LINE_ARD_D1                 PAL_LINE(GPIOA, 2U)
219
#define LINE_USART2_TX              PAL_LINE(GPIOA, 2U)
220
#define LINE_ARD_D0                 PAL_LINE(GPIOA, 3U)
221
#define LINE_USART2_RX              PAL_LINE(GPIOA, 3U)
222
#define LINE_ARD_A2                 PAL_LINE(GPIOA, 4U)
223
#define LINE_ACD12_IN9              PAL_LINE(GPIOA, 4U)
224
#define LINE_ARD_D13                PAL_LINE(GPIOA, 5U)
225
#define LINE_LED_GREEN              PAL_LINE(GPIOA, 5U)
226
#define LINE_ARD_D12                PAL_LINE(GPIOA, 6U)
227
#define LINE_ARD_D11                PAL_LINE(GPIOA, 7U)
228
#define LINE_ARD_D7                 PAL_LINE(GPIOA, 8U)
229
#define LINE_ARD_D8                 PAL_LINE(GPIOA, 9U)
230
#define LINE_ARD_D2                 PAL_LINE(GPIOA, 10U)
231
#define LINE_SWDIO                  PAL_LINE(GPIOA, 13U)
232
#define LINE_SWCLK                  PAL_LINE(GPIOA, 14U)
233
#define LINE_ARD_A3                 PAL_LINE(GPIOB, 0U)
234
#define LINE_ACD12_IN15             PAL_LINE(GPIOB, 0U)
235
#define LINE_ARD_D3                 PAL_LINE(GPIOB, 3U)
236
#define LINE_SWO                    PAL_LINE(GPIOB, 3U)
237
#define LINE_ARD_D5                 PAL_LINE(GPIOB, 4U)
238
#define LINE_ARD_D4                 PAL_LINE(GPIOB, 5U)
239
#define LINE_ARD_D10                PAL_LINE(GPIOB, 6U)
240
#define LINE_ARD_D15                PAL_LINE(GPIOB, 8U)
241
#define LINE_ARD_D14                PAL_LINE(GPIOB, 9U)
242
#define LINE_ARD_D6                 PAL_LINE(GPIOB, 10U)
243
#define LINE_ARD_A5                 PAL_LINE(GPIOC, 0U)
244
#define LINE_ACD123_IN1             PAL_LINE(GPIOC, 0U)
245
#define LINE_ARD_A4                 PAL_LINE(GPIOC, 1U)
246
#define LINE_ACD123_IN2             PAL_LINE(GPIOC, 1U)
247
#define LINE_ARD_D9                 PAL_LINE(GPIOC, 7U)
248
#define LINE_BUTTON                 PAL_LINE(GPIOC, 13U)
249
#define LINE_OSC32_IN               PAL_LINE(GPIOC, 14U)
250
#define LINE_OSC32_OUT              PAL_LINE(GPIOC, 15U)
251
#define LINE_OSC_IN                 PAL_LINE(GPIOH, 0U)
252
#define LINE_OSC_OUT                PAL_LINE(GPIOH, 1U)
253

    
254
/*===========================================================================*/
255
/* Driver pre-compile time settings.                                         */
256
/*===========================================================================*/
257

    
258
/*===========================================================================*/
259
/* Derived constants and error checks.                                       */
260
/*===========================================================================*/
261

    
262
/*===========================================================================*/
263
/* Driver data structures and types.                                         */
264
/*===========================================================================*/
265

    
266
/*===========================================================================*/
267
/* Driver macros.                                                            */
268
/*===========================================================================*/
269

    
270
/*
271
 * I/O ports initial setup, this configuration is established soon after reset
272
 * in the initialization code.
273
 * Please refer to the STM32 Reference Manual for details.
274
 */
275
#define PIN_MODE_INPUT(n)           (0U << ((n) * 2U))
276
#define PIN_MODE_OUTPUT(n)          (1U << ((n) * 2U))
277
#define PIN_MODE_ALTERNATE(n)       (2U << ((n) * 2U))
278
#define PIN_MODE_ANALOG(n)          (3U << ((n) * 2U))
279
#define PIN_ODR_LOW(n)              (0U << (n))
280
#define PIN_ODR_HIGH(n)             (1U << (n))
281
#define PIN_OTYPE_PUSHPULL(n)       (0U << (n))
282
#define PIN_OTYPE_OPENDRAIN(n)      (1U << (n))
283
#define PIN_OSPEED_VERYLOW(n)       (0U << ((n) * 2U))
284
#define PIN_OSPEED_LOW(n)           (1U << ((n) * 2U))
285
#define PIN_OSPEED_MEDIUM(n)        (2U << ((n) * 2U))
286
#define PIN_OSPEED_HIGH(n)          (3U << ((n) * 2U))
287
#define PIN_PUPDR_FLOATING(n)       (0U << ((n) * 2U))
288
#define PIN_PUPDR_PULLUP(n)         (1U << ((n) * 2U))
289
#define PIN_PUPDR_PULLDOWN(n)       (2U << ((n) * 2U))
290
#define PIN_AFIO_AF(n, v)           ((v) << (((n) % 8U) * 4U))
291
#define PIN_ASCR_DISABLED(n)        (0U << (n))
292
#define PIN_ASCR_ENABLED(n)         (1U << (n))
293
#define PIN_LOCKR_DISABLED(n)       (0U << (n))
294
#define PIN_LOCKR_ENABLED(n)        (1U << (n))
295

    
296
/*
297
 * GPIOA setup:
298
 *
299
 * PA0  - ARD_A0 ACD12_IN5          (analog).
300
 * PA1  - ARD_A1 ACD12_IN6          (analog).
301
 * PA2  - ARD_D1 USART2_TX          (alternate 7).
302
 * PA3  - ARD_D0 USART2_RX          (alternate 7).
303
 * PA4  - ARD_A2 ACD12_IN9          (analog).
304
 * PA5  - ARD_D13 LED_GREEN         (output pushpull maximum).
305
 * PA6  - ARD_D12                   (analog).
306
 * PA7  - ARD_D11                   (analog).
307
 * PA8  - ARD_D7                    (analog).
308
 * PA9  - ARD_D8                    (analog).
309
 * PA10 - ARD_D2                    (analog).
310
 * PA11 - PIN11                     (analog).
311
 * PA12 - PIN12                     (analog).
312
 * PA13 - SWDIO                     (alternate 0).
313
 * PA14 - SWCLK                     (alternate 0).
314
 * PA15 - PIN15                     (analog).
315
 */
316
#define VAL_GPIOA_MODER             (PIN_MODE_ANALOG(GPIOA_ARD_A0) |        \
317
                                     PIN_MODE_ANALOG(GPIOA_ARD_A1) |        \
318
                                     PIN_MODE_ALTERNATE(GPIOA_ARD_D1) |     \
319
                                     PIN_MODE_ALTERNATE(GPIOA_ARD_D0) |     \
320
                                     PIN_