Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / NUCLEO-L476RG / board.h @ ded1ded7

History | View | Annotate | Download (97.1 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-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
 * Identifiers for optional peripherals.
64
 */
65
#define BOARD_MPU6050_CONNECTED     true
66
#define BOARD_VL53L1X_CONNECTED     true
67

    
68

    
69
/*
70
 * IO pins assignments.
71
 */
72
#define GPIOA_ARD_A0                0U
73
#define GPIOA_ADC12_IN5             0U
74
#define GPIOA_ARD_A1                1U
75
#define GPIOA_ADC12_IN6             1U
76
#define GPIOA_ARD_D1                2U
77
#define GPIOA_USART2_TX             2U
78
#define GPIOA_ARD_D0                3U
79
#define GPIOA_USART2_RX             3U
80
#define GPIOA_ARD_A2                4U
81
#define GPIOA_ADC12_IN9             4U
82
#define GPIOA_ARD_D13               5U
83
#define GPIOA_LED_GREEN             5U
84
#define GPIOA_ARD_D12               6U
85
#define GPIOA_ARD_D11               7U
86
#define GPIOA_ARD_D7                8U
87
#define GPIOA_ARD_D8                9U
88
#define GPIOA_ARD_D2                10U
89
#define GPIOA_PIN11                 11U
90
#define GPIOA_PIN12                 12U
91
#define GPIOA_SWDIO                 13U
92
#define GPIOA_SWCLK                 14U
93
#define GPIOA_PIN15                 15U
94

    
95
#define GPIOB_ARD_A3                0U
96
#define GPIOB_ADC12_IN15            0U
97
#define GPIOB_PIN1                  1U
98
#define GPIOB_PIN2                  2U
99
#define GPIOB_ARD_D3                3U
100
#define GPIOB_SWO                   3U
101
#define GPIOB_ARD_D5                4U
102
#define GPIOB_ARD_D4                5U
103
#define GPIOB_ARD_D10               6U
104
#define GPIOB_PIN7                  7U
105
#define GPIOB_ARD_D15               8U
106
#define GPIOB_ARD_D14               9U
107
#define GPIOB_ARD_D6                10U
108
#define GPIOB_PIN11                 11U
109
#define GPIOB_PIN12                 12U
110
#define GPIOB_PIN13                 13U
111
#define GPIOB_PIN14                 14U
112
#define GPIOB_PIN15                 15U
113

    
114
#define GPIOC_ARD_A5                0U
115
#define GPIOC_ADC123_IN1            0U
116
#define GPIOC_ARD_A4                1U
117
#define GPIOC_ADC123_IN2            1U
118
#define GPIOC_PIN2                  2U
119
#define GPIOC_PIN3                  3U
120
#define GPIOC_PIN4                  4U
121
#define GPIOC_PIN5                  5U
122
#define GPIOC_PIN6                  6U
123
#define GPIOC_ARD_D9                7U
124
#define GPIOC_PIN8                  8U
125
#define GPIOC_PIN9                  9U
126
#define GPIOC_PIN10                 10U
127
#define GPIOC_PIN11                 11U
128
#define GPIOC_PIN12                 12U
129
#define GPIOC_BUTTON                13U
130
#define GPIOC_OSC32_IN              14U
131
#define GPIOC_OSC32_OUT             15U
132

    
133
#define GPIOD_PIN0                  0U
134
#define GPIOD_PIN1                  1U
135
#define GPIOD_PIN2                  2U
136
#define GPIOD_PIN3                  3U
137
#define GPIOD_PIN4                  4U
138
#define GPIOD_PIN5                  5U
139
#define GPIOD_PIN6                  6U
140
#define GPIOD_PIN7                  7U
141
#define GPIOD_PIN8                  8U
142
#define GPIOD_PIN9                  9U
143
#define GPIOD_PIN10                 10U
144
#define GPIOD_PIN11                 11U
145
#define GPIOD_PIN12                 12U
146
#define GPIOD_PIN13                 13U
147
#define GPIOD_PIN14                 14U
148
#define GPIOD_PIN15                 15U
149

    
150
#define GPIOE_PIN0                  0U
151
#define GPIOE_PIN1                  1U
152
#define GPIOE_PIN2                  2U
153
#define GPIOE_PIN3                  3U
154
#define GPIOE_PIN4                  4U
155
#define GPIOE_PIN5                  5U
156
#define GPIOE_PIN6                  6U
157
#define GPIOE_PIN7                  7U
158
#define GPIOE_PIN8                  8U
159
#define GPIOE_PIN9                  9U
160
#define GPIOE_PIN10                 10U
161
#define GPIOE_PIN11                 11U
162
#define GPIOE_PIN12                 12U
163
#define GPIOE_PIN13                 13U
164
#define GPIOE_PIN14                 14U
165
#define GPIOE_PIN15                 15U
166

    
167
#define GPIOF_PIN0                  0U
168
#define GPIOF_PIN1                  1U
169
#define GPIOF_PIN2                  2U
170
#define GPIOF_PIN3                  3U
171
#define GPIOF_PIN4                  4U
172
#define GPIOF_PIN5                  5U
173
#define GPIOF_PIN6                  6U
174
#define GPIOF_PIN7                  7U
175
#define GPIOF_PIN8                  8U
176
#define GPIOF_PIN9                  9U
177
#define GPIOF_PIN10                 10U
178
#define GPIOF_PIN11                 11U
179
#define GPIOF_PIN12                 12U
180
#define GPIOF_PIN13                 13U
181
#define GPIOF_PIN14                 14U
182
#define GPIOF_PIN15                 15U
183

    
184
#define GPIOG_PIN0                  0U
185
#define GPIOG_PIN1                  1U
186
#define GPIOG_PIN2                  2U
187
#define GPIOG_PIN3                  3U
188
#define GPIOG_PIN4                  4U
189
#define GPIOG_PIN5                  5U
190
#define GPIOG_PIN6                  6U
191
#define GPIOG_PIN7                  7U
192
#define GPIOG_PIN8                  8U
193
#define GPIOG_PIN9                  9U
194
#define GPIOG_PIN10                 10U
195
#define GPIOG_PIN11                 11U
196
#define GPIOG_PIN12                 12U
197
#define GPIOG_PIN13                 13U
198
#define GPIOG_PIN14                 14U
199
#define GPIOG_PIN15                 15U
200

    
201
#define GPIOH_OSC_IN                0U
202
#define GPIOH_OSC_OUT               1U
203
#define GPIOH_PIN2                  2U
204
#define GPIOH_PIN3                  3U
205
#define GPIOH_PIN4                  4U
206
#define GPIOH_PIN5                  5U
207
#define GPIOH_PIN6                  6U
208
#define GPIOH_PIN7                  7U
209
#define GPIOH_PIN8                  8U
210
#define GPIOH_PIN9                  9U
211
#define GPIOH_PIN10                 10U
212
#define GPIOH_PIN11                 11U
213
#define GPIOH_PIN12                 12U
214
#define GPIOH_PIN13                 13U
215
#define GPIOH_PIN14                 14U
216
#define GPIOH_PIN15                 15U
217

    
218
/*
219
 * IO lines assignments.
220
 */
221
#define LINE_ARD_A0                 PAL_LINE(GPIOA, GPIOA_ARD_A0)
222
#define LINE_ADC12_IN5              PAL_LINE(GPIOA, GPIOA_ADC12_IN5)
223
#define LINE_ARD_A1                 PAL_LINE(GPIOA, GPIOA_ARD_A1)
224
#define LINE_ADC12_IN6              PAL_LINE(GPIOA, GPIOA_ADC12_IN6)
225
#define LINE_ARD_D1                 PAL_LINE(GPIOA, GPIOA_ARD_D1)
226
#define LINE_USART2_TX              PAL_LINE(GPIOA, GPIOA_USART2_TX)
227
#define LINE_ARD_D0                 PAL_LINE(GPIOA, GPIOA_ARD_D0)
228
#define LINE_USART2_RX              PAL_LINE(GPIOA, GPIOA_USART2_RX)
229
#define LINE_ARD_A2                 PAL_LINE(GPIOA, GPIOA_ARD_A2)
230
#define LINE_ADC12_IN9              PAL_LINE(GPIOA, GPIOA_ADC12_IN9)
231
#define LINE_ARD_D13                PAL_LINE(GPIOA, GPIOA_ARD_D13)
232
#define LINE_LED_GREEN              PAL_LINE(GPIOA, GPIOA_LED_GREEN)
233
#define LINE_ARD_D12                PAL_LINE(GPIOA, GPIOA_ARD_D12)
234
#define LINE_ARD_D11                PAL_LINE(GPIOA, GPIOA_ARD_D11)
235
#define LINE_ARD_D7                 PAL_LINE(GPIOA, GPIOA_ARD_D7)
236
#define LINE_ARD_D8                 PAL_LINE(GPIOA, GPIOA_ARD_D8)
237
#define LINE_ARD_D2                 PAL_LINE(GPIOA, GPIOA_ARD_D2)
238
#define LINE_SWDIO                  PAL_LINE(GPIOA, GPIOA_SWDIO)
239
#define LINE_SWCLK                  PAL_LINE(GPIOA, GPIOA_SWCLK)
240

    
241
#define LINE_ARD_A3                 PAL_LINE(GPIOB, GPIOB_ARD_A3)
242
#define LINE_ADC12_IN15             PAL_LINE(GPIOB, GPIOB_ADC12_IN15)
243
#define LINE_ARD_D3                 PAL_LINE(GPIOB, GPIOB_ARD_D3)
244
#define LINE_SWO                    PAL_LINE(GPIOB, GPIOB_SWO)
245
#define LINE_ARD_D5                 PAL_LINE(GPIOB, GPIOB_ARD_D5)
246
#define LINE_ARD_D4                 PAL_LINE(GPIOB, GPIOB_ARD_D4)
247
#define LINE_ARD_D10                PAL_LINE(GPIOB, GPIOB_ARD_D10)
248
#define LINE_ARD_D15                PAL_LINE(GPIOB, GPIOB_ARD_D15)
249
#define LINE_ARD_D14                PAL_LINE(GPIOB, GPIOB_ARD_D14)
250
#define LINE_ARD_D6                 PAL_LINE(GPIOB, GPIOB_ARD_D6)
251

    
252
#define LINE_ARD_A5                 PAL_LINE(GPIOC, GPIOC_ARD_A5)
253
#define LINE_ADC123_IN1             PAL_LINE(GPIOC, GPIOC_ADC123_IN1)
254
#define LINE_ARD_A4                 PAL_LINE(GPIOC, GPIOC_ARD_A4)
255
#define LINE_ADC123_IN2             PAL_LINE(GPIOC, GPIOC_ADC123_IN2)
256
#define LINE_ARD_D9                 PAL_LINE(GPIOC, GPIOC_ARD_D9)
257
#define LINE_BUTTON                 PAL_LINE(GPIOC, GPIOC_BUTTON)
258
#define LINE_OSC32_IN               PAL_LINE(GPIOC, GPIOC_OSC32_IN)
259
#define LINE_OSC32_OUT              PAL_LINE(GPIOC, GPIOC_OSC32_OUT)
260
#define LINE_OSC_IN                 PAL_LINE(GPIOH, GPIOH_OSC_IN)
261
#define LINE_OSC_OUT                PAL_LINE(GPIOH, GPIOH_OSC_OUT)
262

    
263
/*===========================================================================*/
264
/* Driver pre-compile time settings.                                         */
265
/*===========================================================================*/
266

    
267
/*===========================================================================*/
268
/* Derived constants and error checks.                                       */
269
/*===========================================================================*/
270

    
271
/*===========================================================================*/
272
/* Driver data structures and types.                                         */
273
/*===========================================================================*/
274

    
275
/*===========================================================================*/
276
/* Driver macros.                                                            */
277
/*===========================================================================*/
278

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

    
305
/*
306
 * GPIOA setup:
307
 *
308
 * PA0  - ARD_A0 ACD12_IN5          (analog).
309
 * PA1  - ARD_A1 ACD12_IN6          (analog).
310
 * PA2  - ARD_D1 USART2_TX          (alternate 7).
311
 * PA3  - ARD_D0 USART2_RX          (alternate 7).
312
 * PA4  - ARD_A2 ACD12_IN9          (analog).
313
 * PA5  - ARD_D13 LED_GREEN         (output pushpull maximum).
314
 * PA6  - ARD_D12                   (analog).
315
 * PA7  - ARD_D11                   (analog).
316
 * PA8  - ARD_D7                    (analog).
317
 * PA9  - ARD_D8                    (analog).
318
 * PA10 - ARD_D2                    (analog).
319
 * PA11 - PIN11                     (analog).
320
 * PA12 - PIN12                     (analog).
321
 * PA13 - SWDIO                     (alternate 0).
322
 * PA14 - SWCLK                     (alternate 0).
323
 * PA15 - PIN15                     (analog).
324
 */
325