Statistics
| Branch: | Tag: | Revision:

amiro-os / os / modules / DiWheelDrive_1-1 / board.h @ 801d8775

History | View | Annotate | Download (40.78 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2018  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
 * Setup for AMiRo DiWheelDrive board.
24
 */
25
26
/*
27
 * Board identifier.
28
 */
29
#define BOARD_DIWHEELDRIVE
30
#define BOARD_NAME              "AMiRo DiWheelDrive"
31
#define BOARD_VERSION           "1.1"
32
33
/*
34
 * Board oscillators-related settings.
35
 * NOTE: LSE not fitted.
36
 */
37
#if !defined(STM32_LSECLK)
38
#define STM32_LSECLK                0U
39
#endif
40
41
#if !defined(STM32_HSECLK)
42
#define STM32_HSECLK                8000000U
43
#endif
44
45
/*
46
 * Board voltages.
47
 * Required for performance limits calculation.
48
 */
49
#define STM32_VDD                   330U
50
51
/*
52
 * MCU type as defined in the ST header.
53
 */
54
#define STM32F103xE
55
56
/*
57
 * IO pins assignments.
58
 */
59
#define GPIOA_WKUP                  0U
60
#define GPIOA_LED                   1U
61
#define GPIOA_DRIVE_PWM1A           2U
62
#define GPIOA_DRIVE_PWM1B           3U
63
#define GPIOA_PIN4                  4U
64
#define GPIOA_MOTION_SCLK           5U
65
#define GPIOA_MOTION_MISO           6U
66
#define GPIOA_MOTION_MOSI           7U
67
#define GPIOA_PIN8                  8U
68
#define GPIOA_PROG_RX               9U
69
#define GPIOA_PROG_TX               10U
70
#define GPIOA_CAN_RX                11U
71
#define GPIOA_CAN_TX                12U
72
#define GPIOA_SWDIO                 13U
73
#define GPIOA_SWCLK                 14U
74
#define GPIOA_DRIVE_PWM2B           15U
75
76
#define GPIOB_PIN0                  0U
77
#define GPIOB_DRIVE_SENSE2          1U
78
#define GPIOB_POWER_EN              2U
79
#define GPIOB_DRIVE_PWM2A           3U
80
#define GPIOB_PIN4                  4U
81
#define GPIOB_COMPASS_DRDY          5U
82
#define GPIOB_DRIVE_ENC1A           6U
83
#define GPIOB_DRIVE_ENC1B           7U
84
#define GPIOB_COMPASS_SCL           8U
85
#define GPIOB_COMPASS_SDA           9U
86
#define GPIOB_IR_SCL                10U
87
#define GPIOB_IR_SDA                11U
88
#define GPIOB_IR_INT                12U
89
#define GPIOB_GYRO_DRDY             13U
90
#define GPIOB_SYS_UART_UP           14U
91
#define GPIOB_ACCEL_INT_N           15U
92
93
#define GPIOC_DRIVE_SENSE1          0U
94
#define GPIOC_SYS_INT_N             1U
95
#define GPIOC_PIN2                  2U
96
#define GPIOC_PATH_DCSTAT           3U
97
#define GPIOC_PIN4                  4U
98
#define GPIOC_PATH_DCEN             5U
99
#define GPIOC_DRIVE_ENC2B           6U
100
#define GPIOC_DRIVE_ENC2A           7U
101
#define GPIOC_SYS_PD_N              8U
102
#define GPIOC_SYS_REG_EN            9U
103
#define GPIOC_SYS_UART_RX           10U
104
#define GPIOC_SYS_UART_TX           11U
105
#define GPIOC_PIN12                 12U
106
#define GPIOC_ACCEL_SS_N            13U
107
#define GPIOC_GYRO_SS_N             14U
108
#define GPIOC_PIN15                 15U
109
110
#define GPIOD_OSC_IN                0U
111
#define GPIOD_OSC_OUT               1U
112
#define GPIOD_SYS_WARMRST_N         2U
113
#define GPIOD_PIN3                  3U
114
#define GPIOD_PIN4                  4U
115
#define GPIOD_PIN5                  5U
116
#define GPIOD_PIN6                  6U
117
#define GPIOD_PIN7                  7U
118
#define GPIOD_PIN8                  8U
119
#define GPIOD_PIN9                  9U
120
#define GPIOD_PIN10                 10U
121
#define GPIOD_PIN11                 11U
122
#define GPIOD_PIN12                 12U
123
#define GPIOD_PIN13                 13U
124
#define GPIOD_PIN14                 14U
125
#define GPIOD_PIN15                 15U
126
127
#define GPIOE_PIN0                  0U
128
#define GPIOE_PIN1                  1U
129
#define GPIOE_PIN2                  2U
130
#define GPIOE_PIN3                  3U
131
#define GPIOE_PIN4                  4U
132
#define GPIOE_PIN5                  5U
133
#define GPIOE_PIN6                  6U
134
#define GPIOE_PIN7                  7U
135
#define GPIOE_PIN8                  8U
136
#define GPIOE_PIN9                  9U
137
#define GPIOE_PIN10                 10U
138
#define GPIOE_PIN11                 11U
139
#define GPIOE_PIN12                 12U
140
#define GPIOE_PIN13                 13U
141
#define GPIOE_PIN14                 14U
142
#define GPIOE_PIN15                 15U
143
144
#define GPIOF_PIN0                  0U
145
#define GPIOF_PIN1                  1U
146
#define GPIOF_PIN2                  2U
147
#define GPIOF_PIN3                  3U
148
#define GPIOF_PIN4                  4U
149
#define GPIOF_PIN5                  5U
150
#define GPIOF_PIN6                  6U
151
#define GPIOF_PIN7                  7U
152
#define GPIOF_PIN8                  8U
153
#define GPIOF_PIN9                  9U
154
#define GPIOF_PIN10                 10U
155
#define GPIOF_PIN11                 11U
156
#define GPIOF_PIN12                 12U
157
#define GPIOF_PIN13                 13U
158
#define GPIOF_PIN14                 14U
159
#define GPIOF_PIN15                 15U
160
161
#define GPIOG_PIN0                  0U
162
#define GPIOG_PIN1                  1U
163
#define GPIOG_PIN2                  2U
164
#define GPIOG_PIN3                  3U
165
#define GPIOG_PIN4                  4U
166
#define GPIOG_PIN5                  5U
167
#define GPIOG_PIN6                  6U
168
#define GPIOG_PIN7                  7U
169
#define GPIOG_PIN8                  8U
170
#define GPIOG_PIN9                  9U
171
#define GPIOG_PIN10                 10U
172
#define GPIOG_PIN11                 11U
173
#define GPIOG_PIN12                 12U
174
#define GPIOG_PIN13                 13U
175
#define GPIOG_PIN14                 14U
176
#define GPIOG_PIN15                 15U
177
178
/*
179
 * IO lines assignments.
180
 */
181
#define LINE_WKUP                   PAL_LINE(GPIOA, GPIOA_WKUP)
182
#define LINE_LED                    PAL_LINE(GPIOA, GPIOA_LED)
183
#define LINE_DRIVE_PWM1A            PAL_LINE(GPIOA, GPIOA_DRIVE_PWM1A)
184
#define LINE_DRIVE_PWM1B            PAL_LINE(GPIOA, GPIOA_DRIVE_PWM1B)
185
#define LINE_MOTION_SCLK            PAL_LINE(GPIOA, GPIOA_MOTION_SCLK)
186
#define LINE_MOTION_MISO            PAL_LINE(GPIOA, GPIOA_MOTION_MISO)
187
#define LINE_MOTION_MOSI            PAL_LINE(GPIOA, GPIOA_MOTION_MOSI)
188
#define LINE_PROG_RX                PAL_LINE(GPIOA, GPIOA_PROG_RX)
189
#define LINE_PROG_TX                PAL_LINE(GPIOA, GPIOA_PROG_TX)
190
#define LINE_CAN_RX                 PAL_LINE(GPIOA, GPIOA_CAN_RX)
191
#define LINE_CAN_TX                 PAL_LINE(GPIOA, GPIOA_CAN_TX)
192
#define LINE_SWDIO                  PAL_LINE(GPIOA, GPIOA_SWDIO)
193
#define LINE_SWCLK                  PAL_LINE(GPIOA, GPIOA_SWCLK)
194
#define LINE_DRIVE_PWM2B            PAL_LINE(GPIOA, GPIOA_DRIVE_PWM2B)
195
196
#define LINE_DRIVE_SENSE2           PAL_LINE(GPIOB, GPIOB_DRIVE_SENSE2)
197
#define LINE_POWER_EN               PAL_LINE(GPIOB, GPIOB_POWER_EN)
198
#define LINE_DRIVE_PWM2A            PAL_LINE(GPIOB, GPIOB_DRIVE_PWM2A)
199
#define LINE_COMPASS_DRDY           PAL_LINE(GPIOB, GPIOB_COMPASS_DRDY)
200
#define LINE_DRIVE_ENC1A            PAL_LINE(GPIOB, GPIOB_DRIVE_ENC1A)
201
#define LINE_DRIVE_ENC1B            PAL_LINE(GPIOB, GPIOB_DRIVE_ENC1B)
202
#define LINE_COMPASS_SCL            PAL_LINE(GPIOB, GPIOB_COMPASS_SCL)
203
#define LINE_COMPASS_SDA            PAL_LINE(GPIOB, GPIOB_COMPASS_SDA)
204
#define LINE_IR_SCL                 PAL_LINE(GPIOB, GPIOB_IR_SCL)
205
#define LINE_IR_SDA                 PAL_LINE(GPIOB, GPIOB_IR_SDA)
206
#define LINE_IR_INT                 PAL_LINE(GPIOB, GPIOB_IR_INT)
207
#define LINE_GYRO_DRDY              PAL_LINE(GPIOB, GPIOB_GYRO_DRDY)
208
#define LINE_SYS_UART_UP            PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
209
#define LINE_ACCEL_INT_N            PAL_LINE(GPIOB, GPIOB_ACCEL_INT_N)
210
211
#define LINE_DRIVE_SENSE1           PAL_LINE(GPIOC, GPIOC_DRIVE_SENSE1)
212
#define LINE_SYS_INT_N              PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
213
#define LINE_PATH_DCSTAT            PAL_LINE(GPIOC, GPIOC_PATH_DCSTAT)
214
#define LINE_PATH_DCEN              PAL_LINE(GPIOC, GPIOC_PATH_DCEN)
215
#define LINE_DRIVE_ENC2B            PAL_LINE(GPIOC, GPIOC_DRIVE_ENC2B)
216
#define LINE_DRIVE_ENC2A            PAL_LINE(GPIOC, GPIOC_DRIVE_ENC2A)
217
#define LINE_SYS_PD_N               PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
218
#define LINE_SYS_REG_EN             PAL_LINE(GPIOC, GPIOC_SYS_REG_EN)
219
#define LINE_SYS_UART_RX            PAL_LINE(GPIOC, GPIOC_SYS_UART_RX)
220
#define LINE_SYS_UART_TX            PAL_LINE(GPIOC, GPIOC_SYS_UART_TX)
221
#define LINE_ACCEL_SS_N             PAL_LINE(GPIOC, GPIOC_ACCEL_SS_N)
222
#define LINE_GYRO_SS_N              PAL_LINE(GPIOC, GPIOC_GYRO_SS_N)
223
224
#define LINE_OSC_IN                 PAL_LINE(GPIOD, GPIOD_OSC_IN)
225
#define LINE_OSC_OUT                PAL_LINE(GPIOD, GPIOD_OSC_OUT)
226
#define LINE_SYS_WARMRST_N          PAL_LINE(GPIOD, GPIOD_SYS_WARMRST_N)
227
228
/*
229
 * I/O ports initial setup, this configuration is established soon after reset
230
 * in the initialization code.
231
 * Please refer to the STM32 Reference Manual for details.
232
 */
233
#define PIN_MODE_INPUT              0U
234
#define PIN_MODE_OUTPUT_2M          2U
235
#define PIN_MODE_OUTPUT_10M         1U
236
#define PIN_MODE_OUTPUT_50M         3U
237
#define PIN_CNF_INPUT_ANALOG        0U
238
#define PIN_CNF_INPUT_FLOATING      1U
239
#define PIN_CNF_INPUT_PULLX         2U
240
#define PIN_CNF_OUTPUT_PUSHPULL     0U
241
#define PIN_CNF_OUTPUT_OPENDRAIN    1U
242
#define PIN_CNF_ALTERNATE_PUSHPULL  2U
243
#define PIN_CNF_ALTERNATE_OPENDRAIN 3U
244
#define PIN_CR(pin, mode, cnf)      (((mode) | ((cnf) << 2U)) << (((pin) % 8U) * 4U))
245
#define PIN_ODR_LOW(n)              (0U << (n))
246
#define PIN_ODR_HIGH(n)             (1U << (n))
247
248
/*
249
 * GPIOA setup:
250
 *
251
 * PA0  - WKUP                      (input floating)
252
 * PA1  - LED                       (output opendrain high 50MHz)
253
 * PA2  - DRIVE_PWM1A               (alternate pushpull 50MHz)
254
 * PA3  - DRIVE_PWM1B               (alternate pushpull 50MHz)
255
 * PA4  - PIN4                      (input floating)
256
 * PA5  - MOTION_SCLK               (alternate pushpull 50MHz)
257
 * PA6  - MOTION_MISO               (input pullup)
258
 * PA7  - MOTION_MOSI               (alternate pushpull 50MHz)
259
 * PA8  - PIN8                      (input floating)
260
 * PA9  - PROG_RX                   (alternate pushpull 50MHz)
261
 * PA10 - PROG_TX                   (input pullup)
262
 * PA11 - CAN_RX                    (input pullup)
263
 * PA12 - CAN_TX                    (input floating)
264
 * PA13 - SWDIO                     (input pullup)
265
 * PA14 - SWCLK                     (input pullup)
266
 * PA15 - DRIVE_PWM2B               (alternate pushpull 50MHz)
267
 */
268
#define VAL_GPIOACRL                (PIN_CR(GPIOA_WKUP, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
269
                                     PIN_CR(GPIOA_LED, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |            \
270
                                     PIN_CR(GPIOA_DRIVE_PWM1A, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
271
                                     PIN_CR(GPIOA_DRIVE_PWM1B, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
272
                                     PIN_CR(GPIOA_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
273
                                     PIN_CR(GPIOA_MOTION_SCLK, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
274
                                     PIN_CR(GPIOA_MOTION_MISO, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |              \
275
                                     PIN_CR(GPIOA_MOTION_MOSI, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL))
276
#define VAL_GPIOACRH                (PIN_CR(GPIOA_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
277
                                     PIN_CR(GPIOA_PROG_RX, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |      \
278
                                     PIN_CR(GPIOA_PROG_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                  \
279
                                     PIN_CR(GPIOA_CAN_RX, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                   \
280
                                     PIN_CR(GPIOA_CAN_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
281
                                     PIN_CR(GPIOA_SWDIO, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                    \
282
                                     PIN_CR(GPIOA_SWCLK, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                    \
283
                                     PIN_CR(GPIOA_DRIVE_PWM2B, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL))
284
#define VAL_GPIOAODR                (PIN_ODR_HIGH(GPIOA_WKUP) |                                                    \
285
                                     PIN_ODR_HIGH(GPIOA_LED) |                                                     \
286
                                     PIN_ODR_HIGH(GPIOA_DRIVE_PWM1A) |                                             \
287
                                     PIN_ODR_HIGH(GPIOA_DRIVE_PWM1B) |                                             \
288
                                     PIN_ODR_LOW(GPIOA_PIN4) |                                                     \
289
                                     PIN_ODR_HIGH(GPIOA_MOTION_SCLK) |                                             \
290
                                     PIN_ODR_HIGH(GPIOA_MOTION_MISO) |                                             \
291
                                     PIN_ODR_HIGH(GPIOA_MOTION_MOSI) |                                             \
292
                                     PIN_ODR_LOW(GPIOA_PIN8) |                                                     \
293
                                     PIN_ODR_HIGH(GPIOA_PROG_RX) |                                                 \
294
                                     PIN_ODR_HIGH(GPIOA_PROG_TX) |                                                 \
295
                                     PIN_ODR_HIGH(GPIOA_CAN_RX) |                                                  \
296
                                     PIN_ODR_HIGH(GPIOA_CAN_TX) |                                                  \
297
                                     PIN_ODR_HIGH(GPIOA_SWDIO) |                                                   \
298
                                     PIN_ODR_HIGH(GPIOA_SWCLK) |                                                   \
299
                                     PIN_ODR_HIGH(GPIOA_DRIVE_PWM2B))
300
301
/*
302
 * GPIOB setup:
303
 *
304
 * PB0  - PIN0                      (input floating)
305
 * PB1  - DRIVE_SENSE2              (input analog)
306
 * PB2  - POWER_EN                  (output pushpull low 50MHz)
307
 * PB3  - DRIVE_PWM2A               (alternate pushpull 50MHz)
308
 * PB4  - PIN4                      (input floating)
309
 * PB5  - COMPASS_DRDY              (input pullup)
310
 * PB6  - DRIVE_ENC1A               (input floating)
311
 * PB7  - DRIVE_ENC1B               (input floating)
312
 * PB8  - COMPASS_SCL               (alternate opendrain 50MHz)
313
 * PB9  - COMPASS_SDA               (alternate opendrain 50MHz)
314
 * PB10 - IR_SCL                    (alternate opendrain 50MHz)
315
 * PB11 - IR_SDA                    (alternate opendrain 50MHz)
316
 * PB12 - IR_INT                    (input pullup)
317
 * PB13 - GYRO_DRDY                 (input pullup)
318
 * PB14 - SYS_UART_UP               (output opendrain high 50MHz)
319
 * PB15 - ACCEL_INT_N               (input pullup)
320
 */
321
#define VAL_GPIOBCRL                (PIN_CR(GPIOB_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
322
                                     PIN_CR(GPIOB_DRIVE_SENSE2, PIN_MODE_INPUT, PIN_CNF_INPUT_ANALOG) |            \
323
                                     PIN_CR(GPIOB_POWER_EN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |        \
324
                                     PIN_CR(GPIOB_DRIVE_PWM2A, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_PUSHPULL) |  \
325
                                     PIN_CR(GPIOB_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
326
                                     PIN_CR(GPIOB_COMPASS_DRDY, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |             \
327
                                     PIN_CR(GPIOB_DRIVE_ENC1A, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |           \
328
                                     PIN_CR(GPIOB_DRIVE_ENC1B, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
329
#define VAL_GPIOBCRH                (PIN_CR(GPIOB_COMPASS_SCL, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) | \
330
                                     PIN_CR(GPIOB_COMPASS_SDA, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) | \
331
                                     PIN_CR(GPIOB_IR_SCL, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) |      \
332
                                     PIN_CR(GPIOB_IR_SDA, PIN_MODE_OUTPUT_50M, PIN_CNF_ALTERNATE_OPENDRAIN) |      \
333
                                     PIN_CR(GPIOB_IR_INT, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
334
                                     PIN_CR(GPIOB_GYRO_DRDY, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX) |                \
335
                                     PIN_CR(GPIOB_SYS_UART_UP, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |    \
336
                                     PIN_CR(GPIOB_ACCEL_INT_N, PIN_MODE_INPUT, PIN_CNF_INPUT_PULLX))
337
#define VAL_GPIOBODR                (PIN_ODR_LOW(GPIOB_PIN0) |                                                     \
338
                                     PIN_ODR_HIGH(GPIOB_DRIVE_SENSE2) |                                            \
339
                                     PIN_ODR_LOW(GPIOB_POWER_EN) |                                                 \
340
                                     PIN_ODR_HIGH(GPIOB_DRIVE_PWM2A) |                                             \
341
                                     PIN_ODR_LOW(GPIOB_PIN4) |                                                     \
342
                                     PIN_ODR_HIGH(GPIOB_COMPASS_DRDY) |                                            \
343
                                     PIN_ODR_HIGH(GPIOB_DRIVE_ENC1A) |                                             \
344
                                     PIN_ODR_HIGH(GPIOB_DRIVE_ENC1B) |                                             \
345
                                     PIN_ODR_HIGH(GPIOB_COMPASS_SCL) |                                             \
346
                                     PIN_ODR_HIGH(GPIOB_COMPASS_SDA) |                                             \
347
                                     PIN_ODR_HIGH(GPIOB_IR_SCL) |                                                  \
348
                                     PIN_ODR_HIGH(GPIOB_IR_SDA) |                                                  \
349
                                     PIN_ODR_HIGH(GPIOB_IR_INT) |                                                  \
350
                                     PIN_ODR_HIGH(GPIOB_GYRO_DRDY) |                                               \
351
                                     PIN_ODR_HIGH(GPIOB_SYS_UART_UP) |                                             \
352
                                     PIN_ODR_HIGH(GPIOB_ACCEL_INT_N))
353
354
/*
355
 * GPIOC setup:
356
 *
357
 * PC0  - DRIVE_SENSE1              (input analog)
358
 * PC1  - SYS_INT_N                 (output opendrain low 50MHz)
359
 * PC2  - PIN2                      (input floating)
360
 * PC3  - PATH_DCSTAT               (input floating)
361
 * PC4  - PIN4                      (input floating)
362
 * PC5  - PATH_DCEN                 (output pushpull low 50MHz)
363
 * PC6  - DRIVE_ENC2B               (input floating)
364
 * PC7  - DRIVE_ENC2A               (input floating)
365
 * PC8  - SYS_PD_N                  (output opendrain high 50MHz)
366
 * PC9  - SYS_REG_EN                (input floating)
367
 * PC10 - SYS_UART_RX               (input floating)
368
 * PC11 - SYS_UART_TX               (input floating)
369
 * PC12 - PIN12                     (input pullup)
370
 * PC13 - ACCEL_SS_N                (output pushpull high 50MHz)
371
 * PC14 - GYRO_SS_N                 (output pushpull high 50MHz)
372
 * PC15 - PIN15                     (input floating)
373
 */
374
#define VAL_GPIOCCRL                (PIN_CR(GPIOC_DRIVE_SENSE1, PIN_MODE_INPUT, PIN_CNF_INPUT_ANALOG) |            \
375
                                     PIN_CR(GPIOC_SYS_INT_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |           \
376
                                     PIN_CR(GPIOC_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
377
                                     PIN_CR(GPIOC_PATH_DCSTAT, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |           \
378
                                     PIN_CR(GPIOC_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
379
                                     PIN_CR(GPIOC_PATH_DCEN, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |       \
380
                                     PIN_CR(GPIOC_DRIVE_ENC2B, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |           \
381
                                     PIN_CR(GPIOC_DRIVE_ENC2A, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
382
#define VAL_GPIOCCRH                (PIN_CR(GPIOC_SYS_PD_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |       \
383
                                     PIN_CR(GPIOC_SYS_REG_EN, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |            \
384
                                     PIN_CR(GPIOC_SYS_UART_RX, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |           \
385
                                     PIN_CR(GPIOC_SYS_UART_TX, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |           \
386
                                     PIN_CR(GPIOC_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
387
                                     PIN_CR(GPIOC_ACCEL_SS_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |      \
388
                                     PIN_CR(GPIOC_GYRO_SS_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_PUSHPULL) |       \
389
                                     PIN_CR(GPIOC_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
390
#define VAL_GPIOCODR                (PIN_ODR_HIGH(GPIOC_DRIVE_SENSE1) |                                            \
391
                                     PIN_ODR_LOW(GPIOC_SYS_INT_N) |                                                \
392
                                     PIN_ODR_LOW(GPIOC_PIN2) |                                                     \
393
                                     PIN_ODR_HIGH(GPIOC_PATH_DCSTAT) |                                             \
394
                                     PIN_ODR_LOW(GPIOC_PIN4) |                                                     \
395
                                     PIN_ODR_LOW(GPIOC_PATH_DCEN) |                                                \
396
                                     PIN_ODR_HIGH(GPIOC_DRIVE_ENC2B) |                                             \
397
                                     PIN_ODR_HIGH(GPIOC_DRIVE_ENC2A) |                                             \
398
                                     PIN_ODR_HIGH(GPIOC_SYS_PD_N) |                                                \
399
                                     PIN_ODR_HIGH(GPIOC_SYS_REG_EN) |                                              \
400
                                     PIN_ODR_HIGH(GPIOC_SYS_UART_RX) |                                             \
401
                                     PIN_ODR_HIGH(GPIOC_SYS_UART_TX) |                                             \
402
                                     PIN_ODR_LOW(GPIOC_PIN12) |                                                    \
403
                                     PIN_ODR_HIGH(GPIOC_ACCEL_SS_N) |                                              \
404
                                     PIN_ODR_HIGH(GPIOC_GYRO_SS_N) |                                               \
405
                                     PIN_ODR_LOW(GPIOC_PIN15))
406
407
/*
408
 * GPIOD setup:
409
 *
410
 * PD0  - OSC_IN                    (input floating)
411
 * PD1  - OSC_OUT                   (input floating)
412
 * PD2  - SYS_WARMRST_N             (output opendrain high 50MHz)
413
 * PD3  - PIN3                      (input floating)
414
 * PD4  - PIN4                      (input floating)
415
 * PD5  - PIN5                      (input floating)
416
 * PD6  - PIN6                      (input floating)
417
 * PD7  - PIN7                      (input floating)
418
 * PD8  - PIN8                      (input floating)
419
 * PD9  - PIN9                      (input floating)
420
 * PD10 - PIN10                     (input floating)
421
 * PD11 - PIN11                     (input floating)
422
 * PD12 - PIN12                     (input floating)
423
 * PD13 - PIN13                     (input floating)
424
 * PD14 - PIN14                     (input floating)
425
 * PD15 - PIN15                     (input floating)
426
 */
427
#define VAL_GPIODCRL                (PIN_CR(GPIOD_OSC_IN, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                \
428
                                     PIN_CR(GPIOD_OSC_OUT, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |               \
429
                                     PIN_CR(GPIOD_SYS_WARMRST_N, PIN_MODE_OUTPUT_50M, PIN_CNF_OUTPUT_OPENDRAIN) |  \
430
                                     PIN_CR(GPIOD_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
431
                                     PIN_CR(GPIOD_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
432
                                     PIN_CR(GPIOD_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
433
                                     PIN_CR(GPIOD_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
434
                                     PIN_CR(GPIOD_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
435
#define VAL_GPIODCRH                (PIN_CR(GPIOD_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
436
                                     PIN_CR(GPIOD_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
437
                                     PIN_CR(GPIOD_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
438
                                     PIN_CR(GPIOD_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
439
                                     PIN_CR(GPIOD_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
440
                                     PIN_CR(GPIOD_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
441
                                     PIN_CR(GPIOD_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
442
                                     PIN_CR(GPIOD_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
443
#define VAL_GPIODODR                (PIN_ODR_HIGH(GPIOD_OSC_IN) |                                                  \
444
                                     PIN_ODR_HIGH(GPIOD_OSC_OUT) |                                                 \
445
                                     PIN_ODR_HIGH(GPIOD_SYS_WARMRST_N) |                                           \
446
                                     PIN_ODR_LOW(GPIOD_PIN3) |                                                     \
447
                                     PIN_ODR_LOW(GPIOD_PIN4) |                                                     \
448
                                     PIN_ODR_LOW(GPIOD_PIN5) |                                                     \
449
                                     PIN_ODR_LOW(GPIOD_PIN6) |                                                     \
450
                                     PIN_ODR_LOW(GPIOD_PIN7) |                                                     \
451
                                     PIN_ODR_LOW(GPIOD_PIN8) |                                                     \
452
                                     PIN_ODR_LOW(GPIOD_PIN9) |                                                     \
453
                                     PIN_ODR_LOW(GPIOD_PIN10) |                                                    \
454
                                     PIN_ODR_LOW(GPIOD_PIN11) |                                                    \
455
                                     PIN_ODR_LOW(GPIOD_PIN12) |                                                    \
456
                                     PIN_ODR_LOW(GPIOD_PIN13) |                                                    \
457
                                     PIN_ODR_LOW(GPIOD_PIN14) |                                                    \
458
                                     PIN_ODR_LOW(GPIOD_PIN15))
459
460
/*
461
 * GPIOE setup:
462
 *
463
 * PE0  - PIN0                      (input floating)
464
 * PE1  - PIN1                      (input floating)
465
 * PE2  - PIN2                      (input floating)
466
 * PE3  - PIN3                      (input floating)
467
 * PE4  - PIN4                      (input floating)
468
 * PE5  - PIN5                      (input floating)
469
 * PE6  - PIN6                      (input floating)
470
 * PE7  - PIN7                      (input floating)
471
 * PE8  - PIN8                      (input floating)
472
 * PE9  - PIN9                      (input floating)
473
 * PE10 - PIN10                     (input floating)
474
 * PE11 - PIN11                     (input floating)
475
 * PE12 - PIN12                     (input floating)
476
 * PE13 - PIN13                     (input floating)
477
 * PE14 - PIN14                     (input floating)
478
 * PE15 - PIN15                     (input floating)
479
 */
480
#define VAL_GPIOECRL                (PIN_CR(GPIOE_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
481
                                     PIN_CR(GPIOE_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
482
                                     PIN_CR(GPIOE_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
483
                                     PIN_CR(GPIOE_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
484
                                     PIN_CR(GPIOE_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
485
                                     PIN_CR(GPIOE_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
486
                                     PIN_CR(GPIOE_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
487
                                     PIN_CR(GPIOE_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
488
#define VAL_GPIOECRH                (PIN_CR(GPIOE_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
489
                                     PIN_CR(GPIOE_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
490
                                     PIN_CR(GPIOE_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
491
                                     PIN_CR(GPIOE_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
492
                                     PIN_CR(GPIOE_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
493
                                     PIN_CR(GPIOE_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
494
                                     PIN_CR(GPIOE_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
495
                                     PIN_CR(GPIOE_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
496
#define VAL_GPIOEODR                (PIN_ODR_LOW(GPIOE_PIN0) |                                                     \
497
                                     PIN_ODR_LOW(GPIOE_PIN1) |                                                     \
498
                                     PIN_ODR_LOW(GPIOE_PIN2) |                                                     \
499
                                     PIN_ODR_LOW(GPIOE_PIN3) |                                                     \
500
                                     PIN_ODR_LOW(GPIOE_PIN4) |                                                     \
501
                                     PIN_ODR_LOW(GPIOE_PIN5) |                                                     \
502
                                     PIN_ODR_LOW(GPIOE_PIN6) |                                                     \
503
                                     PIN_ODR_LOW(GPIOE_PIN7) |                                                     \
504
                                     PIN_ODR_LOW(GPIOE_PIN8) |                                                     \
505
                                     PIN_ODR_LOW(GPIOE_PIN9) |                                                     \
506
                                     PIN_ODR_LOW(GPIOE_PIN10) |                                                    \
507
                                     PIN_ODR_LOW(GPIOE_PIN11) |                                                    \
508
                                     PIN_ODR_LOW(GPIOE_PIN12) |                                                    \
509
                                     PIN_ODR_LOW(GPIOE_PIN13) |                                                    \
510
                                     PIN_ODR_LOW(GPIOE_PIN14) |                                                    \
511
                                     PIN_ODR_LOW(GPIOE_PIN15))
512
513
/*
514
 * GPIOF setup:
515
 *
516
 * PF0  - PIN0                      (input floating)
517
 * PF1  - PIN1                      (input floating)
518
 * PF2  - PIN2                      (input floating)
519
 * PF3  - PIN3                      (input floating)
520
 * PF4  - PIN4                      (input floating)
521
 * PF5  - PIN5                      (input floating)
522
 * PF6  - PIN6                      (input floating)
523
 * PF7  - PIN7                      (input floating)
524
 * PF8  - PIN8                      (input floating)
525
 * PF9  - PIN9                      (input floating)
526
 * PF10 - PIN10                     (input floating)
527
 * PF11 - PIN11                     (input floating)
528
 * PF12 - PIN12                     (input floating)
529
 * PF13 - PIN13                     (input floating)
530
 * PF14 - PIN14                     (input floating)
531
 * PF15 - PIN15                     (input floating)
532
 */
533
#define VAL_GPIOFCRL                (PIN_CR(GPIOF_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
534
                                     PIN_CR(GPIOF_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
535
                                     PIN_CR(GPIOF_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
536
                                     PIN_CR(GPIOF_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
537
                                     PIN_CR(GPIOF_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
538
                                     PIN_CR(GPIOF_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
539
                                     PIN_CR(GPIOF_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
540
                                     PIN_CR(GPIOF_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
541
#define VAL_GPIOFCRH                (PIN_CR(GPIOF_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
542
                                     PIN_CR(GPIOF_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
543
                                     PIN_CR(GPIOF_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
544
                                     PIN_CR(GPIOF_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
545
                                     PIN_CR(GPIOF_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
546
                                     PIN_CR(GPIOF_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
547
                                     PIN_CR(GPIOF_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
548
                                     PIN_CR(GPIOF_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
549
#define VAL_GPIOFODR                (PIN_ODR_LOW(GPIOF_PIN0) |                                                     \
550
                                     PIN_ODR_LOW(GPIOF_PIN1) |                                                     \
551
                                     PIN_ODR_LOW(GPIOF_PIN2) |                                                     \
552
                                     PIN_ODR_LOW(GPIOF_PIN3) |                                                     \
553
                                     PIN_ODR_LOW(GPIOF_PIN4) |                                                     \
554
                                     PIN_ODR_LOW(GPIOF_PIN5) |                                                     \
555
                                     PIN_ODR_LOW(GPIOF_PIN6) |                                                     \
556
                                     PIN_ODR_LOW(GPIOF_PIN7) |                                                     \
557
                                     PIN_ODR_LOW(GPIOF_PIN8) |                                                     \
558
                                     PIN_ODR_LOW(GPIOF_PIN9) |                                                     \
559
                                     PIN_ODR_LOW(GPIOF_PIN10) |                                                    \
560
                                     PIN_ODR_LOW(GPIOF_PIN11) |                                                    \
561
                                     PIN_ODR_LOW(GPIOF_PIN12) |                                                    \
562
                                     PIN_ODR_LOW(GPIOF_PIN13) |                                                    \
563
                                     PIN_ODR_LOW(GPIOF_PIN14) |                                                    \
564
                                     PIN_ODR_LOW(GPIOF_PIN15))
565
566
/*
567
 * GPIOG setup:
568
 *
569
 * PG0  - PIN0                      (input floating)
570
 * PG1  - PIN1                      (input floating)
571
 * PG2  - PIN2                      (input floating)
572
 * PG3  - PIN3                      (input floating)
573
 * PG4  - PIN4                      (input floating)
574
 * PG5  - PIN5                      (input floating)
575
 * PG6  - PIN6                      (input floating)
576
 * PG7  - PIN7                      (input floating)
577
 * PG8  - PIN8                      (input floating)
578
 * PG9  - PIN9                      (input floating)
579
 * PG10 - PIN10                     (input floating)
580
 * PG11 - PIN11                     (input floating)
581
 * PG12 - PIN12                     (input floating)
582
 * PG13 - PIN13                     (input floating)
583
 * PG14 - PIN14                     (input floating)
584
 * PG15 - PIN15                     (input floating)
585
 */
586
#define VAL_GPIOGCRL                (PIN_CR(GPIOG_PIN0, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
587
                                     PIN_CR(GPIOG_PIN1, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
588
                                     PIN_CR(GPIOG_PIN2, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
589
                                     PIN_CR(GPIOG_PIN3, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
590
                                     PIN_CR(GPIOG_PIN4, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
591
                                     PIN_CR(GPIOG_PIN5, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
592
                                     PIN_CR(GPIOG_PIN6, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
593
                                     PIN_CR(GPIOG_PIN7, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
594
#define VAL_GPIOGCRH                (PIN_CR(GPIOG_PIN8, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
595
                                     PIN_CR(GPIOG_PIN9, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                  \
596
                                     PIN_CR(GPIOG_PIN10, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
597
                                     PIN_CR(GPIOG_PIN11, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
598
                                     PIN_CR(GPIOG_PIN12, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
599
                                     PIN_CR(GPIOG_PIN13, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
600
                                     PIN_CR(GPIOG_PIN14, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING) |                 \
601
                                     PIN_CR(GPIOG_PIN15, PIN_MODE_INPUT, PIN_CNF_INPUT_FLOATING))
602
#define VAL_GPIOGODR                (PIN_ODR_LOW(GPIOG_PIN0) |                                                     \
603
                                     PIN_ODR_LOW(GPIOG_PIN1) |                                                     \
604
                                     PIN_ODR_LOW(GPIOG_PIN2) |                                                     \
605
                                     PIN_ODR_LOW(GPIOG_PIN3) |                                                     \
606
                                     PIN_ODR_LOW(GPIOG_PIN4) |                                                     \
607
                                     PIN_ODR_LOW(GPIOG_PIN5) |                                                     \
608
                                     PIN_ODR_LOW(GPIOG_PIN6) |                                                     \
609
                                     PIN_ODR_LOW(GPIOG_PIN7) |                                                     \
610
                                     PIN_ODR_LOW(GPIOG_PIN8) |                                                     \
611
                                     PIN_ODR_LOW(GPIOG_PIN9) |                                                     \
612
                                     PIN_ODR_LOW(GPIOG_PIN10) |                                                    \
613
                                     PIN_ODR_LOW(GPIOG_PIN11) |                                                    \
614
                                     PIN_ODR_LOW(GPIOG_PIN12) |                                                    \
615
                                     PIN_ODR_LOW(GPIOG_PIN13) |                                                    \
616
                                     PIN_ODR_LOW(GPIOG_PIN14) |                                                    \
617
                                     PIN_ODR_LOW(GPIOG_PIN15))
618
619
#if !defined(_FROM_ASM_)
620
#ifdef __cplusplus
621
extern "C" {
622
#endif
623
  void boardInit(void);
624
#ifdef __cplusplus
625
}
626
#endif
627
#endif /* _FROM_ASM_ */
628
629
#endif /* _BOARD_H_ */