Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / board.h @ 07ff44a7

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..2018  Thomas Schöpping et al.
4

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

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

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

    
19
/**
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
38
#define BOARD_NAME                      "AMiRo PowerManagement"
39
#define BOARD_VERSION                   "1.1"
40

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

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

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

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

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

    
83
/*
84
 * IO pins assignments.
85
 */
86
#define GPIOA_WKUP                      0U
87
#define GPIOA_PIN1                      1U
88
#define GPIOA_SYS_UART_TX               2U
89
#define GPIOA_SYS_UART_RX               3U
90
#define GPIOA_SYS_SPI_SS0_N             4U
91
#define GPIOA_SYS_SPI_SCLK              5U
92
#define GPIOA_SYS_SPI_MISO              6U
93
#define GPIOA_SYS_SPI_MOSI              7U
94
#define GPIOA_SYS_REG_EN                8U
95
#define GPIOA_PROG_RX                   9U
96
#define GPIOA_PROG_TX                   10U
97
#define GPIOA_CAN_RX                    11U
98
#define GPIOA_CAN_TX                    12U
99
#define GPIOA_SWDIO                     13U
100
#define GPIOA_SWCLK                     14U
101
#define GPIOA_SYS_SPI_SS1_N             15U
102

    
103
#define GPIOB_IR_INT1_N                 0U
104
#define GPIOB_VSYS_SENSE                1U
105
#define GPIOB_POWER_EN                  2U
106
#define GPIOB_SYS_UART_DN               3U
107
#define GPIOB_CHARGE_STAT2A             4U
108
#define GPIOB_BUZZER                    5U
109
#define GPIOB_GAUGE_BATLOW2             6U
110
#define GPIOB_GAUGE_BATGD2_N            7U
111
#define GPIOB_GAUGE_SCL2                8U
112
#define GPIOB_GAUGE_SDA2                9U
113
#define GPIOB_GAUGE_SCL1                10U
114
#define GPIOB_GAUGE_SDA1                11U
115
#define GPIOB_LED                       12U
116
#define GPIOB_BT_RTS                    13U
117
#define GPIOB_BT_CTS                    14U
118
#define GPIOB_SYS_UART_UP               15U
119

    
120
#define GPIOC_CHARGE_STAT1A             0U
121
#define GPIOC_GAUGE_BATLOW1             1U
122
#define GPIOC_GAUGE_BATGD1_N            2U
123
#define GPIOC_CHARGE_EN1_N              3U
124
#define GPIOC_IR_INT2_N                 4U
125
#define GPIOC_TOUCH_INT_N               5U
126
#define GPIOC_SYS_DONE                  6U
127
#define GPIOC_SYS_PROG_N                7U
128
#define GPIOC_PATH_DC                   8U
129
#define GPIOC_SYS_SPI_DIR               9U
130
#define GPIOC_BT_RX                     10U
131
#define GPIOC_BT_TX                     11U
132
#define GPIOC_SYS_INT_N                 12U
133
#define GPIOC_SYS_PD_N                  13U
134
#define GPIOC_SYS_WARMRST_N             14U
135
#define GPIOC_BT_RST                    15U
136

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

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

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

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

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

    
222
#define GPIOI_PIN0                      0U
223
#define GPIOI_PIN1                      1U
224
#define GPIOI_PIN2                      2U
225
#define GPIOI_PIN3                      3U
226
#define GPIOI_PIN4                      4U
227
#define GPIOI_PIN5                      5U
228
#define GPIOI_PIN6                      6U
229
#define GPIOI_PIN7                      7U
230
#define GPIOI_PIN8                      8U
231
#define GPIOI_PIN9                      9U
232
#define GPIOI_PIN10                     10U
233
#define GPIOI_PIN11                     11U
234
#define GPIOI_PIN12                     12U
235
#define GPIOI_PIN13                     13U
236
#define GPIOI_PIN14                     14U
237
#define GPIOI_PIN15                     15U
238

    
239
/*
240
 * IO lines assignments.
241
 */
242
#define LINE_WKUP                       PAL_LINE(GPIOA, GPIOA_WKUP)
243
#define LINE_SYS_UART_TX                PAL_LINE(GPIOA, GPIOA_SYS_UART_TX)
244
#define LINE_SYS_UART_RX                PAL_LINE(GPIOA, GPIOA_SYS_UART_RX)
245
#define LINE_SYS_SPI_SS0_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS0_N)
246
#define LINE_SYS_SPI_SCLK               PAL_LINE(GPIOA, GPIOA_SYS_SPI_SCLK)
247
#define LINE_SYS_SPI_MISO               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MISO)
248
#define LINE_SYS_SPI_MOSI               PAL_LINE(GPIOA, GPIOA_SYS_SPI_MOSI)
249
#define LINE_SYS_REG_EN                 PAL_LINE(GPIOA, GPIOA_SYS_REG_EN)
250
#define LINE_PROG_RX                    PAL_LINE(GPIOA, GPIOA_PROG_RX)
251
#define LINE_PROG_TX                    PAL_LINE(GPIOA, GPIOA_PROG_TX)
252
#define LINE_CAN_RX                     PAL_LINE(GPIOA, GPIOA_CAN_RX)
253
#define LINE_CAN_TX                     PAL_LINE(GPIOA, GPIOA_CAN_TX)
254
#define LINE_SWDIO                      PAL_LINE(GPIOA, GPIOA_SWDIO)
255
#define LINE_SWCLK                      PAL_LINE(GPIOA, GPIOA_SWCLK)
256
#define LINE_SYS_SPI_SS1_N              PAL_LINE(GPIOA, GPIOA_SYS_SPI_SS1_N)
257

    
258
#define LINE_IR_INT1_N                  PAL_LINE(GPIOB, GPIOB_IR_INT1_N)
259
#define LINE_VSYS_SENSE                 PAL_LINE(GPIOB, GPIOB_VSYS_SENSE)
260
#define LINE_POWER_EN                   PAL_LINE(GPIOB, GPIOB_POWER_EN)
261
#define LINE_SYS_UART_DN                PAL_LINE(GPIOB, GPIOB_SYS_UART_DN)
262
#define LINE_CHARGE_STAT2A              PAL_LINE(GPIOB, GPIOB_CHARGE_STAT2A)
263
#define LINE_BUZZER                     PAL_LINE(GPIOB, GPIOB_BUZZER)
264
#define LINE_GAUGE_BATLOW2              PAL_LINE(GPIOB, GPIOB_GAUGE_BATLOW2)
265
#define LINE_GAUGE_BATGD2_N             PAL_LINE(GPIOB, GPIOB_GAUGE_BATGD2_N)
266
#define LINE_GAUGE_SCL2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL2)
267
#define LINE_GAUGE_SDA2                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA2)
268
#define LINE_GAUGE_SCL1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SCL1)
269
#define LINE_GAUGE_SDA1                 PAL_LINE(GPIOB, GPIOB_GAUGE_SDA1)
270
#define LINE_LED                        PAL_LINE(GPIOB, GPIOB_LED)
271
#define LINE_BT_RTS                     PAL_LINE(GPIOB, GPIOB_BT_RTS)
272
#define LINE_BT_CTS                     PAL_LINE(GPIOB, GPIOB_BT_CTS)
273
#define LINE_SYS_UART_UP                PAL_LINE(GPIOB, GPIOB_SYS_UART_UP)
274

    
275
#define LINE_CHARGE_STAT1A              PAL_LINE(GPIOC, GPIOC_CHARGE_STAT1A)
276
#define LINE_GAUGE_BATLOW1              PAL_LINE(GPIOC, GPIOC_GAUGE_BATLOW1)
277
#define LINE_GAUGE_BATGD1_N             PAL_LINE(GPIOC, GPIOC_GAUGE_BATGD1_N)
278
#define LINE_CHARGE_EN1_N               PAL_LINE(GPIOC, GPIOC_CHARGE_EN1_N)
279
#define LINE_IR_INT2_N                  PAL_LINE(GPIOC, GPIOC_IR_INT2_N)
280
#define LINE_TOUCH_INT_N                PAL_LINE(GPIOC, GPIOC_TOUCH_INT_N)
281
#define LINE_SYS_DONE                   PAL_LINE(GPIOC, GPIOC_SYS_DONE)
282
#define LINE_SYS_PROG_N                 PAL_LINE(GPIOC, GPIOC_SYS_PROG_N)
283
#define LINE_PATH_DC                    PAL_LINE(GPIOC, GPIOC_PATH_DC)
284
#define LINE_SYS_SPI_DIR                PAL_LINE(GPIOC, GPIOC_SYS_SPI_DIR)
285
#define LINE_BT_RX                      PAL_LINE(GPIOC, GPIOC_BT_RX)
286
#define LINE_BT_TX                      PAL_LINE(GPIOC, GPIOC_BT_TX)
287
#define LINE_SYS_INT_N                  PAL_LINE(GPIOC, GPIOC_SYS_INT_N)
288
#define LINE_SYS_PD_N                   PAL_LINE(GPIOC, GPIOC_SYS_PD_N)
289
#define LINE_SYS_WARMRST_N              PAL_LINE(GPIOC, GPIOC_SYS_WARMRST_N)
290
#define LINE_BT_RST                     PAL_LINE(GPIOC, GPIOC_BT_RST)
291

    
292
#define LINE_CHARGE_EN2_N               PAL_LINE(GPIOD, GPIOD_CHARGE_EN2_N)
293

    
294
#define LINE_OSC_IN                     PAL_LINE(GPIOH, 0U)
295
#define LINE_OSC_OUT                    PAL_LINE(GPIOH, 1U)
296

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

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

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

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

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

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

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

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

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

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

    
1387
#if !defined(_FROM_ASM_)
1388
#ifdef __cplusplus
1389
extern "C" {
1390
#endif
1391
  void boardInit(void);
1392
#ifdef __cplusplus
1393
}
1394
#endif
1395
#endif /* _FROM_ASM_ */
1396

    
1397
#endif /* _BOARD_H_ */
1398

    
1399
/** @} */