board.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 the ST INEMO-M1 Discovery board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_HY_STM32
  22. #define BOARD_NAME "HY-STM32"
  23. /*
  24. * Board frequencies.
  25. */
  26. #define STM32_LSECLK 32768
  27. #define STM32_HSECLK 8000000
  28. /*
  29. * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
  30. */
  31. #define STM32F103xE
  32. /*
  33. * IO pins assignments.
  34. */
  35. #define GPIOC_USB_DISC 13U
  36. #define GPIOE_TFT_RST 1U
  37. #define GPIOE_BUTTON1 5U
  38. #define GPIOE_BUTTON2 4U
  39. #define GPIOE_BUTTON3 3U
  40. #define GPIOE_BUTTON4 2U
  41. #define LINE_BUTTON1 PAL_LINE(GPIOE, GPIOE_BUTTON1)
  42. #define LINE_BUTTON2 PAL_LINE(GPIOE, GPIOE_BUTTON2)
  43. #define LINE_BUTTON3 PAL_LINE(GPIOE, GPIOE_BUTTON3)
  44. #define LINE_BUTTON4 PAL_LINE(GPIOE, GPIOE_BUTTON4)
  45. #define BUTTON_PRESSED PAL_LOW
  46. #define GPIOC_LED1 6U
  47. #define GPIOC_LED2 7U
  48. #define GPIOD_LED3 13U
  49. #define GPIOD_LED4 6U
  50. #define LINE_LED1 PAL_LINE(GPIOC, GPIOC_LED1)
  51. #define LINE_LED2 PAL_LINE(GPIOC, GPIOC_LED2)
  52. #define LINE_LED3 PAL_LINE(GPIOD, GPIOD_LED3)
  53. #define LINE_LED4 PAL_LINE(GPIOD, GPIOD_LED4)
  54. #define GPIOE_BUZZER 0U
  55. #define LINE_BUZZER PAL_LINE(GPIOE, GPIOE_BUZZER)
  56. #define LINE_RELAY1 PAL_LINE(GPIOA, GPIOA_PIN8)
  57. #define LINE_RELAY2 PAL_LINE(GPIOD, GPIOD_PIN12)
  58. #define GPIOA_PIN0 0U
  59. #define GPIOA_PIN1 1U
  60. #define GPIOA_PIN2 2U
  61. #define GPIOA_PIN3 3U
  62. #define GPIOA_PIN4 4U
  63. #define GPIOA_PIN5 5U
  64. #define GPIOA_PIN6 6U
  65. #define GPIOA_PIN7 7U
  66. #define GPIOA_PIN8 8U
  67. #define GPIOA_PIN9 9U
  68. #define GPIOA_PIN10 10U
  69. #define GPIOA_PIN11 11U
  70. #define GPIOA_PIN12 12U
  71. #define GPIOA_SWDIO 13U
  72. #define GPIOA_SWCLK 14U
  73. #define GPIOA_PIN15 15U
  74. #define GPIOB_PIN0 0U
  75. #define GPIOB_PIN1 1U
  76. #define GPIOB_PIN2 2U
  77. #define GPIOB_PIN3 3U
  78. #define GPIOB_PIN4 4U
  79. #define GPIOB_PIN5 5U
  80. #define GPIOB_PIN6 6U
  81. #define GPIOB_PIN7 7U
  82. #define GPIOB_PIN8 8U
  83. #define GPIOB_PIN9 9U
  84. #define GPIOB_PIN10 10U
  85. #define GPIOB_PIN11 11U
  86. #define GPIOB_PIN12 12U
  87. #define GPIOB_PIN13 13U
  88. #define GPIOB_PIN14 14U
  89. #define GPIOB_PIN15 15U
  90. #define GPIOC_PIN0 0U
  91. #define GPIOC_PIN1 1U
  92. #define GPIOC_PIN2 2U
  93. #define GPIOC_PIN3 3U
  94. #define GPIOC_PIN4 4U
  95. #define GPIOC_PIN5 5U
  96. #define GPIOC_PIN6 6U
  97. #define GPIOC_PIN7 7U
  98. #define GPIOC_PIN8 8U
  99. #define GPIOC_PIN9 9U
  100. #define GPIOC_PIN10 10U
  101. #define GPIOC_PIN11 11U
  102. #define GPIOC_PIN12 12U
  103. #define GPIOC_PIN13 13U
  104. #define GPIOC_PIN14 14U
  105. #define GPIOC_PIN15 15U
  106. #define GPIOD_PIN0 0U
  107. #define GPIOD_PIN1 1U
  108. #define GPIOD_PIN2 2U
  109. #define GPIOD_PIN3 3U
  110. #define GPIOD_PIN4 4U
  111. #define GPIOD_PIN5 5U
  112. #define GPIOD_PIN6 6U
  113. #define GPIOD_PIN7 7U
  114. #define GPIOD_PIN8 8U
  115. #define GPIOD_PIN9 9U
  116. #define GPIOD_PIN10 10U
  117. #define GPIOD_PIN11 11U
  118. #define GPIOD_PIN12 12U
  119. #define GPIOD_PIN13 13U
  120. #define GPIOD_PIN14 14U
  121. #define GPIOD_PIN15 15U
  122. #define GPIOE_PIN0 0U
  123. #define GPIOE_PIN1 1U
  124. #define GPIOE_PIN2 2U
  125. #define GPIOE_PIN3 3U
  126. #define GPIOE_PIN4 4U
  127. #define GPIOE_PIN5 5U
  128. #define GPIOE_PIN6 6U
  129. #define GPIOE_PIN7 7U
  130. #define GPIOE_PIN8 8U
  131. #define GPIOE_PIN9 9U
  132. #define GPIOE_PIN10 10U
  133. #define GPIOE_PIN11 11U
  134. #define GPIOE_PIN12 12U
  135. #define GPIOE_PIN13 13U
  136. #define GPIOE_PIN14 14U
  137. #define GPIOE_PIN15 15U
  138. #define GPIOF_PIN0 0U
  139. #define GPIOF_PIN1 1U
  140. #define GPIOF_PIN2 2U
  141. #define GPIOF_PIN3 3U
  142. #define GPIOF_PIN4 4U
  143. #define GPIOF_PIN5 5U
  144. #define GPIOF_PIN6 6U
  145. #define GPIOF_PIN7 7U
  146. #define GPIOF_PIN8 8U
  147. #define GPIOF_PIN9 9U
  148. #define GPIOF_PIN10 10U
  149. #define GPIOF_PIN11 11U
  150. #define GPIOF_PIN12 12U
  151. #define GPIOF_PIN13 13U
  152. #define GPIOF_PIN14 14U
  153. #define GPIOF_PIN15 15U
  154. /*
  155. * I/O ports initial setup, this configuration is established soon after reset
  156. * in the initialization code.
  157. *
  158. * The digits have the following meaning:
  159. * 0 - Analog input.
  160. * 1 - Push Pull output 10MHz.
  161. * 2 - Push Pull output 2MHz.
  162. * 3 - Push Pull output 50MHz.
  163. * 4 - Digital input.
  164. * 5 - Open Drain output 10MHz.
  165. * 6 - Open Drain output 2MHz.
  166. * 7 - Open Drain output 50MHz.
  167. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  168. * 9 - Alternate Push Pull output 10MHz.
  169. * A - Alternate Push Pull output 2MHz.
  170. * B - Alternate Push Pull output 50MHz.
  171. * C - Reserved.
  172. * D - Alternate Open Drain output 10MHz.
  173. * E - Alternate Open Drain output 2MHz.
  174. * F - Alternate Open Drain output 50MHz.
  175. * Please refer to the STM32 Reference Manual for details.
  176. */
  177. /*
  178. * Port A setup.
  179. * Everything input with pull-up except:
  180. * PA0 - GIOP J1.5
  181. * PA1 - GIOP J1.6
  182. * PA2 - Alternate output (USART2 TX MAX3232). / GIOP J1.36
  183. * PA3 - Normal input (USART2 RX MAX3232). / GIOP J1.35
  184. * PA4 - CS M25P16.1 / GIOP J1.3
  185. * PA5 - TP_DCLK (TFT.40) / SD_SCK (TFT.22) / C M25P16.6
  186. * PA6 - TP_DOUT (TFT.36) / SD_MISO (TFT.21) / Q M25P16.2
  187. * PA7 - TP_DIN (TFT.38) / SD_MOSI (TFT.23) / D M25P15.5
  188. * PA8 - Open Drain 50M (RELAY1/PWR CON3.4)
  189. * PA9 - Alternate output (USART1 TX PL2303). / GIOP J1.32
  190. * PA10 - Normal input (USART1 RX PL2303). / GIOP J1.31
  191. * PA11 - Normal input (USB DM). / GIOP J1.33
  192. * PA12 - Normal input (USB DP). / GIOP J1.34
  193. * PA13 - SWDIO / JTAG_TMS.7
  194. * PA14 - SWCLK / JTAG_TCK.9
  195. * PA15 - JTAG_TDI.5
  196. */
  197. #define VAL_GPIOACRL 0x88884B88 /* PA7...PA0 */
  198. #define VAL_GPIOACRH 0x888444B7 /* PA15...PA8 */
  199. #define VAL_GPIOAODR 0xFFFFFFFF
  200. /*
  201. * Port B setup.
  202. * Everything input with pull-up except:
  203. * PB0 - GPIO J1.13
  204. * PB1 - GPIO J1.16
  205. * PB2 - GPIO J1.15 / BOOT1
  206. * PB3 - JTAG_TDO.13
  207. * PB4 - JTAG_nRTST.3
  208. * PB5 - GPIO J1.18
  209. * PB6 - TP_IRQ (TFT.35)
  210. * PB7 - PP output 50M TP_CS (TFT.39)
  211. * PB8 - Alternate OD 50M (I2C1_SCL CON3.1)
  212. * PB9 - Alternate OD 50M (I2C1_SDA CON3.2)
  213. * PB10 - TFT.16
  214. * PB11 - TFT.18
  215. * PB12 - GPIO J1.24
  216. * PB13 - GPIO J1.23
  217. * PB14 - GPIO J1.26
  218. * PB15 - GPIO J1.55
  219. */
  220. #define VAL_GPIOBCRL 0x38888888 /* PB7...PB0 */
  221. #define VAL_GPIOBCRH 0x888888FF /* PB15...PB8 */
  222. #define VAL_GPIOBODR 0xFFFFFFFF
  223. /*
  224. * Port C setup.
  225. * Everything input with pull-up except:
  226. * PC0 - Analog Input CON3.6 (ADC_IN10).
  227. * PC1 - Analog Input CON3.5 (ADC_IN11).
  228. * PC2 - GPIO J1.7 (ADC_IN12).
  229. * PC3 - GPIO J1.8 (ADC_IN13).
  230. * PC4 - TFT.25 (ADC_IN14).
  231. * PC5 - TFT.26 (ADC_IN15).
  232. * PC6 - Output PP 50M (LED1)
  233. * PC7 - Output PP 50M (LED2)
  234. * PC8 - Alternate PP 50M (SD_D0 / GPIO J1.30).
  235. * PC9 - Alternate PP 50M (SD_D1 / GPIO J1.29).
  236. * PC10 - Alternate PP 50M (SD_D2 / GPIO J1.21).
  237. * PC11 - Alternate PP 50M (SD_D3 / GPIO J1.22).
  238. * PC12 - Alternate PP 50M (SD_CLK / GPIO J1.19).
  239. * PC13 - PP output 50M (USB Pull-UP / TFT.3)
  240. * PC14 - Normal input (XTAL).
  241. * PC15 - Normal input (XTAL).
  242. */
  243. #define VAL_GPIOCCRL 0x33880000 /* PC7...PC0 */
  244. #define VAL_GPIOCCRH 0x443BBBBB /* PC15...PC8 */
  245. #define VAL_GPIOCODR 0xFFFFFF3F
  246. /*
  247. * Port D setup.
  248. * Everything input with pull-up except:
  249. * PD0 - Alternate PP 50M (FSMC_DB2)
  250. * PD1 - Alternate PP 50M (FSMC_DB3)
  251. * PD2 - Alternate PP 50M (SDIO_CMD / GPIO J1.20)
  252. * PD3 - GPIO (J1.17)
  253. * PD4 - Alternate PP 50M (TFT_RD)
  254. * PD5 - Alternate PP 50M (TFT_WR)
  255. * PD6 - Output PP 50M (SD_CS1, LED4)
  256. * PD7 - Alternate PP 50M (TFT_CS)
  257. * PD8 - Alternate PP 50M (FSMC_DB13)
  258. * PD9 - Alternate PP 50M (FSMC_DB14)
  259. * PD10 - Alternate PP 50M (FSMC_DB15)
  260. * PD11 - Alternate PP 50M (TFT_RS - Data/Command)
  261. * PD12 - Output OD 50M (RELAY2 CON3.3)
  262. * PD13 - Output PP 50M (LED3)
  263. * PD14 - Alternate PP 50M (FSMC_DB0)
  264. * PD15 - Alternate PP 50M (FSMC_DB1)
  265. */
  266. #define VAL_GPIODCRL 0xB3BB8BBB /* PD7...PD0 */
  267. #define VAL_GPIODCRH 0xBB37BBBB /* PD15...PD8 */
  268. #define VAL_GPIODODR 0xFFFFDFBF
  269. /*
  270. * Port E setup.
  271. * Everything input with pull-up except:
  272. * PE0 - Digital Output (BUZZER J2 / GPIO J1.4)
  273. * PE1 - Digital Output (TFT_RESET)
  274. * PE2 - Digital input (KEY_S4 / GPIO J1.14)
  275. * PE3 - Digital input (KEY_S3 / GPIO J1.11)
  276. * PE4 - Digital input (KEY_S2 / GPIO J1.12)
  277. * PE5 - Digital input (KEY_S1 / GPIO J1.9)
  278. * PE6 - GPIO (J1.10)
  279. * PE7 - Alternate PP 50M (FSMC_DB4)
  280. * PE8 - Alternate PP 50M (FSMC_DB5)
  281. * PE9 - Alternate PP 50M (FSMC_DB6)
  282. * PE10 - Alternate PP 50M (FSMC_DB7)
  283. * PE11 - Alternate PP 50M (FSMC_DB8)
  284. * PE12 - Alternate PP 50M (FSMC_DB9)
  285. * PE13 - Alternate PP 50M (FSMC_DB10)
  286. * PE14 - Alternate PP 50M (FSMC_DB11)
  287. * PE15 - Alternate PP 50M (FSMC_DB12)
  288. */
  289. #define VAL_GPIOECRL 0xB8444433 /* PE7...PE0 */
  290. #define VAL_GPIOECRH 0xBBBBBBBB /* PE15...PE8 */
  291. #define VAL_GPIOEODR 0xFFFFFFFF
  292. /*
  293. * Port F setup.
  294. * Everything input with pull-up expect:
  295. */
  296. #define VAL_GPIOFCRL 0x88888888 /* PF7...PF0 */
  297. #define VAL_GPIOFCRH 0x88888888 /* PF15...PF8 */
  298. #define VAL_GPIOFODR 0xFFFFFFFF
  299. /*
  300. * Port G setup.
  301. * Everything input with pull-up expect:
  302. */
  303. #define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */
  304. #define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */
  305. #define VAL_GPIOGODR 0xFFFFFFFF
  306. /*
  307. * USB bus activation macro, required by the USB driver.
  308. */
  309. #define usb_lld_connect_bus(usbp) palClearPad(GPIOC, GPIOC_USB_DISC)
  310. /*
  311. * USB bus de-activation macro, required by the USB driver.
  312. */
  313. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOC, GPIOC_USB_DISC)
  314. #if !defined(_FROM_ASM_)
  315. #ifdef __cplusplus
  316. extern "C" {
  317. #endif
  318. void boardInit(void);
  319. #ifdef __cplusplus
  320. }
  321. #endif
  322. #endif /* _FROM_ASM_ */
  323. #endif /* _BOARD_H_ */