board.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 STMicroelectronics STM3210E-EVAL evaluation board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_ST_STM3210E_EVAL
  22. #define BOARD_NAME "ST STM3210E-EVAL"
  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. * Note: Older board revisions should define STM32F10X_HD instead, please
  31. * verify the STM32 model mounted on your board. The change also
  32. * affects your linker script.
  33. */
  34. #define STM32F103xG
  35. /*
  36. * IO pins assignments.
  37. */
  38. #define GPIOA_WAKEUP_BUTTON 0
  39. #define GPIOB_SC_3V_5V 0
  40. #define GPIOB_SPI1_CS 2
  41. #define GPIOB_TEMP_INT 5
  42. #define GPIOB_USB_DISC 14
  43. #define GPIOC_SC_CMDVCC 6
  44. #define GPIOC_SC_OFF 7
  45. #define GPIOC_TAMPER_BUTTON 13
  46. #define GPIOD_JOY_DOWN 3
  47. #define GPIOF_LED1 6
  48. #define GPIOF_LED2 7
  49. #define GPIOF_LED3 8
  50. #define GPIOF_LED4 9
  51. #define GPIOF_SD_DETECT 11
  52. #define GPIOG_JOY_SEL 7
  53. #define GPIOG_USER_BUTTON 8
  54. #define GPIOG_JOY_RIGHT 13
  55. #define GPIOG_JOY_LEFT 14
  56. #define GPIOG_JOY_UP 15
  57. /*
  58. * I/O ports initial setup, this configuration is established soon after reset
  59. * in the initialization code.
  60. * Please refer to the STM32 Reference Manual for details.
  61. */
  62. #define PIN_ANALOG(n) (0 << (((n) & 7) * 4))
  63. #define PIN_OUTPUT_PP_10(n) (1 << (((n) & 7) * 4))
  64. #define PIN_OUTPUT_PP_2(n) (2 << (((n) & 7) * 4))
  65. #define PIN_OUTPUT_PP_50(n) (3 << (((n) & 7) * 4))
  66. #define PIN_INPUT(n) (4 << (((n) & 7) * 4))
  67. #define PIN_OUTPUT_OD_10(n) (5 << (((n) & 7) * 4))
  68. #define PIN_OUTPUT_OD_2(n) (6 << (((n) & 7) * 4))
  69. #define PIN_OUTPUT_OD_50(n) (7 << (((n) & 7) * 4))
  70. #define PIN_INPUT_PUD(n) (8 << (((n) & 7) * 4))
  71. #define PIN_ALTERNATE_PP_10(n) (9 << (((n) & 7) * 4))
  72. #define PIN_ALTERNATE_PP_2(n) (10 << (((n) & 7) * 4))
  73. #define PIN_ALTERNATE_PP_50(n) (11 << (((n) & 7) * 4))
  74. #define PIN_ALTERNATE_OD_10(n) (13 << (((n) & 7) * 4))
  75. #define PIN_ALTERNATE_OD_2(n) (14 << (((n) & 7) * 4))
  76. #define PIN_ALTERNATE_OD_50(n) (15 << (((n) & 7) * 4))
  77. #define PIN_UNDEFINED(n) PIN_INPUT_PUD(n)
  78. /*
  79. * Port A setup.
  80. */
  81. #define VAL_GPIOACRL (PIN_INPUT(0) | /* Wakeup Button. */ \
  82. PIN_OUTPUT_PP_50(1) | /* USART2_RTS. */ \
  83. PIN_ALTERNATE_PP_50(2) | /* USART2_TX. */ \
  84. PIN_INPUT(3) | /* USART2_RX. */ \
  85. PIN_UNDEFINED(4) | \
  86. PIN_ALTERNATE_PP_50(5) | /* SPI1_SCK. */ \
  87. PIN_INPUT(6) | /* SPI1_MISO. */ \
  88. PIN_ALTERNATE_PP_50(7)) /* SPI1_MOSI. */
  89. #define VAL_GPIOACRH (PIN_ALTERNATE_PP_50(8) | /* MCO. */ \
  90. PIN_ALTERNATE_PP_50(9) | /* USART1_TX. */ \
  91. PIN_INPUT(10) | /* USART1_RX. */ \
  92. PIN_INPUT_PUD(11) | /* USB_DM. */ \
  93. PIN_INPUT_PUD(12) | /* USB_DP. */ \
  94. PIN_INPUT(13) | /* TMS. */ \
  95. PIN_INPUT(14) | /* TCK. */ \
  96. PIN_INPUT(15)) /* TDI. */
  97. #define VAL_GPIOAODR 0xFFFFFFFF
  98. /*
  99. * Port B setup.
  100. */
  101. #define VAL_GPIOBCRL (PIN_OUTPUT_PP_50(0) | /* SmartCard_3/5V. */ \
  102. PIN_INPUT_PUD(1) | /* Unconnected. */ \
  103. PIN_OUTPUT_PP_50(2) | /* SPI1_CS. */ \
  104. PIN_INPUT(3) | /* TDO. */ \
  105. PIN_INPUT(4) | /* TRST. */ \
  106. PIN_INPUT_PUD(5) | /* Temp.Sensor INT. */ \
  107. PIN_ALTERNATE_OD_50(6) | /* I2C1_SCK. */ \
  108. PIN_ALTERNATE_OD_50(7)) /* I2C1_SDA. */
  109. #define VAL_GPIOBCRH (PIN_INPUT(8) | /* CAN_RX. */ \
  110. PIN_ALTERNATE_PP_50(9) | /* CAN_TX. */ \
  111. PIN_ALTERNATE_OD_50(10)| /* SmartCard IO. */ \
  112. PIN_OUTPUT_PP_50(11) | /* SmartCard RST. */ \
  113. PIN_ALTERNATE_PP_50(12)| /* SmartCard CLK. */ \
  114. PIN_UNDEFINED(13) | \
  115. PIN_OUTPUT_PP_50(14) | /* USB disconnect. */ \
  116. PIN_UNDEFINED(15))
  117. #define VAL_GPIOBODR 0xFFFFFFFF
  118. /*
  119. * Port C setup.
  120. */
  121. #define VAL_GPIOCCRL (PIN_UNDEFINED(0) | \
  122. PIN_UNDEFINED(1) | \
  123. PIN_UNDEFINED(2) | \
  124. PIN_UNDEFINED(3) | \
  125. PIN_ANALOG(4) | /* Potentiometer. */ \
  126. PIN_UNDEFINED(5) | \
  127. PIN_OUTPUT_PP_50(6) | /* SmartCard CMDVCC. */ \
  128. PIN_INPUT(7)) /* SmartCard OFF. */
  129. #define VAL_GPIOCCRH (PIN_ALTERNATE_PP_50(8) | /* SDIO D0. */ \
  130. PIN_ALTERNATE_PP_50(9) | /* SDIO D1. */ \
  131. PIN_ALTERNATE_PP_50(10)| /* SDIO D2. */ \
  132. PIN_ALTERNATE_PP_50(11)| /* SDIO D3. */ \
  133. PIN_ALTERNATE_PP_50(12)| /* SDIO CLK. */ \
  134. PIN_INPUT(13) | /* Tamper Button. */ \
  135. PIN_INPUT(14) | /* OSC IN. */ \
  136. PIN_INPUT(15)) /* OSC OUT. */
  137. #define VAL_GPIOCODR 0xFFFFFFFF
  138. /*
  139. * Port D setup
  140. */
  141. #define VAL_GPIODCRL (PIN_ALTERNATE_PP_50(0) | /* FSMC_D2. */ \
  142. PIN_ALTERNATE_PP_50(1) | /* FSMC_D3. */ \
  143. PIN_ALTERNATE_PP_50(2) | /* SDIO CMD. */ \
  144. PIN_INPUT(3) | /* Joy Down. */ \
  145. PIN_ALTERNATE_PP_50(4) | /* FSMC_NOE. */ \
  146. PIN_ALTERNATE_PP_50(5) | /* FSMC_NWE. */ \
  147. PIN_INPUT(6) | /* FSMC_NWAIT. */ \
  148. PIN_ALTERNATE_PP_50(7)) /* FSMC_NCE2. */
  149. #define VAL_GPIODCRH (PIN_ALTERNATE_PP_50(8) | /* FSMC_D13. */ \
  150. PIN_ALTERNATE_PP_50(9) | /* FSMC_D14. */ \
  151. PIN_ALTERNATE_PP_50(10)| /* FSMC_D15. */ \
  152. PIN_ALTERNATE_PP_50(11)| /* FSMC_A16. */ \
  153. PIN_ALTERNATE_PP_50(12)| /* FSMC_A17. */ \
  154. PIN_ALTERNATE_PP_50(13)| /* FSMC_A18. */ \
  155. PIN_ALTERNATE_PP_50(14)| /* FSMC_D0. */ \
  156. PIN_ALTERNATE_PP_50(15)) /* FSMC_D1. */
  157. #define VAL_GPIODODR 0xFFFFFFFF
  158. /*
  159. * Port E setup.
  160. */
  161. #define VAL_GPIOECRL (PIN_ALTERNATE_PP_50(0) | /* FSMC_NBL0. */ \
  162. PIN_ALTERNATE_PP_50(1) | /* FSMC_NBL1. */ \
  163. PIN_ALTERNATE_PP_50(2) | /* FSMC_A23. */ \
  164. PIN_ALTERNATE_PP_50(3) | /* FSMC_A19. */ \
  165. PIN_ALTERNATE_PP_50(4) | /* FSMC_A20. */ \
  166. PIN_ALTERNATE_PP_50(5) | /* FSMC_A21. */ \
  167. PIN_ALTERNATE_PP_50(6) | /* FSMC_A22. */ \
  168. PIN_ALTERNATE_PP_50(7)) /* FSMC_D4. */
  169. #define VAL_GPIOECRH (PIN_ALTERNATE_PP_50(8) | /* FSMC_D5. */ \
  170. PIN_ALTERNATE_PP_50(9) | /* FSMC_D6. */ \
  171. PIN_ALTERNATE_PP_50(10)| /* FSMC_D7. */ \
  172. PIN_ALTERNATE_PP_50(11)| /* FSMC_D8. */ \
  173. PIN_ALTERNATE_PP_50(12)| /* FSMC_D9. */ \
  174. PIN_ALTERNATE_PP_50(13)| /* FSMC_D10. */ \
  175. PIN_ALTERNATE_PP_50(14)| /* FSMC_D11. */ \
  176. PIN_ALTERNATE_PP_50(15)) /* FSMC_D12. */
  177. #define VAL_GPIOEODR 0xFFFFFFFF
  178. /*
  179. * Port F setup.
  180. */
  181. #define VAL_GPIOFCRL (PIN_ALTERNATE_PP_50(0) | /* FSMC_A0. */ \
  182. PIN_ALTERNATE_PP_50(1) | /* FSMC_A1. */ \
  183. PIN_ALTERNATE_PP_50(2) | /* FSMC_A2. */ \
  184. PIN_ALTERNATE_PP_50(3) | /* FSMC_A3. */ \
  185. PIN_ALTERNATE_PP_50(4) | /* FSMC_A4. */ \
  186. PIN_ALTERNATE_PP_50(5) | /* FSMC_A5. */ \
  187. PIN_OUTPUT_PP_50(6) | /* LED1. */ \
  188. PIN_OUTPUT_PP_50(7)) /* LED2. */
  189. #define VAL_GPIOFCRH (PIN_OUTPUT_PP_50(8) | /* LED3. */ \
  190. PIN_OUTPUT_PP_50(9) | /* LED4. */ \
  191. PIN_UNDEFINED(10) | \
  192. PIN_INPUT_PUD(11) | /* SDCard detect. */ \
  193. PIN_ALTERNATE_PP_50(12)| /* FSMC_A6. */ \
  194. PIN_ALTERNATE_PP_50(13)| /* FSMC_A7. */ \
  195. PIN_ALTERNATE_PP_50(14)| /* FSMC_A8. */ \
  196. PIN_ALTERNATE_PP_50(15)) /* FSMC_A9. */
  197. #define VAL_GPIOFODR 0xFFFFFC3F
  198. /*
  199. * Port G setup.
  200. */
  201. #define VAL_GPIOGCRL (PIN_ALTERNATE_PP_50(0) | /* FSMC_A10. */ \
  202. PIN_ALTERNATE_PP_50(1) | /* FSMC_A11. */ \
  203. PIN_ALTERNATE_PP_50(2) | /* FSMC_A12. */ \
  204. PIN_ALTERNATE_PP_50(3) | /* FSMC_A13. */ \
  205. PIN_ALTERNATE_PP_50(4) | /* FSMC_A14. */ \
  206. PIN_ALTERNATE_PP_50(5) | /* FSMC_A15. */ \
  207. PIN_INPUT(6) | /* FSMC_INT2. */ \
  208. PIN_INPUT(7)) /* Joy Select. */
  209. #define VAL_GPIOGCRH (PIN_INPUT(8) | /* User Button. */ \
  210. PIN_ALTERNATE_PP_50(9) | /* FSMC_NE2. */ \
  211. PIN_ALTERNATE_PP_50(10)| /* FSMC_NE3. */ \
  212. PIN_OUTPUT_PP_50(11) | /* Audio PDN. */ \
  213. PIN_ALTERNATE_PP_50(12)| /* FSMC_NE4. */ \
  214. PIN_INPUT(13) | /* Joy Right. */ \
  215. PIN_INPUT(14) | /* Joy Left. */ \
  216. PIN_INPUT(15)) /* Joy Up. */
  217. #define VAL_GPIOGODR 0xFFFFF7FF
  218. /*
  219. * USB bus activation macro, required by the USB driver.
  220. */
  221. #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
  222. /*
  223. * USB bus de-activation macro, required by the USB driver.
  224. */
  225. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
  226. #if !defined(_FROM_ASM_)
  227. #ifdef __cplusplus
  228. extern "C" {
  229. #endif
  230. void boardInit(void);
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif /* _FROM_ASM_ */
  235. #endif /* _BOARD_H_ */