board.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #ifndef _BOARD_H_
  14. #define _BOARD_H_
  15. /*
  16. * Setup for Olimex STM32-P407 board.
  17. * NOTE: Part of JTAG signals are used for other functions, this board can be
  18. * used using SWD only.
  19. */
  20. /*
  21. * Board identifier.
  22. */
  23. #define BOARD_OLIMEX_STM32_P407
  24. #define BOARD_NAME "Olimex STM32-P407"
  25. /*
  26. * Ethernet PHY type.
  27. */
  28. #define BOARD_PHY_ID MII_KS8721_ID
  29. #define BOARD_PHY_RMII
  30. /*
  31. * Board frequencies.
  32. * NOTE: The LSE crystal is not fitted by default on the board.
  33. */
  34. #define STM32_LSECLK 32768
  35. #define STM32_HSECLK 25000000
  36. /*
  37. * Board voltages.
  38. * Required for performance limits calculation.
  39. */
  40. #define STM32_VDD 330
  41. /*
  42. * MCU type as defined in the ST header.
  43. */
  44. #define STM32F407xx
  45. /*
  46. * IO pins assignments.
  47. */
  48. #define GPIOA_BUTTON_WKUP 0
  49. #define GPIOA_ETH_RMII_REF_CLK 1
  50. #define GPIOA_ETH_RMII_MDIO 2
  51. #define GPIOA_ETH_RMII_MDINT 3
  52. #define GPIOA_DCMI_HSYNC 4
  53. #define GPIOA_LCD_SCK 5
  54. #define GPIOA_DCMI_PIXCLK 6
  55. #define GPIOA_ETH_RMII_CRS_DV 7
  56. #define GPIOA_MCO1 8
  57. #define GPIOA_OTG_FS_VBUS 9
  58. #define GPIOA_DCMI_D1 10
  59. #define GPIOA_OTG_FS_DM 11
  60. #define GPIOA_OTG_FS_DP 12
  61. #define GPIOA_SWDIO 13
  62. #define GPIOA_SWCLK 14
  63. #define GPIOA_I2S3_WS 15
  64. #define GPIOB_LCD_BL 0
  65. #define GPIOB_BUZ 1
  66. #define GPIOB_CAM_ENB 2
  67. #define GPIOB_I2S3_CK 3
  68. #define GPIOB_LCD_MISO 4
  69. #define GPIOB_I2S3_SD 5
  70. #define GPIOB_DCMI_D5 6
  71. #define GPIOB_DCMI_VSYNC 7
  72. #define GPIOB_CAN1_RX 8
  73. #define GPIOB_CAN1_TX 9
  74. #define GPIOB_USB_FS_FAULT 10
  75. #define GPIOB_ETH_RMII_TX_EN 11
  76. #define GPIOB_OTG_HS_ID 12
  77. #define GPIOB_OTG_HS_VBUS 13
  78. #define GPIOB_OTG_HS_DM 14
  79. #define GPIOB_OTG_HS_DP 15
  80. #define GPIOC_TRIM 0
  81. #define GPIOC_ETH_RMII_MDC 1
  82. #define GPIOC_USB_FS_VBUSON 2
  83. #define GPIOC_LCD_MOSI 3
  84. #define GPIOC_ETH_RMII_RXD0 4
  85. #define GPIOC_ETH_RMII_RXD1 5
  86. #define GPIOC_DCMI_D0_US6_TX 6
  87. #define GPIOC_I2S3_MCK 7
  88. #define GPIOC_DCMI_D2 8
  89. #define GPIOC_DCMI_D3 9
  90. #define GPIOC_SPI3_SCK 10
  91. #define GPIOC_SPI3_MISO 11
  92. #define GPIOC_SPI3_MOSI 12
  93. #define GPIOC_SWITCH_TAMPER 13
  94. #define GPIOC_OSC32_IN 14
  95. #define GPIOC_OSC32_OUT 15
  96. #define GPIOD_USELESS0 0
  97. #define GPIOD_USELESS1 1
  98. #define GPIOD_SPI3_CS 2
  99. #define GPIOD_LCD_RST 3
  100. #define GPIOD_USELESS4 4
  101. #define GPIOD_USELESS5 5
  102. #define GPIOD_LCD_CS 6
  103. #define GPIOD_USELESS7 7
  104. #define GPIOD_USART3_TX 8
  105. #define GPIOD_USART3_RX 9
  106. #define GPIOD_USELESS10 10
  107. #define GPIOD_USART3_CTS 11
  108. #define GPIOD_USART3_RTS 12
  109. #define GPIOD_USB_HS_FAULT 13
  110. #define GPIOD_USELESS14 14
  111. #define GPIOD_USELESS15 15
  112. #define GPIOE_0 0
  113. #define GPIOE_1 1
  114. #define GPIOE_TEMP_ALERT 2
  115. #define GPIOE_USB_HS_VBUSON 3
  116. #define GPIOE_4 4
  117. #define GPIOE_5 5
  118. #define GPIOE_6 6
  119. #define GPIOE_7 7
  120. #define GPIOE_8 8
  121. #define GPIOE_9 9
  122. #define GPIOE_10 10
  123. #define GPIOE_11 11
  124. #define GPIOE_12 12
  125. #define GPIOE_13 13
  126. #define GPIOE_14 14
  127. #define GPIOE_15 15
  128. #define GPIOF_0 0
  129. #define GPIOF_1 1
  130. #define GPIOF_2 2
  131. #define GPIOF_3 3
  132. #define GPIOF_4 4
  133. #define GPIOF_5 5
  134. #define GPIOF_STAT1 6
  135. #define GPIOF_STAT2 7
  136. #define GPIOF_STAT3 8
  137. #define GPIOF_CAM_PWR 9
  138. #define GPIOF_10 10
  139. #define GPIOF_CAM_RS 11
  140. #define GPIOF_12 12
  141. #define GPIOF_13 13
  142. #define GPIOF_14 14
  143. #define GPIOF_15 15
  144. #define GPIOG_0 0
  145. #define GPIOG_1 1
  146. #define GPIOG_2 2
  147. #define GPIOG_3 3
  148. #define GPIOG_4 4
  149. #define GPIOG_5 5
  150. #define GPIOG_RIGHT 6
  151. #define GPIOG_UP 7
  152. #define GPIOG_DOWN 8
  153. #define GPIOG_USART6_RX 9
  154. #define GPIOG_10 10
  155. #define GPIOG_LEFT 11
  156. #define GPIOG_12 12
  157. #define GPIOG_ETH_RMII_TXD0 13
  158. #define GPIOG_ETH_RMII_TXD1 14
  159. #define GPIOG_CENT 15
  160. #define GPIOH_OSC_IN 0
  161. #define GPIOH_OSC_OUT 1
  162. /*
  163. * I/O ports initial setup, this configuration is established soon after reset
  164. * in the initialization code.
  165. * Please refer to the STM32 Reference Manual for details.
  166. */
  167. #define PIN_MODE_INPUT(n) (0U << ((n) * 2))
  168. #define PIN_MODE_OUTPUT(n) (1U << ((n) * 2))
  169. #define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2))
  170. #define PIN_MODE_ANALOG(n) (3U << ((n) * 2))
  171. #define PIN_OTYPE_PUSHPULL(n) (0U << (n))
  172. #define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
  173. #define PIN_OSPEED_2M(n) (0U << ((n) * 2))
  174. #define PIN_OSPEED_25M(n) (1U << ((n) * 2))
  175. #define PIN_OSPEED_50M(n) (2U << ((n) * 2))
  176. #define PIN_OSPEED_100M(n) (3U << ((n) * 2))
  177. #define PIN_PUDR_FLOATING(n) (0U << ((n) * 2))
  178. #define PIN_PUDR_PULLUP(n) (1U << ((n) * 2))
  179. #define PIN_PUDR_PULLDOWN(n) (2U << ((n) * 2))
  180. #define PIN_AFIO_AF(n, v) ((v##U) << (((n) % 8) * 4))
  181. /*
  182. * Port A setup.
  183. *
  184. * PA0 - GPIOA_BUTTON_WKUP (input floating).
  185. * PA1 - GPIOA_ETH_RMII_REF_CLK(alternate 11).
  186. * PA2 - GPIOA_ETH_RMII_MDIO (alternate 11).
  187. * PA3 - GPIOA_ETH_RMII_MDINT (input floating).
  188. * PA4 - GPIOA_DCMI_HSYNC (input pull-up).
  189. * PA5 - GPIOA_LCD_SCK (output push-pull).
  190. * PA6 - GPIOA_DCMI_PIXCLK (input pull-up).
  191. * PA7 - GPIOA_ETH_RMII_CRS_DV (alternate 11).
  192. * PA8 - GPIOA_MCO1 (alternate 0).
  193. * PA9 - GPIOA_OTG_FS_VBUS (input pull-up).
  194. * PA10 - GPIOA_DCMI_D1 (input pull-up).
  195. * PA11 - GPIOA_OTG_FS_DM (alternate 10).
  196. * PA12 - GPIOA_OTG_FS_DP (alternate 10).
  197. * PA13 - GPIOA_SWDIO (alternate 0).
  198. * PA14 - GPIOA_SWCLK (alternate 0, pull-down).
  199. * PA15 - GPIOA_I2S3_WS (alternate 6).
  200. */
  201. #define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_BUTTON_WKUP) | \
  202. PIN_MODE_ALTERNATE(GPIOA_ETH_RMII_REF_CLK) | \
  203. PIN_MODE_ALTERNATE(GPIOA_ETH_RMII_MDIO) | \
  204. PIN_MODE_INPUT(GPIOA_ETH_RMII_MDINT) | \
  205. PIN_MODE_INPUT(GPIOA_DCMI_HSYNC) | \
  206. PIN_MODE_OUTPUT(GPIOA_LCD_SCK) | \
  207. PIN_MODE_INPUT(GPIOA_DCMI_PIXCLK) | \
  208. PIN_MODE_ALTERNATE(GPIOA_ETH_RMII_CRS_DV) | \
  209. PIN_MODE_ALTERNATE(GPIOA_MCO1) | \
  210. PIN_MODE_INPUT(GPIOA_OTG_FS_VBUS) | \
  211. PIN_MODE_INPUT(GPIOA_DCMI_D1) | \
  212. PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DM) | \
  213. PIN_MODE_ALTERNATE(GPIOA_OTG_FS_DP) | \
  214. PIN_MODE_ALTERNATE(GPIOA_SWDIO) | \
  215. PIN_MODE_ALTERNATE(GPIOA_SWCLK) | \
  216. PIN_MODE_ALTERNATE(GPIOA_I2S3_WS))
  217. #define VAL_GPIOA_OTYPER 0x00000000
  218. #define VAL_GPIOA_OSPEEDR 0xFFFFFFFF
  219. #define VAL_GPIOA_PUPDR (PIN_PUDR_PULLUP(GPIOA_DCMI_HSYNC) | \
  220. PIN_PUDR_PULLUP(GPIOA_DCMI_PIXCLK) | \
  221. PIN_PUDR_PULLDOWN(GPIOA_OTG_FS_VBUS) | \
  222. PIN_PUDR_PULLUP(GPIOA_DCMI_D1) | \
  223. PIN_PUDR_PULLDOWN(GPIOA_SWCLK))
  224. #define VAL_GPIOA_ODR 0xFFFFFFDF
  225. #define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_ETH_RMII_REF_CLK, 11) | \
  226. PIN_AFIO_AF(GPIOA_ETH_RMII_MDIO, 11) | \
  227. PIN_AFIO_AF(GPIOA_ETH_RMII_CRS_DV, 11))
  228. #define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_MCO1, 0) | \
  229. PIN_AFIO_AF(GPIOA_OTG_FS_DM, 10) | \
  230. PIN_AFIO_AF(GPIOA_OTG_FS_DP, 10) | \
  231. PIN_AFIO_AF(GPIOA_SWDIO, 0) | \
  232. PIN_AFIO_AF(GPIOA_SWCLK, 0) | \
  233. PIN_AFIO_AF(GPIOA_I2S3_WS, 6))
  234. /*
  235. * Port B setup.
  236. *
  237. * PB0 - GPIOB_LCD_BL (output push-pull).
  238. * PB1 - GPIOB_BUZ (output push-pull).
  239. * PB2 - GPIOB_CAM_ENB (input floating).
  240. * PB3 - GPIOB_I2S3_CK (alternate 6).
  241. * PB4 - GPIOB_LCD_MISO (input floating).
  242. * PB5 - GPIOB_I2S3_SD (alternate 6).
  243. * PB6 - GPIOB_DCMI_D5 (input pull-up).
  244. * PB7 - GPIOB_DCMI_VSYNC (input pull-up).
  245. * PB8 - GPIOB_CAN1_RX (alternate 9).
  246. * PB9 - GPIOB_CAN1_TX (alternate 9).
  247. * PB10 - GPIOB_USB_FS_FAULT (input floating).
  248. * PB11 - GPIOB_ETH_RMII_TX_EN (alternate 11).
  249. * PB12 - GPIOB_OTG_HS_ID (alternate 12).
  250. * PB13 - GPIOB_OTG_HS_VBUS (input pull-up).
  251. * PB14 - GPIOB_OTG_HS_DM (alternate 12).
  252. * PB15 - GPIOB_OTG_HS_DP (alternate 12).
  253. */
  254. #define VAL_GPIOB_MODER (PIN_MODE_OUTPUT(GPIOB_LCD_BL) | \
  255. PIN_MODE_OUTPUT(GPIOB_BUZ) | \
  256. PIN_MODE_INPUT(GPIOB_CAM_ENB) | \
  257. PIN_MODE_ALTERNATE(GPIOB_I2S3_CK) | \
  258. PIN_MODE_INPUT(GPIOB_LCD_MISO) | \
  259. PIN_MODE_ALTERNATE(GPIOB_I2S3_SD) | \
  260. PIN_MODE_INPUT(GPIOB_DCMI_D5) | \
  261. PIN_MODE_INPUT(GPIOB_DCMI_VSYNC) | \
  262. PIN_MODE_ALTERNATE(GPIOB_CAN1_RX) | \
  263. PIN_MODE_ALTERNATE(GPIOB_CAN1_TX) | \
  264. PIN_MODE_INPUT(GPIOB_USB_FS_FAULT) | \
  265. PIN_MODE_ALTERNATE(GPIOB_ETH_RMII_TX_EN) | \
  266. PIN_MODE_ALTERNATE(GPIOB_OTG_HS_ID) | \
  267. PIN_MODE_INPUT(GPIOB_OTG_HS_VBUS) | \
  268. PIN_MODE_ALTERNATE(GPIOB_OTG_HS_DM) | \
  269. PIN_MODE_ALTERNATE(GPIOB_OTG_HS_DP))
  270. #define VAL_GPIOB_OTYPER 0x00000000
  271. #define VAL_GPIOB_OSPEEDR 0xFFFFFFFF
  272. #define VAL_GPIOB_PUPDR (PIN_PUDR_PULLUP(GPIOB_DCMI_D5) | \
  273. PIN_PUDR_PULLUP(GPIOB_DCMI_VSYNC) | \
  274. PIN_PUDR_PULLDOWN(GPIOB_OTG_HS_VBUS))
  275. #define VAL_GPIOB_ODR 0xFFFFFFFC
  276. #define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_I2S3_CK, 6) | \
  277. PIN_AFIO_AF(GPIOB_I2S3_SD, 6))
  278. #define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_CAN1_RX, 9) | \
  279. PIN_AFIO_AF(GPIOB_CAN1_TX, 9) | \
  280. PIN_AFIO_AF(GPIOB_ETH_RMII_TX_EN, 11) | \
  281. PIN_AFIO_AF(GPIOB_OTG_HS_ID, 12) | \
  282. PIN_AFIO_AF(GPIOB_OTG_HS_DM, 12) | \
  283. PIN_AFIO_AF(GPIOB_OTG_HS_DP, 12))
  284. /*
  285. * Port C setup.
  286. *
  287. * PC0 - GPIOC_TRIM (input floating).
  288. * PC1 - GPIOC_ETH_RMII_MDC (alternate 11).
  289. * PC2 - GPIOC_USB_FS_VBUSON (output push-pull).
  290. * PC3 - GPIOC_LCD_MOSI (output push-pull).
  291. * PC4 - GPIOC_ETH_RMII_RXD0 (alternate 11).
  292. * PC5 - GPIOC_ETH_RMII_RXD1 (alternate 11).
  293. * PC6 - GPIOC_DCMI_D0_US6_TX (alternate 8).
  294. * PC7 - GPIOC_I2S3_MCK (alternate 6).
  295. * PC8 - GPIOC_DCMI_D2 (input pull-up).
  296. * PC9 - GPIOC_DCMI_D3 (input pull-up).
  297. * PC10 - GPIOC_SPI3_SCK (alternate 6).
  298. * PC11 - GPIOC_SPI3_MISO (alternate 6).
  299. * PC12 - GPIOC_SPI3_MOSI (alternate 6).
  300. * PC13 - GPIOC_SWITCH_TAMPER (input floating).
  301. * PC14 - GPIOC_OSC32_IN (input floating).
  302. * PC15 - GPIOC_OSC32_OUT (input floating).
  303. */
  304. #define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_TRIM) | \
  305. PIN_MODE_ALTERNATE(GPIOC_ETH_RMII_MDC) | \
  306. PIN_MODE_OUTPUT(GPIOC_USB_FS_VBUSON) | \
  307. PIN_MODE_OUTPUT(GPIOC_LCD_MOSI) | \
  308. PIN_MODE_ALTERNATE(GPIOC_ETH_RMII_RXD0) | \
  309. PIN_MODE_ALTERNATE(GPIOC_ETH_RMII_RXD1) | \
  310. PIN_MODE_ALTERNATE(GPIOC_DCMI_D0_US6_TX) | \
  311. PIN_MODE_ALTERNATE(GPIOC_I2S3_MCK) | \
  312. PIN_MODE_INPUT(GPIOC_DCMI_D2) | \
  313. PIN_MODE_INPUT(GPIOC_DCMI_D3) | \
  314. PIN_MODE_ALTERNATE(GPIOC_SPI3_SCK) | \
  315. PIN_MODE_ALTERNATE(GPIOC_SPI3_MISO) | \
  316. PIN_MODE_ALTERNATE(GPIOC_SPI3_MOSI) | \
  317. PIN_MODE_INPUT(GPIOC_SWITCH_TAMPER) | \
  318. PIN_MODE_INPUT(GPIOC_OSC32_IN) | \
  319. PIN_MODE_INPUT(GPIOC_OSC32_OUT))
  320. #define VAL_GPIOC_OTYPER 0x00000000
  321. #define VAL_GPIOC_OSPEEDR 0xFFFFFFFF
  322. #define VAL_GPIOC_PUPDR (PIN_PUDR_PULLUP(GPIOC_DCMI_D2) | \
  323. PIN_PUDR_PULLUP(GPIOC_DCMI_D3))
  324. #define VAL_GPIOC_ODR 0xFFFFFFF3
  325. #define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_ETH_RMII_MDC, 11) | \
  326. PIN_AFIO_AF(GPIOC_ETH_RMII_RXD0, 11) | \
  327. PIN_AFIO_AF(GPIOC_ETH_RMII_RXD1, 11) | \
  328. PIN_AFIO_AF(GPIOC_DCMI_D0_US6_TX, 8) | \
  329. PIN_AFIO_AF(GPIOC_I2S3_MCK, 6))
  330. #define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_SPI3_SCK, 6) | \
  331. PIN_AFIO_AF(GPIOC_SPI3_MISO, 6) | \
  332. PIN_AFIO_AF(GPIOC_SPI3_MOSI, 6))
  333. /*
  334. * Port D setup.
  335. *
  336. * PD0 - GPIOD_USELESS0 (input pull-up).
  337. * PD1 - GPIOD_USELESS1 (input pull-up).
  338. * PD2 - GPIOD_SPI3_CS (output opendrain).
  339. * PD3 - GPIOD_LCD_RST (output push-pull).
  340. * PD4 - GPIOD_USELESS4 (input pull-up).
  341. * PD5 - GPIOD_USELESS5 (input pull-up).
  342. * PD6 - GPIOD_LCD_CS (output push-pull).
  343. * PD7 - GPIOD_USELESS7 (input pull-up).
  344. * PD8 - GPIOD_USART3_TX (alternate 8).
  345. * PD9 - GPIOD_USART3_RX (alternate 8).
  346. * PD10 - GPIOD_USELESS10 (input pull-up).
  347. * PD11 - GPIOD_USART3_CTS (alternate 8).
  348. * PD12 - GPIOD_USART3_RTS (alternate 8).
  349. * PD13 - GPIOD_USB_HS_FAULT (input floating).
  350. * PD14 - GPIOD_USELESS14 (input pull-up).
  351. * PD15 - GPIOD_USELESS15 (input pull-up).
  352. */
  353. #define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_USELESS0) | \
  354. PIN_MODE_INPUT(GPIOD_USELESS1) | \
  355. PIN_MODE_OUTPUT(GPIOD_SPI3_CS) | \
  356. PIN_MODE_OUTPUT(GPIOD_LCD_RST) | \
  357. PIN_MODE_INPUT(GPIOD_USELESS4) | \
  358. PIN_MODE_INPUT(GPIOD_USELESS5) | \
  359. PIN_MODE_OUTPUT(GPIOD_LCD_CS) | \
  360. PIN_MODE_INPUT(GPIOD_USELESS7) | \
  361. PIN_MODE_ALTERNATE(GPIOD_USART3_TX) | \
  362. PIN_MODE_ALTERNATE(GPIOD_USART3_RX) | \
  363. PIN_MODE_INPUT(GPIOD_USELESS10) | \
  364. PIN_MODE_ALTERNATE(GPIOD_USART3_CTS) | \
  365. PIN_MODE_ALTERNATE(GPIOD_USART3_RTS) | \
  366. PIN_MODE_INPUT(GPIOD_USB_HS_FAULT) | \
  367. PIN_MODE_INPUT(GPIOD_USELESS14) | \
  368. PIN_MODE_INPUT(GPIOD_USELESS15))
  369. #define VAL_GPIOD_OTYPER PIN_OTYPE_OPENDRAIN(GPIOD_SPI3_CS)
  370. #define VAL_GPIOD_OSPEEDR 0xFFFFFFFF
  371. #define VAL_GPIOD_PUPDR (PIN_PUDR_PULLUP(GPIOD_USELESS0) | \
  372. PIN_PUDR_PULLUP(GPIOD_USELESS1) | \
  373. PIN_PUDR_PULLUP(GPIOD_USELESS4) | \
  374. PIN_PUDR_PULLUP(GPIOD_USELESS5) | \
  375. PIN_PUDR_PULLUP(GPIOD_USELESS7) | \
  376. PIN_PUDR_PULLUP(GPIOD_USELESS10) | \
  377. PIN_PUDR_PULLUP(GPIOD_USELESS14) | \
  378. PIN_PUDR_PULLUP(GPIOD_USELESS15))
  379. #define VAL_GPIOD_ODR 0xFFFFFFFF
  380. #define VAL_GPIOD_AFRL 0x00000000
  381. #define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_USART3_TX, 7) | \
  382. PIN_AFIO_AF(GPIOD_USART3_RX, 7) | \
  383. PIN_AFIO_AF(GPIOD_USART3_CTS, 7) | \
  384. PIN_AFIO_AF(GPIOD_USART3_RTS, 7))
  385. /*
  386. * Port E setup.
  387. *
  388. * PE0 - GPIOE_0 (input pull-up).
  389. * PE1 - GPIOE_1 (input pull-up).
  390. * PE2 - GPIOE_TEMP_ALERT (input floating).
  391. * PE3 - GPIOE_USB_HS_VBUSON (output push-pull).
  392. * PE4 - GPIOE_4 (input pull-up).
  393. * PE5 - GPIOE_5 (input pull-up).
  394. * PE6 - GPIOE_6 (input pull-up).
  395. * PE7 - GPIOE_7 (input pull-up).
  396. * PE8 - GPIOE_8 (input pull-up).
  397. * PE9 - GPIOE_9 (input pull-up).
  398. * PE10 - GPIOE_10 (input pull-up).
  399. * PE11 - GPIOE_11 (input pull-up).
  400. * PE12 - GPIOE_12 (input pull-up).
  401. * PE13 - GPIOE_13 (input pull-up).
  402. * PE14 - GPIOE_14 (input pull-up).
  403. * PE15 - GPIOE_15 (input pull-up).
  404. */
  405. #define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_0) | \
  406. PIN_MODE_INPUT(GPIOE_1) | \
  407. PIN_MODE_INPUT(GPIOE_TEMP_ALERT) | \
  408. PIN_MODE_OUTPUT(GPIOE_USB_HS_VBUSON) | \
  409. PIN_MODE_INPUT(GPIOE_4) | \
  410. PIN_MODE_INPUT(GPIOE_5) | \
  411. PIN_MODE_INPUT(GPIOE_6) | \
  412. PIN_MODE_INPUT(GPIOE_7) | \
  413. PIN_MODE_INPUT(GPIOE_8) | \
  414. PIN_MODE_INPUT(GPIOE_9) | \
  415. PIN_MODE_INPUT(GPIOE_10) | \
  416. PIN_MODE_INPUT(GPIOE_11) | \
  417. PIN_MODE_INPUT(GPIOE_12) | \
  418. PIN_MODE_INPUT(GPIOE_13) | \
  419. PIN_MODE_INPUT(GPIOE_14) | \
  420. PIN_MODE_INPUT(GPIOE_15))
  421. #define VAL_GPIOE_OTYPER 0x00000000
  422. #define VAL_GPIOE_OSPEEDR 0xFFFFFFFF
  423. #define VAL_GPIOE_PUPDR (PIN_PUDR_PULLUP(GPIOE_0) | \
  424. PIN_PUDR_PULLUP(GPIOE_1) | \
  425. PIN_PUDR_PULLUP(GPIOE_4) | \
  426. PIN_PUDR_PULLUP(GPIOE_5) | \
  427. PIN_PUDR_PULLUP(GPIOE_6) | \
  428. PIN_PUDR_PULLUP(GPIOE_7) | \
  429. PIN_PUDR_PULLUP(GPIOE_8) | \
  430. PIN_PUDR_PULLUP(GPIOE_9) | \
  431. PIN_PUDR_PULLUP(GPIOE_10) | \
  432. PIN_PUDR_PULLUP(GPIOE_11) | \
  433. PIN_PUDR_PULLUP(GPIOE_12) | \
  434. PIN_PUDR_PULLUP(GPIOE_13) | \
  435. PIN_PUDR_PULLUP(GPIOE_14) | \
  436. PIN_PUDR_PULLUP(GPIOE_15))
  437. #define VAL_GPIOE_ODR 0xFFFFFFF7
  438. #define VAL_GPIOE_AFRL 0x00000000
  439. #define VAL_GPIOE_AFRH 0x00000000
  440. /*
  441. * Port F setup.
  442. *
  443. * PF0 - GPIOF_0 (input pull-up).
  444. * PF1 - GPIOF_1 (input pull-up).
  445. * PF2 - GPIOF_2 (input pull-up).
  446. * PF3 - GPIOF_3 (input pull-up).
  447. * PF4 - GPIOF_4 (input pull-up).
  448. * PF5 - GPIOF_5 (input pull-up).
  449. * PF6 - GPIOF_STAT1 (output push-pull).
  450. * PF7 - GPIOF_STAT2 (output push-pull).
  451. * PF8 - GPIOF_STAT3 (output push-pull).
  452. * PF9 - GPIOF_CAM_PWR (output push-pull).
  453. * PF10 - GPIOF_10 (input pull-up).
  454. * PF11 - GPIOF_CAM_RS (output push-pull).
  455. * PF12 - GPIOF_12 (input pull-up).
  456. * PF13 - GPIOF_13 (input pull-up).
  457. * PF14 - GPIOF_14 (input pull-up).
  458. * PF15 - GPIOF_15 (input pull-up).
  459. */
  460. #define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_0) | \
  461. PIN_MODE_INPUT(GPIOF_1) | \
  462. PIN_MODE_INPUT(GPIOF_2) | \
  463. PIN_MODE_INPUT(GPIOF_3) | \
  464. PIN_MODE_INPUT(GPIOF_4) | \
  465. PIN_MODE_INPUT(GPIOF_5) | \
  466. PIN_MODE_OUTPUT(GPIOF_STAT1) | \
  467. PIN_MODE_OUTPUT(GPIOF_STAT2) | \
  468. PIN_MODE_OUTPUT(GPIOF_STAT3) | \
  469. PIN_MODE_OUTPUT(GPIOF_CAM_PWR) | \
  470. PIN_MODE_INPUT(GPIOF_10) | \
  471. PIN_MODE_OUTPUT(GPIOF_CAM_RS) | \
  472. PIN_MODE_INPUT(GPIOF_12) | \
  473. PIN_MODE_INPUT(GPIOF_13) | \
  474. PIN_MODE_INPUT(GPIOF_14) | \
  475. PIN_MODE_INPUT(GPIOF_15))
  476. #define VAL_GPIOF_OTYPER 0x00000000
  477. #define VAL_GPIOF_OSPEEDR 0xFFFFFFFF
  478. #define VAL_GPIOF_PUPDR (PIN_PUDR_PULLUP(GPIOF_0) | \
  479. PIN_PUDR_PULLUP(GPIOF_1) | \
  480. PIN_PUDR_PULLUP(GPIOF_2) | \
  481. PIN_PUDR_PULLUP(GPIOF_3) | \
  482. PIN_PUDR_PULLUP(GPIOF_4) | \
  483. PIN_PUDR_PULLUP(GPIOF_5) | \
  484. PIN_PUDR_PULLUP(GPIOF_10) | \
  485. PIN_PUDR_PULLUP(GPIOF_12) | \
  486. PIN_PUDR_PULLUP(GPIOF_13) | \
  487. PIN_PUDR_PULLUP(GPIOF_14) | \
  488. PIN_PUDR_PULLUP(GPIOF_15))
  489. #define VAL_GPIOF_ODR 0xFFFFFC3F
  490. #define VAL_GPIOF_AFRL 0x00000000
  491. #define VAL_GPIOF_AFRH 0x00000000
  492. /*
  493. * Port G setup.
  494. *
  495. * PG0 - GPIOG_0 (input pull-up).
  496. * PG1 - GPIOG_1 (input pull-up).
  497. * PG2 - GPIOG_2 (input pull-up).
  498. * PG3 - GPIOG_3 (input pull-up).
  499. * PG4 - GPIOG_4 (input pull-up).
  500. * PG5 - GPIOG_5 (input pull-up).
  501. * PG6 - GPIOG_RIGHT (input floating).
  502. * PG7 - GPIOG_UP (input floating).
  503. * PG8 - GPIOG_DOWN (input floating).
  504. * PG9 - GPIOG_USART6_RX (alternate 8).
  505. * PG10 - GPIOG_10 (input pull-up).
  506. * PG11 - GPIOG_LEFT (input floating).
  507. * PG12 - GPIOG_12 (input pull-up).
  508. * PG13 - GPIOG_ETH_RMII_TXD0 (alternate 11).
  509. * PG14 - GPIOG_ETH_RMII_TXD1 (alternate 11).
  510. * PG15 - GPIOG_CENT (input pull-up).
  511. */
  512. #define VAL_GPIOG_MODER (PIN_MODE_INPUT(GPIOG_0) | \
  513. PIN_MODE_INPUT(GPIOG_1) | \
  514. PIN_MODE_INPUT(GPIOG_2) | \
  515. PIN_MODE_INPUT(GPIOG_3) | \
  516. PIN_MODE_INPUT(GPIOG_4) | \
  517. PIN_MODE_INPUT(GPIOG_5) | \
  518. PIN_MODE_INPUT(GPIOG_RIGHT) | \
  519. PIN_MODE_INPUT(GPIOG_UP) | \
  520. PIN_MODE_INPUT(GPIOG_DOWN) | \
  521. PIN_MODE_ALTERNATE(GPIOG_USART6_RX) | \
  522. PIN_MODE_INPUT(GPIOG_10) | \
  523. PIN_MODE_INPUT(GPIOG_LEFT) | \
  524. PIN_MODE_INPUT(GPIOG_12) | \
  525. PIN_MODE_ALTERNATE(GPIOG_ETH_RMII_TXD0) | \
  526. PIN_MODE_ALTERNATE(GPIOG_ETH_RMII_TXD1) | \
  527. PIN_MODE_INPUT(GPIOG_CENT))
  528. #define VAL_GPIOG_OTYPER 0x00000000
  529. #define VAL_GPIOG_OSPEEDR 0xFFFFFFFF
  530. #define VAL_GPIOG_PUPDR (PIN_PUDR_PULLUP(GPIOG_0) | \
  531. PIN_PUDR_PULLUP(GPIOG_1) | \
  532. PIN_PUDR_PULLUP(GPIOG_2) | \
  533. PIN_PUDR_PULLUP(GPIOG_3) | \
  534. PIN_PUDR_PULLUP(GPIOG_4) | \
  535. PIN_PUDR_PULLUP(GPIOG_5) | \
  536. PIN_PUDR_PULLUP(GPIOG_10) | \
  537. PIN_PUDR_PULLUP(GPIOG_12))
  538. #define VAL_GPIOG_ODR 0xFFFFFFFF
  539. #define VAL_GPIOG_AFRL 0x00000000
  540. #define VAL_GPIOG_AFRH (PIN_AFIO_AF(GPIOG_USART6_RX, 8) | \
  541. PIN_AFIO_AF(GPIOG_ETH_RMII_TXD0, 11) | \
  542. PIN_AFIO_AF(GPIOG_ETH_RMII_TXD1, 11))
  543. /*
  544. * Port H setup.
  545. * All input with pull-up except:
  546. * PH0 - GPIOH_OSC_IN (input floating).
  547. * PH1 - GPIOH_OSC_OUT (input floating).
  548. */
  549. #define VAL_GPIOH_MODER (PIN_MODE_INPUT(GPIOH_OSC_IN) | \
  550. PIN_MODE_INPUT(GPIOH_OSC_OUT) | \
  551. PIN_MODE_INPUT(2) | \
  552. PIN_MODE_INPUT(3) | \
  553. PIN_MODE_INPUT(4) | \
  554. PIN_MODE_INPUT(5) | \
  555. PIN_MODE_INPUT(6) | \
  556. PIN_MODE_INPUT(7) | \
  557. PIN_MODE_INPUT(8) | \
  558. PIN_MODE_INPUT(9) | \
  559. PIN_MODE_INPUT(10) | \
  560. PIN_MODE_INPUT(11) | \
  561. PIN_MODE_INPUT(12) | \
  562. PIN_MODE_INPUT(13) | \
  563. PIN_MODE_INPUT(14) | \
  564. PIN_MODE_INPUT(15))
  565. #define VAL_GPIOH_OTYPER 0x00000000
  566. #define VAL_GPIOH_OSPEEDR 0xFFFFFFFF
  567. #define VAL_GPIOH_PUPDR (PIN_PUDR_FLOATING(GPIOH_OSC_IN) | \
  568. PIN_PUDR_FLOATING(GPIOH_OSC_OUT) | \
  569. PIN_PUDR_PULLUP(2) | \
  570. PIN_PUDR_PULLUP(3) | \
  571. PIN_PUDR_PULLUP(4) | \
  572. PIN_PUDR_PULLUP(5) | \
  573. PIN_PUDR_PULLUP(6) | \
  574. PIN_PUDR_PULLUP(7) | \
  575. PIN_PUDR_PULLUP(8) | \
  576. PIN_PUDR_PULLUP(9) | \
  577. PIN_PUDR_PULLUP(10) | \
  578. PIN_PUDR_PULLUP(11) | \
  579. PIN_PUDR_PULLUP(12) | \
  580. PIN_PUDR_PULLUP(13) | \
  581. PIN_PUDR_PULLUP(14) | \
  582. PIN_PUDR_PULLUP(15))
  583. #define VAL_GPIOH_ODR 0xFFFFFFFF
  584. #define VAL_GPIOH_AFRL 0x00000000
  585. #define VAL_GPIOH_AFRH 0x00000000
  586. /*
  587. * Port I setup.
  588. * All input with pull-up.
  589. */
  590. #define VAL_GPIOI_MODER 0x00000000
  591. #define VAL_GPIOI_OTYPER 0x00000000
  592. #define VAL_GPIOI_OSPEEDR 0xFFFFFFFF
  593. #define VAL_GPIOI_PUPDR (PIN_PUDR_PULLUP(0) | \
  594. PIN_PUDR_PULLUP(1) | \
  595. PIN_PUDR_PULLUP(2) | \
  596. PIN_PUDR_PULLUP(3) | \
  597. PIN_PUDR_PULLUP(4) | \
  598. PIN_PUDR_PULLUP(5) | \
  599. PIN_PUDR_PULLUP(6) | \
  600. PIN_PUDR_PULLUP(7) | \
  601. PIN_PUDR_PULLUP(8) | \
  602. PIN_PUDR_PULLUP(9) | \
  603. PIN_PUDR_PULLUP(10) | \
  604. PIN_PUDR_PULLUP(11) | \
  605. PIN_PUDR_PULLUP(12) | \
  606. PIN_PUDR_PULLUP(13) | \
  607. PIN_PUDR_PULLUP(14) | \
  608. PIN_PUDR_PULLUP(15))
  609. #define VAL_GPIOI_ODR 0xFFFFFFFF
  610. #define VAL_GPIOI_AFRL 0x00000000
  611. #define VAL_GPIOI_AFRH 0x00000000
  612. #if !defined(_FROM_ASM_)
  613. #ifdef __cplusplus
  614. extern "C" {
  615. #endif
  616. void boardInit(void);
  617. #ifdef __cplusplus
  618. }
  619. #endif
  620. #endif /* _FROM_ASM_ */
  621. #endif /* _BOARD_H_ */