Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-1 / board.h @ 1703dfdf

History | View | Annotate | Download (107.935 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_MODE_INPUT(n)               (0U << ((n) * 2U))
303
#define PIN_MODE_OUTPUT(n)              (1U << ((n) * 2U))
304
#define PIN_MODE_ALTERNATE(n)           (2U << ((n) * 2U))
305
#define PIN_MODE_ANALOG(n)              (3U << ((n) * 2U))
306
#define PIN_ODR_LOW(n)                  (0U << (n))
307
#define PIN_ODR_HIGH(n)                 (1U << (n))
308
#define PIN_OTYPE_PUSHPULL(n)           (0U << (n))
309
#define PIN_OTYPE_OPENDRAIN(n)          (1U << (n))
310
#define PIN_OSPEED_LOW(n)               (0U << ((n) * 2U))
311
#define PIN_OSPEED_MEDIUM(n)            (1U << ((n) * 2U))
312
#define PIN_OSPEED_HIGH(n)              (2U << ((n) * 2U))
313
#define PIN_OSPEED_VERYHIGH(n)          (3U << ((n) * 2U))
314
#define PIN_PUPDR_FLOATING(n)           (0U << ((n) * 2U))
315
#define PIN_PUPDR_PULLUP(n)             (1U << ((n) * 2U))
316
#define PIN_PUPDR_PULLDOWN(n)           (2U << ((n) * 2U))
317
#define PIN_AFIO_AF(n, v)               ((v) << (((n) % 8U) * 4U))
318

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

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

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

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

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

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

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

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

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

    
1372
#if !defined(_FROM_ASM_)
1373
#ifdef __cplusplus
1374
extern "C" {
1375
#endif
1376
  void boardInit(void);
1377
#ifdef __cplusplus
1378
}
1379
#endif
1380
#endif /* _FROM_ASM_ */
1381

    
1382
#endif /* _BOARD_H_ */
1383

    
1384
/** @} */