Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / board.h @ 3cb82b1a

History | View | Annotate | Download (109 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
/**
20
 * @file
21
 * @brief   PowerManagement v1.1 Board specific macros.
22
 *
23
 * @addtogroup powermanagement_board
24
 * @{
25
 */
26

    
27
#ifndef BOARD_H
28
#define BOARD_H
29

    
30
/*
31
 * Setup for AMiRo PowerManagement v1.1 board.
32
 */
33

    
34
/*
35
 * Board identifier.
36
 */
37
#define BOARD_POWERMANAGEMENT_1_1
38
#define BOARD_NAME                      "AMiRo PowerManagement v1.1"
39

    
40
/*
41
 * Board oscillators-related settings.
42
 * NOTE: LSE not fitted.
43
 */
44
#if !defined(STM32_LSECLK)
45
#define STM32_LSECLK                    0U
46
#endif
47

    
48
#if !defined(STM32_HSECLK)
49
#define STM32_HSECLK                    8000000U
50
#endif
51

    
52
/*
53
 * Board voltages.
54
 * Required for performance limits calculation.
55
 */
56
#define STM32_VDD                       330U
57

    
58
/*
59
 * MCU type as defined in the ST header.
60
 */
61
#define STM32F405xx
62

    
63
/*
64
 * STM32F4 alternate function definitions
65
 */
66
#define STM32F4xx_AF_system             0U
67
#define STM32F4xx_AF_TIM1to2            1U
68
#define STM32F4xx_AF_TIM3to5            2U
69
#define STM32F4xx_AF_TIM8to11           3U
70
#define STM32F4xx_AF_I2C1to3            4U
71
#define STM32F4xx_AF_SPI1to2            5U
72
#define STM32F4xx_AF_SPI3               6U
73
#define STM32F4xx_AF_USART1to3          7U
74
#define STM32F4xx_AF_USART4to6          8U
75
#define STM32F4xx_AF_CAN1to2_TIM12to14  9U
76
#define STM32F4xx_AF_OTG_HSFS           10U
77
#define STM32F4xx_AF_ETH                11U
78
#define STM32F4xx_AF_FSMC_SDIO_OTGHS    12U
79
#define STM32F4xx_AF_DCMI               13U
80
#define STM32F4xx_AF_EVENTOUT           15U
81

    
82
/*
83
 * Identifiers for the several sensor rings, which can be attached to the PowerManagement v1.1 module.
84
 */
85
#define BOARD_NOSENSORRING              0
86
#define BOARD_PROXIMITYSENSOR           1
87
#define BOARD_DISTANCESENSOR_VL53L0X    2
88
#define BOARD_DISTANCESENSOR_VL53L1X    3
89

    
90
/*
91
 * Configuration macro to define which type of sensor ring is attached.
92
 */
93
#define BOARD_SENSORRING                BOARD_PROXIMITYSENSOR
94

    
95
/*
96
 * IO pins assignments.
97
 */
98
#define GPIOA_WKUP                      0U
99
#define GPIOA_PIN1                      1U
100
#define GPIOA_SYS_UART_TX               2U
101
#define GPIOA_SYS_UART_RX               3U
102
#define GPIOA_SYS_SPI_SS0_N             4U
103
#define GPIOA_SYS_SPI_SCLK              5U
104
#define GPIOA_SYS_SPI_MISO              6U
105
#define GPIOA_SYS_SPI_MOSI              7U
106
#define GPIOA_SYS_REG_EN                8U
107
#define GPIOA_PROG_RX                   9U
108
#define GPIOA_PROG_TX                   10U
109
#define GPIOA_CAN_RX                    11U
110
#define GPIOA_CAN_TX                    12U
111
#define GPIOA_SWDIO                     13U
112
#define GPIOA_SWCLK                     14U
113
#define GPIOA_SYS_SPI_SS1_N             15U
114

    
115
#define GPIOB_IR_INT1_N                 0U
116
#define GPIOB_VSYS_SENSE                1U
117
#define GPIOB_POWER_EN                  2U
118
#define GPIOB_SYS_UART_DN               3U
119
#define GPIOB_CHARGE_STAT2A             4U
120
#define GPIOB_BUZZER                    5U
121
#define GPIOB_GAUGE_BATLOW2             6U
122
#define GPIOB_GAUGE_BATGD2_N            7U
123
#define GPIOB_GAUGE_SCL2                8U
124
#define GPIOB_GAUGE_SDA2                9U
125
#define GPIOB_GAUGE_SCL1                10U
126
#define GPIOB_GAUGE_SDA1                11U
127
#define GPIOB_LED                       12U
128
#define GPIOB_BT_RTS                    13U
129
#define GPIOB_BT_CTS                    14U
130
#define GPIOB_SYS_UART_UP               15U
131

    
132
#define GPIOC_CHARGE_STAT1A             0U
133
#define GPIOC_GAUGE_BATLOW1             1U
134
#define GPIOC_GAUGE_BATGD1_N            2U
135
#define GPIOC_CHARGE_EN1_N              3U
136
#define GPIOC_IR_INT2_N                 4U
137
#define GPIOC_TOUCH_INT_N               5U
138
#define GPIOC_SYS_DONE                  6U
139
#define GPIOC_SYS_PROG_N                7U
140
#define GPIOC_PATH_DC                   8U
141
#define GPIOC_SYS_SPI_DIR               9U
142
#define GPIOC_BT_RX                     10U
143
#define GPIOC_BT_TX                     11U
144
#define GPIOC_SYS_INT_N                 12U
145
#define GPIOC_SYS_PD_N                  13U
146
#define GPIOC_SYS_WARMRST_N             14U
147
#define GPIOC_BT_RST                    15U
148

    
149
#define GPIOD_PIN0                      0U
150
#define GPIOD_PIN1                      1U
151
#define GPIOD_CHARGE_EN2_N              2U
152
#define GPIOD_PIN3                      3U
153
#define GPIOD_PIN4                      4U
154
#define GPIOD_PIN5                      5U
155
#define GPIOD_PIN6                      6U
156
#define GPIOD_PIN7                      7U
157
#define GPIOD_PIN8                      8U
158
#define GPIOD_PIN9                      9U
159
#define GPIOD_PIN10                     10U
160
#define GPIOD_PIN11                     11U
161
#define GPIOD_PIN12                     12U
162
#define GPIOD_PIN13                     13U
163
#define GPIOD_PIN14                     14U
164
#define GPIOD_PIN15                     15U
165

    
166
#define GPIOE_PIN0                      0U
167
#define GPIOE_PIN1                      1U
168
#define GPIOE_PIN2                      2U
169
#define GPIOE_PIN3                      3U
170
#define GPIOE_PIN4                      4U
171
#define GPIOE_PIN5                      5U
172
#define GPIOE_PIN6                      6U
173
#define GPIOE_PIN7                      7U
174
#define GPIOE_PIN8                      8U
175
#define GPIOE_PIN9                      9U
176
#define GPIOE_PIN10                     10U
177
#define GPIOE_PIN11                     11U
178
#define GPIOE_PIN12                     12U
179
#define GPIOE_PIN13                     13U
180
#define GPIOE_PIN14                     14U
181
#define GPIOE_PIN15                     15U
182

    
183
#define GPIOF_PIN0                      0U
184
#define GPIOF_PIN1                      1U
185
#define GPIOF_PIN2                      2U
186
#define GPIOF_PIN3                      3U
187
#define GPIOF_PIN4                      4U
188
#define GPIOF_PIN5                      5U
189
#define GPIOF_PIN6                      6U
190
#define GPIOF_PIN7                      7U
191
#define GPIOF_PIN8                      8U
192
#define GPIOF_PIN9                      9U
193
#define GPIOF_PIN10                     10U
194
#define GPIOF_PIN11                     11U
195
#define GPIOF_PIN12                     12U
196
#define GPIOF_PIN13                     13U
197
#define GPIOF_PIN14                     14U
198
#define GPIOF_PIN15                     15U
199

    
200
#define GPIOG_PIN0                      0U
201
#define GPIOG_PIN1                      1U
202
#define GPIOG_PIN2                      2U
203
#define GPIOG_PIN3                      3U
204
#define GPIOG_PIN4                      4U
205
#define GPIOG_PIN5                      5U
206
#define GPIOG_PIN6                      6U
207
#define GPIOG_PIN7                      7U
208
#define GPIOG_PIN8                      8U
209
#define GPIOG_PIN9                      9U
210
#define GPIOG_PIN10                     10U
211
#define GPIOG_PIN11                     11U
212
#define GPIOG_PIN12                     12U
213
#define GPIOG_PIN13                     13U
214
#define GPIOG_PIN14                     14U
215
#define GPIOG_PIN15                     15U
216

    
217
#define GPIOH_OSC_IN                    0U
218
#define GPIOH_OSC_OUT                   1U
219
#define GPIOH_PIN2                      2U
220
#define GPIOH_PIN3                      3U
221
#define GPIOH_PIN4                      4U
222
#define GPIOH_PIN5                      5U
223
#define GPIOH_PIN6                      6U
224
#define GPIOH_PIN7                      7U
225
#define GPIOH_PIN8                      8U
226
#define GPIOH_PIN9                      9U
227
#define GPIOH_PIN10                     10U
228
#define GPIOH_PIN11                     11U
229
#define GPIOH_PIN12                     12U
230
#define GPIOH_PIN13                     13U
231
#define GPIOH_PIN14                     14U
232
#define GPIOH_PIN15                     15U
233

    
234
#define GPIOI_PIN0                      0U
235
#define GPIOI_PIN1                      1U
236
#define GPIOI_PIN2                      2U
237
#define GPIOI_PIN3                      3U
238
#define GPIOI_PIN4                      4U
239
#define GPIOI_PIN5                      5U
240
#define GPIOI_PIN6                      6U
241
#define GPIOI_PIN7                      7U
242
#define GPIOI_PIN8                      8U
243
#define GPIOI_PIN9                      9U
244
#define GPIOI_PIN10                     10U
245
#define GPIOI_PIN11                     11U
246
#define GPIOI_PIN12                     12U
247
#define GPIOI_PIN13                     13U
248
#define GPIOI_PIN14                     14U
249
#define GPIOI_PIN15                     15U
250

    
251
/*
252
 * IO lines assignments.
253
 */
254
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
255
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
256
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
257
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
258
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
259
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
260
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
261
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
262
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
263
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
264
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
265
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
266
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
267
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
268
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
269

    
270
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
271
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
272
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
273
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
274
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
275
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
276
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
277
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
278
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
279
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
280
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
281
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
282
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
283
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
284
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
285
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
286

    
287
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
288
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
289
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
290
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
291
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
292
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
293
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
294
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
295
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
296
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
297
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
298
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
299
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
300
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
301
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
302
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
303

    
304
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
305

    
306
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
307
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
308

    
309
/*
310
 * I/O ports initial setup, this configuration is established soon after reset
311
 * in the initialization code.
312
 * Please refer to the STM32 Reference Manual for details.
313
 */
314
#define PIN_IGNORE(n)                   (1U << (n))
315
#define PIN_MODE_INPUT(n)               (0U << ((n) * 2U))
316
#define PIN_MODE_OUTPUT(n)              (1U << ((n) * 2U))
317
#define PIN_MODE_ALTERNATE(n)           (2U << ((n) * 2U))
318
#define PIN_MODE_ANALOG(n)              (3U << ((n) * 2U))
319
#define PIN_ODR_LOW(n)                  (0U << (n))
320
#define PIN_ODR_HIGH(n)                 (1U << (n))
321
#define PIN_OTYPE_PUSHPULL(n)           (0U << (n))
322
#define PIN_OTYPE_OPENDRAIN(n)          (1U << (n))
323
#define PIN_OSPEED_LOW(n)               (0U << ((n) * 2U))
324
#define PIN_OSPEED_MEDIUM(n)            (1U << ((n) * 2U))
325
#define PIN_OSPEED_HIGH(n)              (2U << ((n) * 2U))
326
#define PIN_OSPEED_VERYHIGH(n)          (3U << ((n) * 2U))
327
#define PIN_PUPDR_FLOATING(n)           (0U << ((n) * 2U))
328
#define PIN_PUPDR_PULLUP(n)             (1U << ((n) * 2U))
329
#define PIN_PUPDR_PULLDOWN(n)           (2U << ((n) * 2U))
330
#define PIN_AFIO_AF(n, v)               ((v) << (((n) % 8U) * 4U))
331

    
332
/*
333
 * GPIOA setup:
334
 *
335
 * PA0  - WKUP                          (input floating)
336
 * PA1  - PIN1                          (input pullup)
337
 * PA2  - SYS_UART_TX                   (input floating)
338
 * PA3  - SYS_UART_RX                   (alternate 7 pushpull floating)
339
 * PA4  - SYS_SPI_SS0_N                 (input floating)
340
 * PA5  - SYS_SPI_SCLK                  (alternate 5 pushpull floating)
341
 * PA6  - SYS_SPI_MISO                  (alternate 5 pushpull floating)
342
 * PA7  - SYS_SPI_MOSI                  (alternate 5 pushpull floating)
343
 * PA8  - SYS_REG_EN                    (output pushpull high)
344
 * PA9  - PROG_RX                       (alternate 7 pushpull floating)
345
 * PA10 - PROG_TX                       (alternate 7 pushpull pullup)
346
 * PA11 - CAN_RX                        (alternate 9 pushpull floating)
347
 * PA12 - CAN_TX                        (alternate 9 pushpull floating)
348
 * PA13 - SWDIO                         (alternate 0 pushpull floating)
349
 * PA14 - SWCLK                         (alternate 0 pushpull floating)
350
 * PA15 - SYS_SPI_SS1_N                 (input floating)
351
 */
352
#define VAL_GPIOA_IGNORE                0
353
#define VAL_GPIOA_MODER                 (PIN_MODE_INPUT(GPIOA_WKUP) |                                 \
354
                                         PIN_MODE_INPUT(GPIOA_PIN1) |                                 \
355
                                         PIN_MODE_INPUT(GPIOA_SYS_UART_TX) |                          \
356
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_UART_RX) |                      \
357
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS0_N) |                        \
358
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_SCLK) |                     \
359
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MISO) |                     \
360
                                         PIN_MODE_ALTERNATE(GPIOA_SYS_SPI_MOSI) |                     \
361
                                         PIN_MODE_OUTPUT(GPIOA_SYS_REG_EN) |                          \
362
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_RX) |                          \
363
                                         PIN_MODE_ALTERNATE(GPIOA_PROG_TX) |                          \
364
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_RX) |                           \
365
                                         PIN_MODE_ALTERNATE(GPIOA_CAN_TX) |                           \
366
                                         PIN_MODE_ALTERNATE(GPIOA_SWDIO) |                            \
367
                                         PIN_MODE_ALTERNATE(GPIOA_SWCLK) |                            \
368
                                         PIN_MODE_INPUT(GPIOA_SYS_SPI_SS1_N))
369
#define VAL_GPIOA_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOA_WKUP) |                             \
370
                                         PIN_OTYPE_PUSHPULL(GPIOA_PIN1) |                             \
371
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_TX) |                      \
372
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_UART_RX) |                      \
373
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS0_N) |                    \
374
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SCLK) |                     \
375
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MISO) |                     \
376
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_MOSI) |                     \
377
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_REG_EN) |                       \
378
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_RX) |                          \
379
                                         PIN_OTYPE_PUSHPULL(GPIOA_PROG_TX) |                          \
380
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_RX) |                           \
381
                                         PIN_OTYPE_PUSHPULL(GPIOA_CAN_TX) |                           \
382
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWDIO) |                            \
383
                                         PIN_OTYPE_PUSHPULL(GPIOA_SWCLK) |                            \
384
                                         PIN_OTYPE_PUSHPULL(GPIOA_SYS_SPI_SS1_N))
385
#define VAL_GPIOA_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOA_WKUP) |                            \
386
                                         PIN_OSPEED_VERYHIGH(GPIOA_PIN1) |                            \
387
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_TX) |                     \
388
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_UART_RX) |                     \
389
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS0_N) |                   \
390
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SCLK) |                    \
391
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MISO) |                    \
392
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_MOSI) |                    \
393
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_REG_EN) |                      \
394
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_RX) |                         \
395
                                         PIN_OSPEED_VERYHIGH(GPIOA_PROG_TX) |                         \
396
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_RX) |                          \
397
                                         PIN_OSPEED_VERYHIGH(GPIOA_CAN_TX) |                          \
398
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWDIO) |                           \
399
                                         PIN_OSPEED_VERYHIGH(GPIOA_SWCLK) |                           \
400
                                         PIN_OSPEED_VERYHIGH(GPIOA_SYS_SPI_SS1_N))
401
#define VAL_GPIOA_PUPDR                 (PIN_PUPDR_FLOATING(GPIOA_WKUP) |                             \
402
                                         PIN_PUPDR_PULLUP(GPIOA_PIN1) |                               \
403
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_TX) |                      \
404
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_UART_RX) |                      \
405
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS0_N) |                    \
406
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SCLK) |                     \
407
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MISO) |                     \
408
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_MOSI) |                     \
409
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_REG_EN) |                       \
410
                                         PIN_PUPDR_FLOATING(GPIOA_PROG_RX) |                          \
411
                                         PIN_PUPDR_PULLUP(GPIOA_PROG_TX) |                            \
412
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_RX) |                           \
413
                                         PIN_PUPDR_FLOATING(GPIOA_CAN_TX) |                           \
414
                                         PIN_PUPDR_FLOATING(GPIOA_SWDIO) |                            \
415
                                         PIN_PUPDR_FLOATING(GPIOA_SWCLK) |                            \
416
                                         PIN_PUPDR_FLOATING(GPIOA_SYS_SPI_SS1_N))
417
#define VAL_GPIOA_ODR                   (PIN_ODR_HIGH(GPIOA_WKUP) |                                   \
418
                                         PIN_ODR_HIGH(GPIOA_PIN1) |                                   \
419
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_TX) |                            \
420
                                         PIN_ODR_HIGH(GPIOA_SYS_UART_RX) |                            \
421
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS0_N) |                          \
422
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SCLK) |                           \
423
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MISO) |                           \
424
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_MOSI) |                           \
425
                                         PIN_ODR_HIGH(GPIOA_SYS_REG_EN) |                             \
426
                                         PIN_ODR_HIGH(GPIOA_PROG_RX) |                                \
427
                                         PIN_ODR_HIGH(GPIOA_PROG_TX) |                                \
428
                                         PIN_ODR_HIGH(GPIOA_CAN_RX) |                                 \
429
                                         PIN_ODR_HIGH(GPIOA_CAN_TX) |                                 \
430
                                         PIN_ODR_HIGH(GPIOA_SWDIO) |                                  \
431
                                         PIN_ODR_HIGH(GPIOA_SWCLK) |                                  \
432
                                         PIN_ODR_HIGH(GPIOA_SYS_SPI_SS1_N))
433
#define VAL_GPIOA_AFRL                  (PIN_AFIO_AF(GPIOA_WKUP, STM32F4xx_AF_system) |               \
434
                                         PIN_AFIO_AF(GPIOA_PIN1, STM32F4xx_AF_system) |               \
435
                                         PIN_AFIO_AF(GPIOA_SYS_UART_TX, STM32F4xx_AF_USART1to3) |     \
436
                                         PIN_AFIO_AF(GPIOA_SYS_UART_RX, STM32F4xx_AF_USART1to3) |     \
437
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS0_N, STM32F4xx_AF_system) |      \
438
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SCLK, STM32F4xx_AF_SPI1to2) |      \
439
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MISO, STM32F4xx_AF_SPI1to2) |      \
440
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_MOSI, STM32F4xx_AF_SPI1to2))
441
#define VAL_GPIOA_AFRH                  (PIN_AFIO_AF(GPIOA_SYS_REG_EN, STM32F4xx_AF_system) |         \
442
                                         PIN_AFIO_AF(GPIOA_PROG_RX, STM32F4xx_AF_USART1to3) |         \
443
                                         PIN_AFIO_AF(GPIOA_PROG_TX, STM32F4xx_AF_USART1to3) |         \
444
                                         PIN_AFIO_AF(GPIOA_CAN_RX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
445
                                         PIN_AFIO_AF(GPIOA_CAN_TX, STM32F4xx_AF_CAN1to2_TIM12to14) |  \
446
                                         PIN_AFIO_AF(GPIOA_SWDIO, STM32F4xx_AF_system) |              \
447
                                         PIN_AFIO_AF(GPIOA_SWCLK, STM32F4xx_AF_system) |              \
448
                                         PIN_AFIO_AF(GPIOA_SYS_SPI_SS1_N, STM32F4xx_AF_system))
449

    
450
/*
451
 * GPIOB setup:
452
 *
453
 * PB0  - IR_INT1_N                     (input floating)
454
 * PB1  - VSYS_SENSE                    (analog)
455
 * PB2  - POWER_EN                      (output pushpull high)
456
 * PB3  - SYS_UART_DN                   (output opendrain high)
457
 * PB4  - CHARGE_STAT2A                 (inout floating)
458
 * PB5  - BUZZER                        (alternate 2 pushpull floating)
459
 * PB6  - GAUGE_BATLOW2                 (input floating)
460
 * PB7  - GAUGE_BATGD2_N                (input floating)
461
 * PB8  - GAUGE_SCL2                    (alternate 4 opendrain floating)
462
 * PB9  - GAUGE_SDA2                    (alternate 4 opendrain floating)
463
 * PB10 - GAUGE_SCL1                    (alternate 4 opendrain floating)
464
 * PB11 - GAUGE_SDA1                    (alternate 4 opendrain floating)
465
 * PB12 - LED                           (output opendrain high)
466
 * PB13 - BT_RTS                        (alternate 7 pushpull floating)
467
 * PB14 - BT_CTS                        (inout floating)
468
 * PB15 - SYS_UART_UP                   (output opendrain high)
469
 */
470
#define VAL_GPIOB_IGNORE                (PIN_IGNORE(GPIOB_POWER_EN) |                                 \
471
                                         PIN_IGNORE(GPIOB_SYS_UART_DN) |                              \
472
                                         PIN_IGNORE(GPIOB_LED) |                                      \
473
                                         PIN_IGNORE(GPIOB_SYS_UART_UP)) & 0
474
#define VAL_GPIOB_MODER                 (PIN_MODE_INPUT(GPIOB_IR_INT1_N) |                            \
475
                                         PIN_MODE_ANALOG(GPIOB_VSYS_SENSE) |                          \
476
                                         PIN_MODE_OUTPUT(GPIOB_POWER_EN) |                            \
477
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_DN) |                         \
478
                                         PIN_MODE_INPUT(GPIOB_CHARGE_STAT2A) |                        \
479
                                         PIN_MODE_ALTERNATE(GPIOB_BUZZER) |                           \
480
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATLOW2) |                        \
481
                                         PIN_MODE_INPUT(GPIOB_GAUGE_BATGD2_N) |                       \
482
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL2) |                       \
483
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA2) |                       \
484
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SCL1) |                       \
485
                                         PIN_MODE_ALTERNATE(GPIOB_GAUGE_SDA1) |                       \
486
                                         PIN_MODE_OUTPUT(GPIOB_LED) |                                 \
487
                                         PIN_MODE_ALTERNATE(GPIOB_BT_RTS) |                           \
488
                                         PIN_MODE_INPUT(GPIOB_BT_CTS) |                               \
489
                                         PIN_MODE_OUTPUT(GPIOB_SYS_UART_UP))
490
#define VAL_GPIOB_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOB_IR_INT1_N) |                        \
491
                                         PIN_OTYPE_PUSHPULL(GPIOB_VSYS_SENSE) |                       \
492
                                         PIN_OTYPE_PUSHPULL(GPIOB_POWER_EN) |                         \
493
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_DN) |                     \
494
                                         PIN_OTYPE_PUSHPULL(GPIOB_CHARGE_STAT2A) |                    \
495
                                         PIN_OTYPE_PUSHPULL(GPIOB_BUZZER) |                           \
496
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATLOW2) |                    \
497
                                         PIN_OTYPE_PUSHPULL(GPIOB_GAUGE_BATGD2_N) |                   \
498
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL2) |                      \
499
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA2) |                      \
500
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SCL1) |                      \
501
                                         PIN_OTYPE_OPENDRAIN(GPIOB_GAUGE_SDA1) |                      \
502
                                         PIN_OTYPE_OPENDRAIN(GPIOB_LED) |                             \
503
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_RTS) |                           \
504
                                         PIN_OTYPE_PUSHPULL(GPIOB_BT_CTS) |                           \
505
                                         PIN_OTYPE_OPENDRAIN(GPIOB_SYS_UART_UP))
506
#define VAL_GPIOB_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOB_IR_INT1_N) |                       \
507
                                         PIN_OSPEED_VERYHIGH(GPIOB_VSYS_SENSE) |                      \
508
                                         PIN_OSPEED_VERYHIGH(GPIOB_POWER_EN) |                        \
509
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_DN) |                     \
510
                                         PIN_OSPEED_VERYHIGH(GPIOB_CHARGE_STAT2A) |                   \
511
                                         PIN_OSPEED_VERYHIGH(GPIOB_BUZZER) |                          \
512
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATLOW2) |                   \
513
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_BATGD2_N) |                  \
514
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL2) |                      \
515
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA2) |                      \
516
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SCL1) |                      \
517
                                         PIN_OSPEED_VERYHIGH(GPIOB_GAUGE_SDA1) |                      \
518
                                         PIN_OSPEED_VERYHIGH(GPIOB_LED) |                             \
519
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_RTS) |                          \
520
                                         PIN_OSPEED_VERYHIGH(GPIOB_BT_CTS) |                          \
521
                                         PIN_OSPEED_VERYHIGH(GPIOB_SYS_UART_UP))
522
#define VAL_GPIOB_PUPDR                 (PIN_PUPDR_FLOATING(GPIOB_IR_INT1_N) |                        \
523
                                         PIN_PUPDR_FLOATING(GPIOB_VSYS_SENSE) |                       \
524
                                         PIN_PUPDR_FLOATING(GPIOB_POWER_EN) |                         \
525
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_DN) |                      \
526
                                         PIN_PUPDR_FLOATING(GPIOB_CHARGE_STAT2A) |                    \
527
                                         PIN_PUPDR_FLOATING(GPIOB_BUZZER) |                           \
528
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATLOW2) |                    \
529
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_BATGD2_N) |                   \
530
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL2) |                       \
531
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA2) |                       \
532
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SCL1) |                       \
533
                                         PIN_PUPDR_FLOATING(GPIOB_GAUGE_SDA1) |                       \
534
                                         PIN_PUPDR_FLOATING(GPIOB_LED) |                              \
535
                                         PIN_PUPDR_FLOATING(GPIOB_BT_RTS) |                           \
536
                                         PIN_PUPDR_FLOATING(GPIOB_BT_CTS) |                           \
537
                                         PIN_PUPDR_FLOATING(GPIOB_SYS_UART_UP))
538
#define VAL_GPIOB_ODR                   (PIN_ODR_HIGH(GPIOB_IR_INT1_N) |                              \
539
                                         PIN_ODR_HIGH(GPIOB_VSYS_SENSE) |                             \
540
                                         PIN_ODR_HIGH(GPIOB_POWER_EN) |                               \
541
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_DN) |                            \
542
                                         PIN_ODR_HIGH(GPIOB_CHARGE_STAT2A) |                          \
543
                                         PIN_ODR_HIGH(GPIOB_BUZZER) |                                 \
544
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATLOW2) |                          \
545
                                         PIN_ODR_HIGH(GPIOB_GAUGE_BATGD2_N) |                         \
546
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL2) |                             \
547
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA2) |                             \
548
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SCL1) |                             \
549
                                         PIN_ODR_HIGH(GPIOB_GAUGE_SDA1) |                             \
550
                                         PIN_ODR_HIGH(GPIOB_LED) |                                    \
551
                                         PIN_ODR_HIGH(GPIOB_BT_RTS) |                                 \
552
                                         PIN_ODR_HIGH(GPIOB_BT_CTS) |                                 \
553
                                         PIN_ODR_HIGH(GPIOB_SYS_UART_UP))
554
#define VAL_GPIOB_AFRL                  (PIN_AFIO_AF(GPIOB_IR_INT1_N, STM32F4xx_AF_system) |          \
555
                                         PIN_AFIO_AF(GPIOB_VSYS_SENSE, STM32F4xx_AF_system) |         \
556
                                         PIN_AFIO_AF(GPIOB_POWER_EN, STM32F4xx_AF_system) |           \
557
                                         PIN_AFIO_AF(GPIOB_SYS_UART_DN, STM32F4xx_AF_system) |        \
558
                                         PIN_AFIO_AF(GPIOB_CHARGE_STAT2A, STM32F4xx_AF_system) |      \
559
                                         PIN_AFIO_AF(GPIOB_BUZZER, STM32F4xx_AF_TIM3to5) |            \
560
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATLOW2, STM32F4xx_AF_system) |      \
561
                                         PIN_AFIO_AF(GPIOB_GAUGE_BATGD2_N, STM32F4xx_AF_system))
562
#define VAL_GPIOB_AFRH                  (PIN_AFIO_AF(GPIOB_GAUGE_SCL2, STM32F4xx_AF_I2C1to3) |        \
563
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA2, STM32F4xx_AF_I2C1to3) |        \
564
                                         PIN_AFIO_AF(GPIOB_GAUGE_SCL1, STM32F4xx_AF_I2C1to3) |        \
565
                                         PIN_AFIO_AF(GPIOB_GAUGE_SDA1, STM32F4xx_AF_I2C1to3) |        \
566
                                         PIN_AFIO_AF(GPIOB_LED, STM32F4xx_AF_system) |                \
567
                                         PIN_AFIO_AF(GPIOB_BT_RTS, STM32F4xx_AF_USART1to3) |          \
568
                                         PIN_AFIO_AF(GPIOB_BT_CTS, STM32F4xx_AF_USART1to3) |          \
569
                                         PIN_AFIO_AF(GPIOB_SYS_UART_UP, STM32F4xx_AF_system))
570

    
571
/*
572
 * GPIOC setup:
573
 *
574
 * PC0  - CHARGE_STAT1A                 (input floating)
575
 * PC1  - GAUGE_BATLOW1                 (input floating)
576
 * PC2  - GAUGE_BATGD1_N                (input floating)
577
 * PC3  - CHARGE_EN1_N                  (output opendrain high)
578
 * PC4  - IR_INT2_N                     (input floating)
579
 * PC5  - TOUCH_INT_N                   (input floating)
580
 * PC6  - SYS_DONE                      (input floating)
581
 * PC7  - SYS_PROG_N                    (output opendrain high)
582
 * PC8  - PATH_DC                       (input floating)
583
 * PC9  - SYS_SPI_DIR                   (output opendrain high)
584
 * PC10 - BT_RX                         (alternate 7 pushpull floating)
585
 * PC11 - BT_TX                         (alternate 7 pushpull floating)
586
 * PC12 - SYS_INT_N                     (output opendrain low)
587
 * PC13 - SYS_PD_N                      (output opendrain high)
588
 * PC14 - SYS_WARMRST_N                 (output opendrain high)
589
 * PC15 - BT_RST                        (output opendrain high)
590
 */
591
#define VAL_GPIOC_IGNORE                (PIN_IGNORE(GPIOC_CHARGE_EN1_N) |                             \
592
                                         PIN_IGNORE(GPIOC_SYS_INT_N) |                                \
593
                                         PIN_IGNORE(GPIOC_SYS_PD_N)) & 0
594
#define VAL_GPIOC_MODER                 (PIN_MODE_INPUT(GPIOC_CHARGE_STAT1A) |                        \
595
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATLOW1) |                        \
596
                                         PIN_MODE_INPUT(GPIOC_GAUGE_BATGD1_N) |                       \
597
                                         PIN_MODE_OUTPUT(GPIOC_CHARGE_EN1_N) |                        \
598
                                         PIN_MODE_INPUT(GPIOC_IR_INT2_N) |                            \
599
                                         PIN_MODE_INPUT(GPIOC_TOUCH_INT_N) |                          \
600
                                         PIN_MODE_INPUT(GPIOC_SYS_DONE) |                             \
601
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PROG_N) |                          \
602
                                         PIN_MODE_INPUT(GPIOC_PATH_DC) |                              \
603
                                         PIN_MODE_OUTPUT(GPIOC_SYS_SPI_DIR) |                         \
604
                                         PIN_MODE_ALTERNATE(GPIOC_BT_RX) |                            \
605
                                         PIN_MODE_ALTERNATE(GPIOC_BT_TX) |                            \
606
                                         PIN_MODE_OUTPUT(GPIOC_SYS_INT_N) |                           \
607
                                         PIN_MODE_OUTPUT(GPIOC_SYS_PD_N) |                            \
608
                                         PIN_MODE_OUTPUT(GPIOC_SYS_WARMRST_N) |                       \
609
                                         PIN_MODE_OUTPUT(GPIOC_BT_RST))
610
#define VAL_GPIOC_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOC_CHARGE_STAT1A) |                    \
611
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATLOW1) |                    \
612
                                         PIN_OTYPE_PUSHPULL(GPIOC_GAUGE_BATGD1_N) |                   \
613
                                         PIN_OTYPE_OPENDRAIN(GPIOC_CHARGE_EN1_N) |                    \
614
                                         PIN_OTYPE_PUSHPULL(GPIOC_IR_INT2_N) |                        \
615
                                         PIN_OTYPE_PUSHPULL(GPIOC_TOUCH_INT_N) |                      \
616
                                         PIN_OTYPE_PUSHPULL(GPIOC_SYS_DONE) |                         \
617
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PROG_N) |                      \
618
                                         PIN_OTYPE_PUSHPULL(GPIOC_PATH_DC) |                          \
619
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_SPI_DIR) |                     \
620
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_RX) |                            \
621
                                         PIN_OTYPE_PUSHPULL(GPIOC_BT_TX) |                            \
622
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_INT_N) |                       \
623
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_PD_N) |                        \
624
                                         PIN_OTYPE_OPENDRAIN(GPIOC_SYS_WARMRST_N) |                   \
625
                                         PIN_OTYPE_OPENDRAIN(GPIOC_BT_RST))
626
#define VAL_GPIOC_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_STAT1A) |                   \
627
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATLOW1) |                   \
628
                                         PIN_OSPEED_VERYHIGH(GPIOC_GAUGE_BATGD1_N) |                  \
629
                                         PIN_OSPEED_VERYHIGH(GPIOC_CHARGE_EN1_N) |                    \
630
                                         PIN_OSPEED_VERYHIGH(GPIOC_IR_INT2_N) |                       \
631
                                         PIN_OSPEED_VERYHIGH(GPIOC_TOUCH_INT_N) |                     \
632
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_DONE) |                        \
633
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PROG_N) |                      \
634
                                         PIN_OSPEED_VERYHIGH(GPIOC_PATH_DC) |                         \
635
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_SPI_DIR) |                     \
636
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RX) |                           \
637
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_TX) |                           \
638
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_INT_N) |                       \
639
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_PD_N) |                        \
640
                                         PIN_OSPEED_VERYHIGH(GPIOC_SYS_WARMRST_N) |                   \
641
                                         PIN_OSPEED_VERYHIGH(GPIOC_BT_RST))
642
#define VAL_GPIOC_PUPDR                 (PIN_PUPDR_FLOATING(GPIOC_CHARGE_STAT1A) |                    \
643
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATLOW1) |                    \
644
                                         PIN_PUPDR_FLOATING(GPIOC_GAUGE_BATGD1_N) |                   \
645
                                         PIN_PUPDR_FLOATING(GPIOC_CHARGE_EN1_N) |                     \
646
                                         PIN_PUPDR_FLOATING(GPIOC_IR_INT2_N) |                        \
647
                                         PIN_PUPDR_FLOATING(GPIOC_TOUCH_INT_N) |                      \
648
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_DONE) |                         \
649
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PROG_N) |                       \
650
                                         PIN_PUPDR_FLOATING(GPIOC_PATH_DC) |                          \
651
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_SPI_DIR) |                      \
652
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RX) |                            \
653
                                         PIN_PUPDR_FLOATING(GPIOC_BT_TX) |                            \
654
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_INT_N) |                        \
655
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_PD_N) |                         \
656
                                         PIN_PUPDR_FLOATING(GPIOC_SYS_WARMRST_N) |                    \
657
                                         PIN_PUPDR_FLOATING(GPIOC_BT_RST))
658
#define VAL_GPIOC_ODR                   (PIN_ODR_HIGH(GPIOC_CHARGE_STAT1A) |                          \
659
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATLOW1) |                          \
660
                                         PIN_ODR_HIGH(GPIOC_GAUGE_BATGD1_N) |                         \
661
                                         PIN_ODR_HIGH(GPIOC_CHARGE_EN1_N) |                           \
662
                                         PIN_ODR_HIGH(GPIOC_IR_INT2_N) |                              \
663
                                         PIN_ODR_HIGH(GPIOC_TOUCH_INT_N) |                            \
664
                                         PIN_ODR_HIGH(GPIOC_SYS_DONE) |                               \
665
                                         PIN_ODR_HIGH(GPIOC_SYS_PROG_N) |                             \
666
                                         PIN_ODR_LOW(GPIOC_PATH_DC) |                                 \
667
                                         PIN_ODR_HIGH(GPIOC_SYS_SPI_DIR) |                            \
668
                                         PIN_ODR_HIGH(GPIOC_BT_RX) |                                  \
669
                                         PIN_ODR_HIGH(GPIOC_BT_TX) |                                  \
670
                                         PIN_ODR_LOW(GPIOC_SYS_INT_N) |                               \
671
                                         PIN_ODR_HIGH(GPIOC_SYS_PD_N) |                               \
672
                                         PIN_ODR_HIGH(GPIOC_SYS_WARMRST_N) |                          \
673
                                         PIN_ODR_HIGH(GPIOC_BT_RST))
674
#define VAL_GPIOC_AFRL                  (PIN_AFIO_AF(GPIOC_CHARGE_STAT1A, STM32F4xx_AF_system) |      \
675
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATLOW1, STM32F4xx_AF_system) |      \
676
                                         PIN_AFIO_AF(GPIOC_GAUGE_BATGD1_N, STM32F4xx_AF_system) |     \
677
                                         PIN_AFIO_AF(GPIOC_CHARGE_EN1_N, STM32F4xx_AF_system) |       \
678
                                         PIN_AFIO_AF(GPIOC_IR_INT2_N, STM32F4xx_AF_system) |          \
679
                                         PIN_AFIO_AF(GPIOC_TOUCH_INT_N, STM32F4xx_AF_system) |        \
680
                                         PIN_AFIO_AF(GPIOC_SYS_DONE, STM32F4xx_AF_system) |           \
681
                                         PIN_AFIO_AF(GPIOC_SYS_PROG_N, STM32F4xx_AF_system))
682
#define VAL_GPIOC_AFRH                  (PIN_AFIO_AF(GPIOC_PATH_DC, STM32F4xx_AF_system) |            \
683
                                         PIN_AFIO_AF(GPIOC_SYS_SPI_DIR, STM32F4xx_AF_system) |        \
684
                                         PIN_AFIO_AF(GPIOC_BT_RX, STM32F4xx_AF_USART1to3) |           \
685
                                         PIN_AFIO_AF(GPIOC_BT_TX, STM32F4xx_AF_USART1to3) |           \
686
                                         PIN_AFIO_AF(GPIOC_SYS_INT_N, STM32F4xx_AF_system) |          \
687
                                         PIN_AFIO_AF(GPIOC_SYS_PD_N, STM32F4xx_AF_system) |           \
688
                                         PIN_AFIO_AF(GPIOC_SYS_WARMRST_N, STM32F4xx_AF_system) |      \
689
                                         PIN_AFIO_AF(GPIOC_BT_RST, STM32F4xx_AF_system))
690

    
691
/*
692
 * GPIOD setup:
693
 *
694
 * PD0  - PIN0                          (input floating)
695
 * PD1  - PIN1                          (input floating)
696
 * PD2  - CHARGE_EN2_N                  (output opendrain high)
697
 * PD3  - PIN3                          (input floating)
698
 * PD4  - PIN4                          (input floating)
699
 * PD5  - PIN5                          (input floating)
700
 * PD6  - PIN6                          (input floating)
701
 * PD7  - PIN7                          (input floating)
702
 * PD8  - PIN8                          (input floating)
703
 * PD9  - PIN9                          (input floating)
704
 * PD10 - PIN10                         (input floating)
705
 * PD11 - PIN11                         (input floating)
706
 * PD12 - PIN12                         (input floating)
707
 * PD13 - PIN13                         (input floating)
708
 * PD14 - PIN14                         (input floating)
709
 * PD15 - PIN15                         (input floating)
710
 */
711
#define VAL_GPIOD_IGNORE                (PIN_IGNORE(GPIOD_CHARGE_EN2_N)) & 0
712
#define VAL_GPIOD_MODER                 (PIN_MODE_INPUT(GPIOD_PIN0) |                                 \
713
                                         PIN_MODE_INPUT(GPIOD_PIN1) |                                 \
714
                                         PIN_MODE_OUTPUT(GPIOD_CHARGE_EN2_N) |                        \
715
                                         PIN_MODE_INPUT(GPIOD_PIN3) |                                 \
716
                                         PIN_MODE_INPUT(GPIOD_PIN4) |                                 \
717
                                         PIN_MODE_INPUT(GPIOD_PIN5) |                                 \
718
                                         PIN_MODE_INPUT(GPIOD_PIN6) |                                 \
719
                                         PIN_MODE_INPUT(GPIOD_PIN7) |                                 \
720
                                         PIN_MODE_INPUT(GPIOD_PIN8) |                                 \
721
                                         PIN_MODE_INPUT(GPIOD_PIN9) |                                 \
722
                                         PIN_MODE_INPUT(GPIOD_PIN10) |                                \
723
                                         PIN_MODE_INPUT(GPIOD_PIN11) |                                \
724
                                         PIN_MODE_INPUT(GPIOD_PIN12) |                                \
725
                                         PIN_MODE_INPUT(GPIOD_PIN13) |                                \
726
                                         PIN_MODE_INPUT(GPIOD_PIN14) |                                \
727
                                         PIN_MODE_INPUT(GPIOD_PIN15))
728
#define VAL_GPIOD_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) |                             \
729
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN1) |                             \
730
                                         PIN_OTYPE_OPENDRAIN(GPIOD_CHARGE_EN2_N) |                    \
731
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN3) |                             \
732
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN4) |                             \
733
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN5) |                             \
734
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN6) |                             \
735
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN7) |                             \
736
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN8) |                             \
737
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN9) |                             \
738
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN10) |                            \
739
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN11) |                            \
740
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN12) |                            \
741
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN13) |                            \
742
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN14) |                            \
743
                                         PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
744
#define VAL_GPIOD_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOD_PIN0) |                            \
745
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN1) |                            \
746
                                         PIN_OSPEED_VERYHIGH(GPIOD_CHARGE_EN2_N) |                    \
747
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN3) |                            \
748
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN4) |                            \
749
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN5) |                            \
750
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN6) |                            \
751
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN7) |                            \
752
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN8) |                            \
753
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN9) |                            \
754
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN10) |                           \
755
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN11) |                           \
756
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN12) |                           \
757
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN13) |                           \
758
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN14) |                           \
759
                                         PIN_OSPEED_VERYHIGH(GPIOD_PIN15))
760
#define VAL_GPIOD_PUPDR                 (PIN_PUPDR_PULLUP(GPIOD_PIN0) |                               \
761
                                         PIN_PUPDR_PULLUP(GPIOD_PIN1) |                               \
762
                                         PIN_PUPDR_FLOATING(GPIOD_CHARGE_EN2_N) |                     \
763
                                         PIN_PUPDR_PULLUP(GPIOD_PIN3) |                               \
764
                                         PIN_PUPDR_PULLUP(GPIOD_PIN4) |                               \
765
                                         PIN_PUPDR_PULLUP(GPIOD_PIN5) |                               \
766
                                         PIN_PUPDR_PULLUP(GPIOD_PIN6) |                               \
767
                                         PIN_PUPDR_PULLUP(GPIOD_PIN7) |                               \
768
                                         PIN_PUPDR_PULLUP(GPIOD_PIN8) |                               \
769
                                         PIN_PUPDR_PULLUP(GPIOD_PIN9) |                               \
770
                                         PIN_PUPDR_PULLUP(GPIOD_PIN10) |                              \
771
                                         PIN_PUPDR_PULLUP(GPIOD_PIN11) |                              \
772
                                         PIN_PUPDR_PULLUP(GPIOD_PIN12) |                              \
773
                                         PIN_PUPDR_PULLUP(GPIOD_PIN13) |                              \
774
                                         PIN_PUPDR_PULLUP(GPIOD_PIN14) |                              \
775
                                         PIN_PUPDR_PULLUP(GPIOD_PIN15))
776
#define VAL_GPIOD_ODR                   (PIN_ODR_HIGH(GPIOD_PIN0) |                                   \
777
                                         PIN_ODR_HIGH(GPIOD_PIN1) |                                   \
778
                                         PIN_ODR_HIGH(GPIOD_CHARGE_EN2_N) |                           \
779
                                         PIN_ODR_HIGH(GPIOD_PIN3) |                                   \
780
                                         PIN_ODR_HIGH(GPIOD_PIN4) |                                   \
781
                                         PIN_ODR_HIGH(GPIOD_PIN5) |                                   \
782
                                         PIN_ODR_HIGH(GPIOD_PIN6) |                                   \
783
                                         PIN_ODR_HIGH(GPIOD_PIN7) |                                   \
784
                                         PIN_ODR_HIGH(GPIOD_PIN8) |                                   \
785
                                         PIN_ODR_HIGH(GPIOD_PIN9) |                                   \
786
                                         PIN_ODR_HIGH(GPIOD_PIN10) |                                  \
787
                                         PIN_ODR_HIGH(GPIOD_PIN11) |                                  \
788
                                         PIN_ODR_HIGH(GPIOD_PIN12) |                                  \
789
                                         PIN_ODR_HIGH(GPIOD_PIN13) |                                  \
790
                                         PIN_ODR_HIGH(GPIOD_PIN14) |                                  \
791
                                         PIN_ODR_HIGH(GPIOD_PIN15))
792
#define VAL_GPIOD_AFRL                  (PIN_AFIO_AF(GPIOD_PIN0, STM32F4xx_AF_system) |               \
793
                                         PIN_AFIO_AF(GPIOD_PIN1, STM32F4xx_AF_system) |               \
794
                                         PIN_AFIO_AF(GPIOD_CHARGE_EN2_N, STM32F4xx_AF_system) |       \
795
                                         PIN_AFIO_AF(GPIOD_PIN3, STM32F4xx_AF_system) |               \
796
                                         PIN_AFIO_AF(GPIOD_PIN4, STM32F4xx_AF_system) |               \
797
                                         PIN_AFIO_AF(GPIOD_PIN5, STM32F4xx_AF_system) |               \
798
                                         PIN_AFIO_AF(GPIOD_PIN6, STM32F4xx_AF_system) |               \
799
                                         PIN_AFIO_AF(GPIOD_PIN7, STM32F4xx_AF_system))
800
#define VAL_GPIOD_AFRH                  (PIN_AFIO_AF(GPIOD_PIN8, STM32F4xx_AF_system) |               \
801
                                         PIN_AFIO_AF(GPIOD_PIN9, STM32F4xx_AF_system) |               \
802
                                         PIN_AFIO_AF(GPIOD_PIN10, STM32F4xx_AF_system) |              \
803
                                         PIN_AFIO_AF(GPIOD_PIN11, STM32F4xx_AF_system) |              \
804
                                         PIN_AFIO_AF(GPIOD_PIN12, STM32F4xx_AF_system) |              \
805
                                         PIN_AFIO_AF(GPIOD_PIN13, STM32F4xx_AF_system) |              \
806
                                         PIN_AFIO_AF(GPIOD_PIN14, STM32F4xx_AF_system) |              \
807
                                         PIN_AFIO_AF(GPIOD_PIN15, STM32F4xx_AF_system))
808

    
809
/*
810
 * GPIOE setup:
811
 *
812
 * PE0  - PIN0                          (input floating)
813
 * PE1  - PIN1                          (input floating)
814
 * PE2  - PIN2                          (input floating)
815
 * PE3  - PIN3                          (input floating)
816
 * PE4  - PIN4                          (input floating)
817
 * PE5  - PIN5                          (input floating)
818
 * PE6  - PIN6                          (input floating)
819
 * PE7  - PIN7                          (input floating)
820
 * PE8  - PIN8                          (input floating)
821
 * PE9  - PIN9                          (input floating)
822
 * PE10 - PIN10                         (input floating)
823
 * PE11 - PIN11                         (input floating)
824
 * PE12 - PIN12                         (input floating)
825
 * PE13 - PIN13                         (input floating)
826
 * PE14 - PIN14                         (input floating)
827
 * PE15 - PIN15                         (input floating)
828
 */
829
#define VAL_GPIOE_IGNORE                0
830
#define VAL_GPIOE_MODER                 (PIN_MODE_INPUT(GPIOE_PIN0) |                                 \
831
                                         PIN_MODE_INPUT(GPIOE_PIN1) |                                 \
832
                                         PIN_MODE_INPUT(GPIOE_PIN2) |                                 \
833
                                         PIN_MODE_INPUT(GPIOE_PIN3) |                                 \
834
                                         PIN_MODE_INPUT(GPIOE_PIN4) |                                 \
835
                                         PIN_MODE_INPUT(GPIOE_PIN5) |                                 \
836
                                         PIN_MODE_INPUT(GPIOE_PIN6) |                                 \
837
                                         PIN_MODE_INPUT(GPIOE_PIN7) |                                 \
838
                                         PIN_MODE_INPUT(GPIOE_PIN8) |                                 \
839
                                         PIN_MODE_INPUT(GPIOE_PIN9) |                                 \
840
                                         PIN_MODE_INPUT(GPIOE_PIN10) |                                \
841
                                         PIN_MODE_INPUT(GPIOE_PIN11) |                                \
842
                                         PIN_MODE_INPUT(GPIOE_PIN12) |                                \
843
                                         PIN_MODE_INPUT(GPIOE_PIN13) |                                \
844
                                         PIN_MODE_INPUT(GPIOE_PIN14) |                                \
845
                                         PIN_MODE_INPUT(GPIOE_PIN15))
846
#define VAL_GPIOE_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) |                             \
847
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN1) |                             \
848
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN2) |                             \
849
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN3) |                             \
850
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN4) |                             \
851
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN5) |                             \
852
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN6) |                             \
853
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN7) |                             \
854
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN8) |                             \
855
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN9) |                             \
856
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN10) |                            \
857
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN11) |                            \
858
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN12) |                            \
859
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN13) |                            \
860
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN14) |                            \
861
                                         PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
862
#define VAL_GPIOE_OSPEEDR               (PIN_OSPEED_LOW(GPIOE_PIN0) |                                 \
863
                                         PIN_OSPEED_LOW(GPIOE_PIN1) |                                 \
864
                                         PIN_OSPEED_LOW(GPIOE_PIN2) |                                 \
865
                                         PIN_OSPEED_LOW(GPIOE_PIN3) |                                 \
866
                                         PIN_OSPEED_LOW(GPIOE_PIN4) |                                 \
867
                                         PIN_OSPEED_LOW(GPIOE_PIN5) |                                 \
868
                                         PIN_OSPEED_LOW(GPIOE_PIN6) |                                 \
869
                                         PIN_OSPEED_LOW(GPIOE_PIN7) |                                 \
870
                                         PIN_OSPEED_LOW(GPIOE_PIN8) |                                 \
871
                                         PIN_OSPEED_LOW(GPIOE_PIN9) |                                 \
872
                                         PIN_OSPEED_LOW(GPIOE_PIN10) |                                \
873
                                         PIN_OSPEED_LOW(GPIOE_PIN11) |                                \
874
                                         PIN_OSPEED_LOW(GPIOE_PIN12) |                                \
875
                                         PIN_OSPEED_LOW(GPIOE_PIN13) |                                \
876
                                         PIN_OSPEED_LOW(GPIOE_PIN14) |                                \
877
                                         PIN_OSPEED_LOW(GPIOE_PIN15))
878
#define VAL_GPIOE_PUPDR                 (PIN_PUPDR_FLOATING(GPIOE_PIN0) |                             \
879
                                         PIN_PUPDR_FLOATING(GPIOE_PIN1) |                             \
880
                                         PIN_PUPDR_FLOATING(GPIOE_PIN2) |                             \
881
                                         PIN_PUPDR_FLOATING(GPIOE_PIN3) |                             \
882
                                         PIN_PUPDR_FLOATING(GPIOE_PIN4) |                             \
883
                                         PIN_PUPDR_FLOATING(GPIOE_PIN5) |                             \
884
                                         PIN_PUPDR_FLOATING(GPIOE_PIN6) |                             \
885
                                         PIN_PUPDR_FLOATING(GPIOE_PIN7) |                             \
886
                                         PIN_PUPDR_FLOATING(GPIOE_PIN8) |                             \
887
                                         PIN_PUPDR_FLOATING(GPIOE_PIN9) |                             \
888
                                         PIN_PUPDR_FLOATING(GPIOE_PIN10) |                            \
889
                                         PIN_PUPDR_FLOATING(GPIOE_PIN11) |                            \
890
                                         PIN_PUPDR_FLOATING(GPIOE_PIN12) |                            \
891
                                         PIN_PUPDR_FLOATING(GPIOE_PIN13) |                            \
892
                                         PIN_PUPDR_FLOATING(GPIOE_PIN14) |                            \
893
                                         PIN_PUPDR_FLOATING(GPIOE_PIN15))
894
#define VAL_GPIOE_ODR                   (PIN_ODR_LOW(GPIOE_PIN0) |                                    \
895
                                         PIN_ODR_LOW(GPIOE_PIN1) |                                    \
896
                                         PIN_ODR_LOW(GPIOE_PIN2) |                                    \
897
                                         PIN_ODR_LOW(GPIOE_PIN3) |                                    \
898
                                         PIN_ODR_LOW(GPIOE_PIN4) |                                    \
899
                                         PIN_ODR_LOW(GPIOE_PIN5) |                                    \
900
                                         PIN_ODR_LOW(GPIOE_PIN6) |                                    \
901
                                         PIN_ODR_LOW(GPIOE_PIN7) |                                    \
902
                                         PIN_ODR_LOW(GPIOE_PIN8) |                                    \
903
                                         PIN_ODR_LOW(GPIOE_PIN9) |                                    \
904
                                         PIN_ODR_LOW(GPIOE_PIN10) |                                   \
905
                                         PIN_ODR_LOW(GPIOE_PIN11) |                                   \
906
                                         PIN_ODR_LOW(GPIOE_PIN12) |                                   \
907
                                         PIN_ODR_LOW(GPIOE_PIN13) |                                   \
908
                                         PIN_ODR_LOW(GPIOE_PIN14) |                                   \
909
                                         PIN_ODR_LOW(GPIOE_PIN15))
910
#define VAL_GPIOE_AFRL                  (PIN_AFIO_AF(GPIOE_PIN0, STM32F4xx_AF_system) |               \
911
                                         PIN_AFIO_AF(GPIOE_PIN1, STM32F4xx_AF_system) |               \
912
                                         PIN_AFIO_AF(GPIOE_PIN2, STM32F4xx_AF_system) |               \
913
                                         PIN_AFIO_AF(GPIOE_PIN3, STM32F4xx_AF_system) |               \
914
                                         PIN_AFIO_AF(GPIOE_PIN4, STM32F4xx_AF_system) |               \
915
                                         PIN_AFIO_AF(GPIOE_PIN5, STM32F4xx_AF_system) |               \
916
                                         PIN_AFIO_AF(GPIOE_PIN6, STM32F4xx_AF_system) |               \
917
                                         PIN_AFIO_AF(GPIOE_PIN7, STM32F4xx_AF_system))
918
#define VAL_GPIOE_AFRH                  (PIN_AFIO_AF(GPIOE_PIN8, STM32F4xx_AF_system) |               \
919
                                         PIN_AFIO_AF(GPIOE_PIN9, STM32F4xx_AF_system) |               \
920
                                         PIN_AFIO_AF(GPIOE_PIN10, STM32F4xx_AF_system) |              \
921
                                         PIN_AFIO_AF(GPIOE_PIN11, STM32F4xx_AF_system) |              \
922
                                         PIN_AFIO_AF(GPIOE_PIN12, STM32F4xx_AF_system) |              \
923
                                         PIN_AFIO_AF(GPIOE_PIN13, STM32F4xx_AF_system) |              \
924
                                         PIN_AFIO_AF(GPIOE_PIN14, STM32F4xx_AF_system) |              \
925
                                         PIN_AFIO_AF(GPIOE_PIN15, STM32F4xx_AF_system))
926

    
927
/*
928
 * GPIOF setup:
929
 *
930
 * PF0  - PIN0                          (input floating)
931
 * PF1  - PIN1                          (input floating)
932
 * PF2  - PIN2                          (input floating)
933
 * PF3  - PIN3                          (input floating)
934
 * PF4  - PIN4                          (input floating)
935
 * PF5  - PIN5                          (input floating)
936
 * PF6  - PIN6                          (input floating)
937
 * PF7  - PIN7                          (input floating)
938
 * PF8  - PIN8                          (input floating)
939
 * PF9  - PIN9                          (input floating)
940
 * PF10 - PIN10                         (input floating)
941
 * PF11 - PIN11                         (input floating)
942
 * PF12 - PIN12                         (input floating)
943
 * PF13 - PIN13                         (input floating)
944
 * PF14 - PIN14                         (input floating)
945
 * PF15 - PIN15                         (input floating)
946
 */
947
#define VAL_GPIOF_IGNORE                0
948
#define VAL_GPIOF_MODER                 (PIN_MODE_INPUT(GPIOF_PIN0) |                                 \
949
                                         PIN_MODE_INPUT(GPIOF_PIN1) |                                 \
950
                                         PIN_MODE_INPUT(GPIOF_PIN2) |                                 \
951
                                         PIN_MODE_INPUT(GPIOF_PIN3) |                                 \
952
                                         PIN_MODE_INPUT(GPIOF_PIN4) |                                 \
953
                                         PIN_MODE_INPUT(GPIOF_PIN5) |                                 \
954
                                         PIN_MODE_INPUT(GPIOF_PIN6) |                                 \
955
                                         PIN_MODE_INPUT(GPIOF_PIN7) |                                 \
956
                                         PIN_MODE_INPUT(GPIOF_PIN8) |                                 \
957
                                         PIN_MODE_INPUT(GPIOF_PIN9) |                                 \
958
                                         PIN_MODE_INPUT(GPIOF_PIN10) |                                \
959
                                         PIN_MODE_INPUT(GPIOF_PIN11) |                                \
960
                                         PIN_MODE_INPUT(GPIOF_PIN12) |                                \
961
                                         PIN_MODE_INPUT(GPIOF_PIN13) |                                \
962
                                         PIN_MODE_INPUT(GPIOF_PIN14) |                                \
963
                                         PIN_MODE_INPUT(GPIOF_PIN15))
964
#define VAL_GPIOF_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) |                             \
965
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN1) |                             \
966
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN2) |                             \
967
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN3) |                             \
968
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN4) |                             \
969
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN5) |                             \
970
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN6) |                             \
971
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN7) |                             \
972
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN8) |                             \
973
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN9) |                             \
974
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN10) |                            \
975
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN11) |                            \
976
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN12) |                            \
977
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN13) |                            \
978
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN14) |                            \
979
                                         PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
980
#define VAL_GPIOF_OSPEEDR               (PIN_OSPEED_LOW(GPIOF_PIN0) |                                 \
981
                                         PIN_OSPEED_LOW(GPIOF_PIN1) |                                 \
982
                                         PIN_OSPEED_LOW(GPIOF_PIN2) |                                 \
983
                                         PIN_OSPEED_LOW(GPIOF_PIN3) |                                 \
984
                                         PIN_OSPEED_LOW(GPIOF_PIN4) |                                 \
985
                                         PIN_OSPEED_LOW(GPIOF_PIN5) |                                 \
986
                                         PIN_OSPEED_LOW(GPIOF_PIN6) |                                 \
987
                                         PIN_OSPEED_LOW(GPIOF_PIN7) |                                 \
988
                                         PIN_OSPEED_LOW(GPIOF_PIN8) |                                 \
989
                                         PIN_OSPEED_LOW(GPIOF_PIN9) |                                 \
990
                                         PIN_OSPEED_LOW(GPIOF_PIN10) |                                \
991
                                         PIN_OSPEED_LOW(GPIOF_PIN11) |                                \
992
                                         PIN_OSPEED_LOW(GPIOF_PIN12) |                                \
993
                                         PIN_OSPEED_LOW(GPIOF_PIN13) |                                \
994
                                         PIN_OSPEED_LOW(GPIOF_PIN14) |                                \
995
                                         PIN_OSPEED_LOW(GPIOF_PIN15))
996
#define VAL_GPIOF_PUPDR                 (PIN_PUPDR_FLOATING(GPIOF_PIN0) |                             \
997
                                         PIN_PUPDR_FLOATING(GPIOF_PIN1) |                             \
998
                                         PIN_PUPDR_FLOATING(GPIOF_PIN2) |                             \
999
                                         PIN_PUPDR_FLOATING(GPIOF_PIN3) |                             \
1000
                                         PIN_PUPDR_FLOATING(GPIOF_PIN4) |                             \
1001
                                         PIN_PUPDR_FLOATING(GPIOF_PIN5) |                             \
1002
                                         PIN_PUPDR_FLOATING(GPIOF_PIN6) |                             \
1003
                                         PIN_PUPDR_FLOATING(GPIOF_PIN7) |                             \
1004
                                         PIN_PUPDR_FLOATING(GPIOF_PIN8) |                             \
1005
                                         PIN_PUPDR_FLOATING(GPIOF_PIN9) |                             \
1006
                                         PIN_PUPDR_FLOATING(GPIOF_PIN10) |                            \
1007
                                         PIN_PUPDR_FLOATING(GPIOF_PIN11) |                            \
1008
                                         PIN_PUPDR_FLOATING(GPIOF_PIN12) |                            \
1009
                                         PIN_PUPDR_FLOATING(GPIOF_PIN13) |                            \
1010
                                         PIN_PUPDR_FLOATING(GPIOF_PIN14) |                            \
1011
                                         PIN_PUPDR_FLOATING(GPIOF_PIN15))
1012
#define VAL_GPIOF_ODR                   (PIN_ODR_LOW(GPIOF_PIN0) |                                    \
1013
                                         PIN_ODR_LOW(GPIOF_PIN1) |                                    \
1014
                                         PIN_ODR_LOW(GPIOF_PIN2) |                                    \
1015
                                         PIN_ODR_LOW(GPIOF_PIN3) |                                    \
1016
                                         PIN_ODR_LOW(GPIOF_PIN4) |                                    \
1017
                                         PIN_ODR_LOW(GPIOF_PIN5) |                                    \
1018
                                         PIN_ODR_LOW(GPIOF_PIN6) |                                    \
1019
                                         PIN_ODR_LOW(GPIOF_PIN7) |                                    \
1020
                                         PIN_ODR_LOW(GPIOF_PIN8) |                                    \
1021
                                         PIN_ODR_LOW(GPIOF_PIN9) |                                    \
1022
                                         PIN_ODR_LOW(GPIOF_PIN10) |                                   \
1023
                                         PIN_ODR_LOW(GPIOF_PIN11) |                                   \
1024
                                         PIN_ODR_LOW(GPIOF_PIN12) |                                   \
1025
                                         PIN_ODR_LOW(GPIOF_PIN13) |                                   \
1026
                                         PIN_ODR_LOW(GPIOF_PIN14) |                                   \
1027
                                         PIN_ODR_LOW(GPIOF_PIN15))
1028
#define VAL_GPIOF_AFRL                  (PIN_AFIO_AF(GPIOF_PIN0, STM32F4xx_AF_system) |               \
1029
                                         PIN_AFIO_AF(GPIOF_PIN1, STM32F4xx_AF_system) |               \
1030
                                         PIN_AFIO_AF(GPIOF_PIN2, STM32F4xx_AF_system) |               \
1031
                                         PIN_AFIO_AF(GPIOF_PIN3, STM32F4xx_AF_system) |               \
1032
                                         PIN_AFIO_AF(GPIOF_PIN4, STM32F4xx_AF_system) |               \
1033
                                         PIN_AFIO_AF(GPIOF_PIN5, STM32F4xx_AF_system) |               \
1034
                                         PIN_AFIO_AF(GPIOF_PIN6, STM32F4xx_AF_system) |               \
1035
                                         PIN_AFIO_AF(GPIOF_PIN7, STM32F4xx_AF_system))
1036
#define VAL_GPIOF_AFRH                  (PIN_AFIO_AF(GPIOF_PIN8, STM32F4xx_AF_system) |               \
1037
                                         PIN_AFIO_AF(GPIOF_PIN9, STM32F4xx_AF_system) |               \
1038
                                         PIN_AFIO_AF(GPIOF_PIN10, STM32F4xx_AF_system) |              \
1039
                                         PIN_AFIO_AF(GPIOF_PIN11, STM32F4xx_AF_system) |              \
1040
                                         PIN_AFIO_AF(GPIOF_PIN12, STM32F4xx_AF_system) |              \
1041
                                         PIN_AFIO_AF(GPIOF_PIN13, STM32F4xx_AF_system) |              \
1042
                                         PIN_AFIO_AF(GPIOF_PIN14, STM32F4xx_AF_system) |              \
1043
                                         PIN_AFIO_AF(GPIOF_PIN15, STM32F4xx_AF_system))
1044

    
1045
/*
1046
 * GPIOG setup:
1047
 *
1048
 * PG0  - PIN0                          (input floating)
1049
 * PG1  - PIN1                          (input floating)
1050
 * PG2  - PIN2                          (input floating)
1051
 * PG3  - PIN3                          (input floating)
1052
 * PG4  - PIN4                          (input floating)
1053
 * PG5  - PIN5                          (input floating)
1054
 * PG6  - PIN6                          (input floating)
1055
 * PG7  - PIN7                          (input floating)
1056
 * PG8  - PIN8                          (input floating)
1057
 * PG9  - PIN9                          (input floating)
1058
 * PG10 - PIN10                         (input floating)
1059
 * PG11 - PIN11                         (input floating)
1060
 * PG12 - PIN12                         (input floating)
1061
 * PG13 - PIN13                         (input floating)
1062
 * PG14 - PIN14                         (input floating)
1063
 * PG15 - PIN15                         (input floating)
1064
 */
1065
#define VAL_GPIOG_IGNORE                0
1066
#define VAL_GPIOG_MODER                 (PIN_MODE_INPUT(GPIOG_PIN0) |                                 \
1067
                                         PIN_MODE_INPUT(GPIOG_PIN1) |                                 \
1068
                                         PIN_MODE_INPUT(GPIOG_PIN2) |                                 \
1069
                                         PIN_MODE_INPUT(GPIOG_PIN3) |                                 \
1070
                                         PIN_MODE_INPUT(GPIOG_PIN4) |                                 \
1071
                                         PIN_MODE_INPUT(GPIOG_PIN5) |                                 \
1072
                                         PIN_MODE_INPUT(GPIOG_PIN6) |                                 \
1073
                                         PIN_MODE_INPUT(GPIOG_PIN7) |                                 \
1074
                                         PIN_MODE_INPUT(GPIOG_PIN8) |                                 \
1075
                                         PIN_MODE_INPUT(GPIOG_PIN9) |                                 \
1076
                                         PIN_MODE_INPUT(GPIOG_PIN10) |                                \
1077
                                         PIN_MODE_INPUT(GPIOG_PIN11) |                                \
1078
                                         PIN_MODE_INPUT(GPIOG_PIN12) |                                \
1079
                                         PIN_MODE_INPUT(GPIOG_PIN13) |                                \
1080
                                         PIN_MODE_INPUT(GPIOG_PIN14) |                                \
1081
                                         PIN_MODE_INPUT(GPIOG_PIN15))
1082
#define VAL_GPIOG_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOG_PIN0) |                             \
1083
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN1) |                             \
1084
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN2) |                             \
1085
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN3) |                             \
1086
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN4) |                             \
1087
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN5) |                             \
1088
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN6) |                             \
1089
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN7) |                             \
1090
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN8) |                             \
1091
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN9) |                             \
1092
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN10) |                            \
1093
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN11) |                            \
1094
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN12) |                            \
1095
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN13) |                            \
1096
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN14) |                            \
1097
                                         PIN_OTYPE_PUSHPULL(GPIOG_PIN15))
1098
#define VAL_GPIOG_OSPEEDR               (PIN_OSPEED_LOW(GPIOG_PIN0) |                                 \
1099
                                         PIN_OSPEED_LOW(GPIOG_PIN1) |                                 \
1100
                                         PIN_OSPEED_LOW(GPIOG_PIN2) |                                 \
1101
                                         PIN_OSPEED_LOW(GPIOG_PIN3) |                                 \
1102
                                         PIN_OSPEED_LOW(GPIOG_PIN4) |                                 \
1103
                                         PIN_OSPEED_LOW(GPIOG_PIN5) |                                 \
1104
                                         PIN_OSPEED_LOW(GPIOG_PIN6) |                                 \
1105
                                         PIN_OSPEED_LOW(GPIOG_PIN7) |                                 \
1106
                                         PIN_OSPEED_LOW(GPIOG_PIN8) |                                 \
1107
                                         PIN_OSPEED_LOW(GPIOG_PIN9) |                                 \
1108
                                         PIN_OSPEED_LOW(GPIOG_PIN10) |                                \
1109
                                         PIN_OSPEED_LOW(GPIOG_PIN11) |                                \
1110
                                         PIN_OSPEED_LOW(GPIOG_PIN12) |                                \
1111
                                         PIN_OSPEED_LOW(GPIOG_PIN13) |                                \
1112
                                         PIN_OSPEED_LOW(GPIOG_PIN14) |                                \
1113
                                         PIN_OSPEED_LOW(GPIOG_PIN15))
1114
#define VAL_GPIOG_PUPDR                 (PIN_PUPDR_FLOATING(GPIOG_PIN0) |                             \
1115
                                         PIN_PUPDR_FLOATING(GPIOG_PIN1) |                             \
1116
                                         PIN_PUPDR_FLOATING(GPIOG_PIN2) |                             \
1117
                                         PIN_PUPDR_FLOATING(GPIOG_PIN3) |                             \
1118
                                         PIN_PUPDR_FLOATING(GPIOG_PIN4) |                             \
1119
                                         PIN_PUPDR_FLOATING(GPIOG_PIN5) |                             \
1120
                                         PIN_PUPDR_FLOATING(GPIOG_PIN6) |                             \
1121
                                         PIN_PUPDR_FLOATING(GPIOG_PIN7) |                             \
1122
                                         PIN_PUPDR_FLOATING(GPIOG_PIN8) |                             \
1123
                                         PIN_PUPDR_FLOATING(GPIOG_PIN9) |                             \
1124
                                         PIN_PUPDR_FLOATING(GPIOG_PIN10) |                            \
1125
                                         PIN_PUPDR_FLOATING(GPIOG_PIN11) |                            \
1126
                                         PIN_PUPDR_FLOATING(GPIOG_PIN12) |                            \
1127
                                         PIN_PUPDR_FLOATING(GPIOG_PIN13) |                            \
1128
                                         PIN_PUPDR_FLOATING(GPIOG_PIN14) |                            \
1129
                                         PIN_PUPDR_FLOATING(GPIOG_PIN15))
1130
#define VAL_GPIOG_ODR                   (PIN_ODR_LOW(GPIOG_PIN0) |                                    \
1131
                                         PIN_ODR_LOW(GPIOG_PIN1) |                                    \
1132
                                         PIN_ODR_LOW(GPIOG_PIN2) |                                    \
1133
                                         PIN_ODR_LOW(GPIOG_PIN3) |                                    \
1134
                                         PIN_ODR_LOW(GPIOG_PIN4) |                                    \
1135
                                         PIN_ODR_LOW(GPIOG_PIN5) |                                    \
1136
                                         PIN_ODR_LOW(GPIOG_PIN6) |                                    \
1137
                                         PIN_ODR_LOW(GPIOG_PIN7) |                                    \
1138
                                         PIN_ODR_LOW(GPIOG_PIN8) |                                    \
1139
                                         PIN_ODR_LOW(GPIOG_PIN9) |                                    \
1140
                                         PIN_ODR_LOW(GPIOG_PIN10) |                                   \
1141
                                         PIN_ODR_LOW(GPIOG_PIN11) |                                   \
1142
                                         PIN_ODR_LOW(GPIOG_PIN12) |                                   \
1143
                                         PIN_ODR_LOW(GPIOG_PIN13) |                                   \
1144
                                         PIN_ODR_LOW(GPIOG_PIN14) |                                   \
1145
                                         PIN_ODR_LOW(GPIOG_PIN15))
1146
#define VAL_GPIOG_AFRL                  (PIN_AFIO_AF(GPIOG_PIN0, STM32F4xx_AF_system) |               \
1147
                                         PIN_AFIO_AF(GPIOG_PIN1, STM32F4xx_AF_system) |               \
1148
                                         PIN_AFIO_AF(GPIOG_PIN2, STM32F4xx_AF_system) |               \
1149
                                         PIN_AFIO_AF(GPIOG_PIN3, STM32F4xx_AF_system) |               \
1150
                                         PIN_AFIO_AF(GPIOG_PIN4, STM32F4xx_AF_system) |               \
1151
                                         PIN_AFIO_AF(GPIOG_PIN5, STM32F4xx_AF_system) |               \
1152
                                         PIN_AFIO_AF(GPIOG_PIN6, STM32F4xx_AF_system) |               \
1153
                                         PIN_AFIO_AF(GPIOG_PIN7, STM32F4xx_AF_system))
1154
#define VAL_GPIOG_AFRH                  (PIN_AFIO_AF(GPIOG_PIN8, STM32F4xx_AF_system) |               \
1155
                                         PIN_AFIO_AF(GPIOG_PIN9, STM32F4xx_AF_system) |               \
1156
                                         PIN_AFIO_AF(GPIOG_PIN10, STM32F4xx_AF_system) |              \
1157
                                         PIN_AFIO_AF(GPIOG_PIN11, STM32F4xx_AF_system) |              \
1158
                                         PIN_AFIO_AF(GPIOG_PIN12, STM32F4xx_AF_system) |              \
1159
                                         PIN_AFIO_AF(GPIOG_PIN13, STM32F4xx_AF_system) |              \
1160
                                         PIN_AFIO_AF(GPIOG_PIN14, STM32F4xx_AF_system) |              \
1161
                                         PIN_AFIO_AF(GPIOG_PIN15, STM32F4xx_AF_system))
1162

    
1163
/*
1164
 * GPIOH setup:
1165
 *
1166
 * PH0  - OSC_IN                        (input floating)
1167
 * PH1  - OSC_OUT                       (input floating)
1168
 * PH2  - PIN2                          (input floating)
1169
 * PH3  - PIN3                          (input floating)
1170
 * PH4  - PIN4                          (input floating)
1171
 * PH5  - PIN5                          (input floating)
1172
 * PH6  - PIN6                          (input floating)
1173
 * PH7  - PIN7                          (input floating)
1174
 * PH8  - PIN8                          (input floating)
1175
 * PH9  - PIN9                          (input floating)
1176
 * PH10 - PIN10                         (input floating)
1177
 * PH11 - PIN11                         (input floating)
1178
 * PH12 - PIN12                         (input floating)
1179
 * PH13 - PIN13                         (input floating)
1180
 * PH14 - PIN14                         (input floating)
1181
 * PH15 - PIN15                         (input floating)
1182
 */
1183
#define VAL_GPIOH_IGNORE                0
1184
#define VAL_GPIOH_MODER                 (PIN_MODE_INPUT(GPIOH_OSC_IN) |                               \
1185
                                         PIN_MODE_INPUT(GPIOH_OSC_OUT) |                              \
1186
                                         PIN_MODE_INPUT(GPIOH_PIN2) |                                 \
1187
                                         PIN_MODE_INPUT(GPIOH_PIN3) |                                 \
1188
                                         PIN_MODE_INPUT(GPIOH_PIN4) |                                 \
1189
                                         PIN_MODE_INPUT(GPIOH_PIN5) |                                 \
1190
                                         PIN_MODE_INPUT(GPIOH_PIN6) |                                 \
1191
                                         PIN_MODE_INPUT(GPIOH_PIN7) |                                 \
1192
                                         PIN_MODE_INPUT(GPIOH_PIN8) |                                 \
1193
                                         PIN_MODE_INPUT(GPIOH_PIN9) |                                 \
1194
                                         PIN_MODE_INPUT(GPIOH_PIN10) |                                \
1195
                                         PIN_MODE_INPUT(GPIOH_PIN11) |                                \
1196
                                         PIN_MODE_INPUT(GPIOH_PIN12) |                                \
1197
                                         PIN_MODE_INPUT(GPIOH_PIN13) |                                \
1198
                                         PIN_MODE_INPUT(GPIOH_PIN14) |                                \
1199
                                         PIN_MODE_INPUT(GPIOH_PIN15))
1200
#define VAL_GPIOH_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOH_OSC_IN) |                           \
1201
                                         PIN_OTYPE_PUSHPULL(GPIOH_OSC_OUT) |                          \
1202
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN2) |                             \
1203
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN3) |                             \
1204
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN4) |                             \
1205
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN5) |                             \
1206
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN6) |                             \
1207
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN7) |                             \
1208
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN8) |                             \
1209
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN9) |                             \
1210
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN10) |                            \
1211
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN11) |                            \
1212
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN12) |                            \
1213
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN13) |                            \
1214
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN14) |                            \
1215
                                         PIN_OTYPE_PUSHPULL(GPIOH_PIN15))
1216
#define VAL_GPIOH_OSPEEDR               (PIN_OSPEED_VERYHIGH(GPIOH_OSC_IN) |                          \
1217
                                         PIN_OSPEED_VERYHIGH(GPIOH_OSC_OUT) |                         \
1218
                                         PIN_OSPEED_LOW(GPIOH_PIN2) |                                 \
1219
                                         PIN_OSPEED_LOW(GPIOH_PIN3) |                                 \
1220
                                         PIN_OSPEED_LOW(GPIOH_PIN4) |                                 \
1221
                                         PIN_OSPEED_LOW(GPIOH_PIN5) |                                 \
1222
                                         PIN_OSPEED_LOW(GPIOH_PIN6) |                                 \
1223
                                         PIN_OSPEED_LOW(GPIOH_PIN7) |                                 \
1224
                                         PIN_OSPEED_LOW(GPIOH_PIN8) |                                 \
1225
                                         PIN_OSPEED_LOW(GPIOH_PIN9) |                                 \
1226
                                         PIN_OSPEED_LOW(GPIOH_PIN10) |                                \
1227
                                         PIN_OSPEED_LOW(GPIOH_PIN11) |                                \
1228
                                         PIN_OSPEED_LOW(GPIOH_PIN12) |                                \
1229
                                         PIN_OSPEED_LOW(GPIOH_PIN13) |                                \
1230
                                         PIN_OSPEED_LOW(GPIOH_PIN14) |                                \
1231
                                         PIN_OSPEED_LOW(GPIOH_PIN15))
1232
#define VAL_GPIOH_PUPDR                 (PIN_PUPDR_FLOATING(GPIOH_OSC_IN) |                           \
1233
                                         PIN_PUPDR_FLOATING(GPIOH_OSC_OUT) |                          \
1234
                                         PIN_PUPDR_FLOATING(GPIOH_PIN2) |                             \
1235
                                         PIN_PUPDR_FLOATING(GPIOH_PIN3) |                             \
1236
                                         PIN_PUPDR_FLOATING(GPIOH_PIN4) |                             \
1237
                                         PIN_PUPDR_FLOATING(GPIOH_PIN5) |                             \
1238
                                         PIN_PUPDR_FLOATING(GPIOH_PIN6) |                             \
1239
                                         PIN_PUPDR_FLOATING(GPIOH_PIN7) |                             \
1240
                                         PIN_PUPDR_FLOATING(GPIOH_PIN8) |                             \
1241
                                         PIN_PUPDR_FLOATING(GPIOH_PIN9) |                             \
1242
                                         PIN_PUPDR_FLOATING(GPIOH_PIN10) |                            \
1243
                                         PIN_PUPDR_FLOATING(GPIOH_PIN11) |                            \
1244
                                         PIN_PUPDR_FLOATING(GPIOH_PIN12) |                            \
1245
                                         PIN_PUPDR_FLOATING(GPIOH_PIN13) |                            \
1246
                                         PIN_PUPDR_FLOATING(GPIOH_PIN14) |                            \
1247
                                         PIN_PUPDR_FLOATING(GPIOH_PIN15))
1248
#define VAL_GPIOH_ODR                   (PIN_ODR_HIGH(GPIOH_OSC_IN) |                                 \
1249
                                         PIN_ODR_HIGH(GPIOH_OSC_OUT) |                                \
1250
                                         PIN_ODR_HIGH(GPIOH_PIN2) |                                   \
1251
                                         PIN_ODR_HIGH(GPIOH_PIN3) |                                   \
1252
                                         PIN_ODR_HIGH(GPIOH_PIN4) |                                   \
1253
                                         PIN_ODR_HIGH(GPIOH_PIN5) |                                   \
1254
                                         PIN_ODR_HIGH(GPIOH_PIN6) |                                   \
1255
                                         PIN_ODR_HIGH(GPIOH_PIN7) |                                   \
1256
                                         PIN_ODR_HIGH(GPIOH_PIN8) |                                   \
1257
                                         PIN_ODR_HIGH(GPIOH_PIN9) |                                   \
1258
                                         PIN_ODR_HIGH(GPIOH_PIN10) |                                  \
1259
                                         PIN_ODR_HIGH(GPIOH_PIN11) |                                  \
1260
                                         PIN_ODR_HIGH(GPIOH_PIN12) |                                  \
1261
                                         PIN_ODR_HIGH(GPIOH_PIN13) |                                  \
1262
                                         PIN_ODR_HIGH(GPIOH_PIN14) |                                  \
1263
                                         PIN_ODR_HIGH(GPIOH_PIN15))
1264
#define VAL_GPIOH_AFRL                  (PIN_AFIO_AF(GPIOH_OSC_IN, STM32F4xx_AF_system) |             \
1265
                                         PIN_AFIO_AF(GPIOH_OSC_OUT, STM32F4xx_AF_system) |            \
1266
                                         PIN_AFIO_AF(GPIOH_PIN2, STM32F4xx_AF_system) |               \
1267
                                         PIN_AFIO_AF(GPIOH_PIN3, STM32F4xx_AF_system) |               \
1268
                                         PIN_AFIO_AF(GPIOH_PIN4, STM32F4xx_AF_system) |               \
1269
                                         PIN_AFIO_AF(GPIOH_PIN5, STM32F4xx_AF_system) |               \
1270
                                         PIN_AFIO_AF(GPIOH_PIN6, STM32F4xx_AF_system) |               \
1271
                                         PIN_AFIO_AF(GPIOH_PIN7, STM32F4xx_AF_system))
1272
#define VAL_GPIOH_AFRH                  (PIN_AFIO_AF(GPIOH_PIN8, STM32F4xx_AF_system) |               \
1273
                                         PIN_AFIO_AF(GPIOH_PIN9, STM32F4xx_AF_system) |               \
1274
                                         PIN_AFIO_AF(GPIOH_PIN10, STM32F4xx_AF_system) |              \
1275
                                         PIN_AFIO_AF(GPIOH_PIN11, STM32F4xx_AF_system) |              \
1276
                                         PIN_AFIO_AF(GPIOH_PIN12, STM32F4xx_AF_system) |              \
1277
                                         PIN_AFIO_AF(GPIOH_PIN13, STM32F4xx_AF_system) |              \
1278
                                         PIN_AFIO_AF(GPIOH_PIN14, STM32F4xx_AF_system) |              \
1279
                                         PIN_AFIO_AF(GPIOH_PIN15, STM32F4xx_AF_system))
1280

    
1281
/*
1282
 * GPIOI setup:
1283
 *
1284
 * PI0  - PIN0                          (input floating)
1285
 * PI1  - PIN1                          (input floating)
1286
 * PI2  - PIN2                          (input floating)
1287
 * PI3  - PIN3                          (input floating)
1288
 * PI4  - PIN4                          (input floating)
1289
 * PI5  - PIN5                          (input floating)
1290
 * PI6  - PIN6                          (input floating)
1291
 * PI7  - PIN7                          (input floating)
1292
 * PI8  - PIN8                          (input floating)
1293
 * PI9  - PIN9                          (input floating)
1294
 * PI10 - PIN10                         (input floating)
1295
 * PI11 - PIN11                         (input floating)
1296
 * PI12 - PIN12                         (input floating)
1297
 * PI13 - PIN13                         (input floating)
1298
 * PI14 - PIN14                         (input floating)
1299
 * PI15 - PIN15                         (input floating)
1300
 */
1301
#define VAL_GPIOI_IGNORE                0
1302
#define VAL_GPIOI_MODER                 (PIN_MODE_INPUT(GPIOI_PIN0) |                                 \
1303
                                         PIN_MODE_INPUT(GPIOI_PIN1) |                                 \
1304
                                         PIN_MODE_INPUT(GPIOI_PIN2) |                                 \
1305
                                         PIN_MODE_INPUT(GPIOI_PIN3) |                                 \
1306
                                         PIN_MODE_INPUT(GPIOI_PIN4) |                                 \
1307
                                         PIN_MODE_INPUT(GPIOI_PIN5) |                                 \
1308
                                         PIN_MODE_INPUT(GPIOI_PIN6) |                                 \
1309
                                         PIN_MODE_INPUT(GPIOI_PIN7) |                                 \
1310
                                         PIN_MODE_INPUT(GPIOI_PIN8) |                                 \
1311
                                         PIN_MODE_INPUT(GPIOI_PIN9) |                                 \
1312
                                         PIN_MODE_INPUT(GPIOI_PIN10) |                                \
1313
                                         PIN_MODE_INPUT(GPIOI_PIN11) |                                \
1314
                                         PIN_MODE_INPUT(GPIOI_PIN12) |                                \
1315
                                         PIN_MODE_INPUT(GPIOI_PIN13) |                                \
1316
                                         PIN_MODE_INPUT(GPIOI_PIN14) |                                \
1317
                                         PIN_MODE_INPUT(GPIOI_PIN15))
1318
#define VAL_GPIOI_OTYPER                (PIN_OTYPE_PUSHPULL(GPIOI_PIN0) |                             \
1319
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN1) |                             \
1320
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN2) |                             \
1321
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN3) |                             \
1322
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN4) |                             \
1323
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN5) |                             \
1324
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN6) |                             \
1325
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN7) |                             \
1326
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN8) |                             \
1327
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN9) |                             \
1328
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN10) |                            \
1329
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN11) |                            \
1330
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN12) |                            \
1331
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN13) |                            \
1332
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN14) |                            \
1333
                                         PIN_OTYPE_PUSHPULL(GPIOI_PIN15))
1334
#define VAL_GPIOI_OSPEEDR               (PIN_OSPEED_LOW(GPIOI_PIN0) |                                 \
1335
                                         PIN_OSPEED_LOW(GPIOI_PIN1) |                                 \
1336
                                         PIN_OSPEED_LOW(GPIOI_PIN2) |                                 \
1337
                                         PIN_OSPEED_LOW(GPIOI_PIN3) |                                 \
1338
                                         PIN_OSPEED_LOW(GPIOI_PIN4) |                                 \
1339
                                         PIN_OSPEED_LOW(GPIOI_PIN5) |                                 \
1340
                                         PIN_OSPEED_LOW(GPIOI_PIN6) |                                 \
1341
                                         PIN_OSPEED_LOW(GPIOI_PIN7) |                                 \
1342
                                         PIN_OSPEED_LOW(GPIOI_PIN8) |                                 \
1343
                                         PIN_OSPEED_LOW(GPIOI_PIN9) |                                 \
1344
                                         PIN_OSPEED_LOW(GPIOI_PIN10) |                                \
1345
                                         PIN_OSPEED_LOW(GPIOI_PIN11) |                                \
1346
                                         PIN_OSPEED_LOW(GPIOI_PIN12) |                                \
1347
                                         PIN_OSPEED_LOW(GPIOI_PIN13) |                                \
1348
                                         PIN_OSPEED_LOW(GPIOI_PIN14) |                                \
1349
                                         PIN_OSPEED_LOW(GPIOI_PIN15))
1350
#define VAL_GPIOI_PUPDR                 (PIN_PUPDR_FLOATING(GPIOI_PIN0) |                             \
1351
                                         PIN_PUPDR_FLOATING(GPIOI_PIN1) |                             \
1352
                                         PIN_PUPDR_FLOATING(GPIOI_PIN2) |                             \
1353
                                         PIN_PUPDR_FLOATING(GPIOI_PIN3) |                             \
1354
                                         PIN_PUPDR_FLOATING(GPIOI_PIN4) |                             \
1355
                                         PIN_PUPDR_FLOATING(GPIOI_PIN5) |                             \
1356
                                         PIN_PUPDR_FLOATING(GPIOI_PIN6) |                             \
1357
                                         PIN_PUPDR_FLOATING(GPIOI_PIN7) |                             \
1358
                                         PIN_PUPDR_FLOATING(GPIOI_PIN8) |                             \
1359
                                         PIN_PUPDR_FLOATING(GPIOI_PIN9) |                             \
1360
                                         PIN_PUPDR_FLOATING(GPIOI_PIN10) |                            \
1361
                                         PIN_PUPDR_FLOATING(GPIOI_PIN11) |                            \
1362
                                         PIN_PUPDR_FLOATING(GPIOI_PIN12) |                            \
1363
                                         PIN_PUPDR_FLOATING(GPIOI_PIN13) |                            \
1364
                                         PIN_PUPDR_FLOATING(GPIOI_PIN14) |                            \
1365
                                         PIN_PUPDR_FLOATING(GPIOI_PIN15))
1366
#define VAL_GPIOI_ODR                   (PIN_ODR_LOW(GPIOI_PIN0) |                                    \
1367
                                         PIN_ODR_LOW(GPIOI_PIN1) |                                    \
1368
                                         PIN_ODR_LOW(GPIOI_PIN2) |                                    \
1369
                                         PIN_ODR_LOW(GPIOI_PIN3) |                                    \
1370
                                         PIN_ODR_LOW(GPIOI_PIN4) |                                    \
1371
                                         PIN_ODR_LOW(GPIOI_PIN5) |                                    \
1372
                                         PIN_ODR_LOW(GPIOI_PIN6) |                                    \
1373
                                         PIN_ODR_LOW(GPIOI_PIN7) |                                    \
1374
                                         PIN_ODR_LOW(GPIOI_PIN8) |                                    \
1375
                                         PIN_ODR_LOW(GPIOI_PIN9) |                                    \
1376
                                         PIN_ODR_LOW(GPIOI_PIN10) |                                   \
1377
                                         PIN_ODR_LOW(GPIOI_PIN11) |                                   \
1378
                                         PIN_ODR_LOW(GPIOI_PIN12) |                                   \
1379
                                         PIN_ODR_LOW(GPIOI_PIN13) |                                   \
1380
                                         PIN_ODR_LOW(GPIOI_PIN14) |                                   \
1381
                                         PIN_ODR_LOW(GPIOI_PIN15))
1382
#define VAL_GPIOI_AFRL                  (PIN_AFIO_AF(GPIOI_PIN0, STM32F4xx_AF_system) |               \
1383
                                         PIN_AFIO_AF(GPIOI_PIN1, STM32F4xx_AF_system) |               \
1384
                                         PIN_AFIO_AF(GPIOI_PIN2, STM32F4xx_AF_system) |               \
1385
                                         PIN_AFIO_AF(GPIOI_PIN3, STM32F4xx_AF_system) |               \
1386
                                         PIN_AFIO_AF(GPIOI_PIN4, STM32F4xx_AF_system) |               \
1387
                                         PIN_AFIO_AF(GPIOI_PIN5, STM32F4xx_AF_system) |               \
1388
                                         PIN_AFIO_AF(GPIOI_PIN6, STM32F4xx_AF_system) |               \
1389
                                         PIN_AFIO_AF(GPIOI_PIN7, STM32F4xx_AF_system))
1390
#define VAL_GPIOI_AFRH                  (PIN_AFIO_AF(GPIOI_PIN8, STM32F4xx_AF_system) |               \
1391
                                         PIN_AFIO_AF(GPIOI_PIN9, STM32F4xx_AF_system) |               \
1392
                                         PIN_AFIO_AF(GPIOI_PIN10, STM32F4xx_AF_system) |              \
1393
                                         PIN_AFIO_AF(GPIOI_PIN11, STM32F4xx_AF_system) |              \
1394
                                         PIN_AFIO_AF(GPIOI_PIN12, STM32F4xx_AF_system) |              \
1395
                                         PIN_AFIO_AF(GPIOI_PIN13, STM32F4xx_AF_system) |              \
1396
                                         PIN_AFIO_AF(GPIOI_PIN14, STM32F4xx_AF_system) |              \
1397
                                         PIN_AFIO_AF(GPIOI_PIN15, STM32F4xx_AF_system))
1398

    
1399
#if !defined(_FROM_ASM_)
1400
#ifdef __cplusplus
1401
extern "C" {
1402
#endif
1403
  void boardInit(void);
1404
#ifdef __cplusplus
1405
}
1406
#endif
1407
#endif /* _FROM_ASM_ */
1408

    
1409
#endif /* BOARD_H */
1410

    
1411
/** @} */