board.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 STMicroelectronics STM3220G-EVAL board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_ST_STM3220G_EVAL
  22. #define BOARD_NAME "ST STM3220G-EVAL"
  23. /*
  24. * Board frequencies.
  25. * NOTE: The HSE crystal is not fitted by default on the board.
  26. */
  27. #define STM32_LSECLK 32768
  28. #define STM32_HSECLK 25000000
  29. /*
  30. * MCU type as defined in the ST header file stm32f2xx.h.
  31. */
  32. #define STM32F207xx
  33. /*
  34. * IO pins assignments.
  35. */
  36. #define GPIOA_WAKEUP_BUTTON 0
  37. #define GPIOB_ETHER_INT 14
  38. #define GPIOB_NAND_INT 15
  39. #define GPIOC_TAMPER_BUTTON 0
  40. #define GPIOC_LED4 7
  41. #define GPIOF_POT 9
  42. #define GPIOG_LED1 6
  43. #define GPIOG_LED2 8
  44. #define GPIOG_USER_BUTTON 15
  45. #define GPIOH_EXPANDER_INT 12
  46. #define GPIOH_SD_DETECT 13
  47. #define GPIOI_LED3 9
  48. /*
  49. * I/O ports initial setup, this configuration is established soon after reset
  50. * in the initialization code.
  51. * Please refer to the STM32 Reference Manual for details.
  52. */
  53. #define PIN_MODE_INPUT(n) (0 << ((n) * 2))
  54. #define PIN_MODE_OUTPUT(n) (1 << ((n) * 2))
  55. #define PIN_MODE_ALTERNATE(n) (2 << ((n) * 2))
  56. #define PIN_MODE_ANALOG(n) (3 << ((n) * 2))
  57. #define PIN_OTYPE_PUSHPULL(n) (0 << (n))
  58. #define PIN_OTYPE_OPENDRAIN(n) (1 << (n))
  59. #define PIN_OSPEED_2M(n) (0 << ((n) * 2))
  60. #define PIN_OSPEED_25M(n) (1 << ((n) * 2))
  61. #define PIN_OSPEED_50M(n) (2 << ((n) * 2))
  62. #define PIN_OSPEED_100M(n) (3 << ((n) * 2))
  63. #define PIN_PUDR_FLOATING(n) (0 << ((n) * 2))
  64. #define PIN_PUDR_PULLUP(n) (1 << ((n) * 2))
  65. #define PIN_PUDR_PULLDOWN(n) (2 << ((n) * 2))
  66. #define PIN_AFIO_AF(n, v) ((v##U) << (((n) % 8) * 4))
  67. /*
  68. * Port A setup.
  69. * All input with pull-up except:
  70. * PA8 - MCO 1 (alternate 0).
  71. * PA13 - JTMS/SWDAT (alternate 0).
  72. * PA14 - JTCK/SWCLK (alternate 0).
  73. * PA15 - JTDI (alternate 0).
  74. */
  75. #define VAL_GPIOA_MODER (PIN_MODE_ALTERNATE(8) | \
  76. PIN_MODE_ALTERNATE(13) | \
  77. PIN_MODE_ALTERNATE(14) | \
  78. PIN_MODE_ALTERNATE(15))
  79. #define VAL_GPIOA_OTYPER 0x00000000
  80. #define VAL_GPIOA_OSPEEDR 0xFFFFFFFF
  81. #define VAL_GPIOA_PUPDR (PIN_PUDR_FLOATING(13) | \
  82. PIN_PUDR_FLOATING(14) | \
  83. PIN_PUDR_FLOATING(15))
  84. #define VAL_GPIOA_ODR 0xFFFFFFFF
  85. #define VAL_GPIOA_AFRL 0x00000000
  86. #define VAL_GPIOA_AFRH 0x00000000
  87. /*
  88. * Port B setup.
  89. * All input with pull-up except:
  90. * PB3 - JTDO (alternate 0).
  91. * PB4 - JNTRST (alternate 0).
  92. */
  93. #define VAL_GPIOB_MODER (PIN_MODE_ALTERNATE(3) | \
  94. PIN_MODE_ALTERNATE(4))
  95. #define VAL_GPIOB_OTYPER 0x00000000
  96. #define VAL_GPIOB_OSPEEDR 0xFFFFFFFF
  97. #define VAL_GPIOB_PUPDR (~(PIN_PUDR_FLOATING(3) | \
  98. PIN_PUDR_FLOATING(4)))
  99. #define VAL_GPIOB_ODR 0xFFFFFFFF
  100. #define VAL_GPIOB_AFRL 0x00000000
  101. #define VAL_GPIOB_AFRH 0x00000000
  102. /*
  103. * Port C setup.
  104. * All input with pull-up except:
  105. * PC9 - MCO2 (alternate 0).
  106. * PC10 - USART3_TX (alternate 7).
  107. * PC11 - USART3_RX (alternate 7).
  108. * PC14 - OSC32_INT (input floating).
  109. * PC15 - OSC32_OUT (input floating).
  110. */
  111. #define VAL_GPIOC_MODER (PIN_MODE_ALTERNATE(9) | \
  112. PIN_MODE_ALTERNATE(10) | \
  113. PIN_MODE_ALTERNATE(11))
  114. #define VAL_GPIOC_OTYPER 0x00000000
  115. #define VAL_GPIOC_OSPEEDR 0xFFFFFFFF
  116. #define VAL_GPIOC_PUPDR (~(PIN_PUDR_PULLUP(11) | \
  117. PIN_PUDR_FLOATING(14) | \
  118. PIN_PUDR_FLOATING(15)))
  119. #define VAL_GPIOC_ODR 0xFFFFFFFF
  120. #define VAL_GPIOC_AFRL 0x00000000
  121. #define VAL_GPIOC_AFRH (PIN_AFIO_AF(7, 10) | \
  122. PIN_AFIO_AF(7, 11))
  123. /*
  124. * Port D setup.
  125. * All input with pull-up.
  126. */
  127. #define VAL_GPIOD_MODER 0x00000000
  128. #define VAL_GPIOD_OTYPER 0x00000000
  129. #define VAL_GPIOD_OSPEEDR 0xFFFFFFFF
  130. #define VAL_GPIOD_PUPDR 0xFFFFFFFF
  131. #define VAL_GPIOD_ODR 0xFFFFFFFF
  132. #define VAL_GPIOD_AFRL 0x00000000
  133. #define VAL_GPIOD_AFRH 0x00000000
  134. /*
  135. * Port E setup.
  136. * All input with pull-up.
  137. */
  138. #define VAL_GPIOE_MODER 0x00000000
  139. #define VAL_GPIOE_OTYPER 0x00000000
  140. #define VAL_GPIOE_OSPEEDR 0xFFFFFFFF
  141. #define VAL_GPIOE_PUPDR 0xFFFFFFFF
  142. #define VAL_GPIOE_ODR 0xFFFFFFFF
  143. #define VAL_GPIOE_AFRL 0x00000000
  144. #define VAL_GPIOE_AFRH 0x00000000
  145. /*
  146. * Port F setup.
  147. * All input with pull-up.
  148. */
  149. #define VAL_GPIOF_MODER 0x00000000
  150. #define VAL_GPIOF_OTYPER 0x00000000
  151. #define VAL_GPIOF_OSPEEDR 0xFFFFFFFF
  152. #define VAL_GPIOF_PUPDR 0xFFFFFFFF
  153. #define VAL_GPIOF_ODR 0xFFFFFFFF
  154. #define VAL_GPIOF_AFRL 0x00000000
  155. #define VAL_GPIOF_AFRH 0x00000000
  156. /*
  157. * Port G setup.
  158. * All input with pull-up.
  159. */
  160. #define VAL_GPIOG_MODER (PIN_MODE_OUTPUT(GPIOG_LED1))
  161. #define VAL_GPIOG_OTYPER 0x00000000
  162. #define VAL_GPIOG_OSPEEDR 0xFFFFFFFF
  163. #define VAL_GPIOG_PUPDR (~(PIN_PUDR_FLOATING(GPIOG_LED1)))
  164. #define VAL_GPIOG_ODR 0xFFFFFFBF
  165. #define VAL_GPIOG_AFRL 0x00000000
  166. #define VAL_GPIOG_AFRH 0x00000000
  167. /*
  168. * Port H setup.
  169. * All input with pull-up.
  170. */
  171. #define VAL_GPIOH_MODER 0x00000000
  172. #define VAL_GPIOH_OTYPER 0x00000000
  173. #define VAL_GPIOH_OSPEEDR 0xFFFFFFFF
  174. #define VAL_GPIOH_PUPDR 0xFFFFFFFF
  175. #define VAL_GPIOH_ODR 0xFFFFFFFF
  176. #define VAL_GPIOH_AFRL 0x00000000
  177. #define VAL_GPIOH_AFRH 0x00000000
  178. /*
  179. * Port I setup.
  180. * All input with pull-up.
  181. */
  182. #define VAL_GPIOI_MODER 0x00000000
  183. #define VAL_GPIOI_OTYPER 0x00000000
  184. #define VAL_GPIOI_OSPEEDR 0xFFFFFFFF
  185. #define VAL_GPIOI_PUPDR 0xFFFFFFFF
  186. #define VAL_GPIOI_ODR 0xFFFFFFFF
  187. #define VAL_GPIOI_AFRL 0x00000000
  188. #define VAL_GPIOI_AFRH 0x00000000
  189. #if !defined(_FROM_ASM_)
  190. #ifdef __cplusplus
  191. extern "C" {
  192. #endif
  193. void boardInit(void);
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #endif /* _FROM_ASM_ */
  198. #endif /* _BOARD_H_ */