board.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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_ST_NUCLEO64_F103RB
  22. #define BOARD_NAME "STMicroelectronics NUCLEO-F103RB"
  23. /*
  24. * Board frequencies.
  25. */
  26. #define STM32_LSECLK 0
  27. #if defined(NUCLEO_EXTERNAL_OSCILLATOR)
  28. #define STM32_HSECLK 8000000
  29. #define STM32_HSE_BYPASS
  30. #elif defined(NUCLEO_HSE_CRYSTAL)
  31. #define STM32_HSECLK 8000000
  32. #else
  33. #define STM32_HSECLK 0
  34. #endif
  35. /*
  36. * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
  37. */
  38. #define STM32F103xB
  39. /*
  40. * IO pins assignments.
  41. */
  42. #define GPIOA_ARD_A0 0U
  43. #define GPIOA_ADC1_IN0 0U
  44. #define GPIOA_ARD_A1 1U
  45. #define GPIOA_ADC1_IN1 1U
  46. #define GPIOA_ARD_D1 2U
  47. #define GPIOA_USART2_TX 2U
  48. #define GPIOA_ARD_D0 3U
  49. #define GPIOA_USART2_RX 3U
  50. #define GPIOA_ARD_A2 4U
  51. #define GPIOA_ADC1_IN4 4U
  52. #define GPIOA_LED_GREEN 5U
  53. #define GPIOA_ARD_D13 5U
  54. #define GPIOA_ARD_D12 6U
  55. #define GPIOA_ARD_D11 7U
  56. #define GPIOA_ARD_D7 8U
  57. #define GPIOA_ARD_D8 9U
  58. #define GPIOA_ARD_D2 10U
  59. #define GPIOA_PIN11 11U
  60. #define GPIOA_PIN12 12U
  61. #define GPIOA_SWDIO 13U
  62. #define GPIOA_SWCLK 14U
  63. #define GPIOA_PIN15 15U
  64. #define GPIOB_ARD_A3 0U
  65. #define GPIOB_ADC1_IN8 0U
  66. #define GPIOB_PIN1 1U
  67. #define GPIOB_PIN2 2U
  68. #define GPIOB_SWO 3U
  69. #define GPIOB_ARD_D3 3U
  70. #define GPIOB_ARD_D5 4U
  71. #define GPIOB_ARD_D4 5U
  72. #define GPIOB_ARD_D10 6U
  73. #define GPIOB_PIN7 7U
  74. #define GPIOB_ARD_D15 8U
  75. #define GPIOB_ARD_D14 9U
  76. #define GPIOB_ARD_D6 10U
  77. #define GPIOB_PIN11 11U
  78. #define GPIOB_PIN12 12U
  79. #define GPIOB_PIN13 13U
  80. #define GPIOB_PIN14 14U
  81. #define GPIOB_PIN15 15U
  82. #define GPIOC_ARD_A5 0U
  83. #define GPIOC_ADC1_IN11 0U
  84. #define GPIOC_ARD_A4 1U
  85. #define GPIOC_ADC1_IN10 1U
  86. #define GPIOC_PIN2 2U
  87. #define GPIOC_PIN3 3U
  88. #define GPIOC_PIN4 4U
  89. #define GPIOC_PIN5 5U
  90. #define GPIOC_PIN6 6U
  91. #define GPIOC_ARD_D9 7U
  92. #define GPIOC_PIN8 8U
  93. #define GPIOC_PIN9 9U
  94. #define GPIOC_PIN10 10U
  95. #define GPIOC_PIN11 11U
  96. #define GPIOC_PIN12 12U
  97. #define GPIOC_BUTTON 13U
  98. #define GPIOC_PIN14 14U
  99. #define GPIOC_PIN15 15U
  100. #define GPIOD_OSC_IN 0U
  101. #define GPIOD_PIN0 0U
  102. #define GPIOD_OSC_OUT 1U
  103. #define GPIOD_PIN1 1U
  104. #define GPIOD_PIN2 2U
  105. #define GPIOD_PIN3 3U
  106. #define GPIOD_PIN4 4U
  107. #define GPIOD_PIN5 5U
  108. #define GPIOD_PIN6 6U
  109. #define GPIOD_PIN7 7U
  110. #define GPIOD_PIN8 8U
  111. #define GPIOD_PIN9 9U
  112. #define GPIOD_PIN10 10U
  113. #define GPIOD_PIN11 11U
  114. #define GPIOD_PIN12 12U
  115. #define GPIOD_PIN13 13U
  116. #define GPIOD_PIN14 14U
  117. #define GPIOD_PIN15 15U
  118. #define GPIOE_PIN0 0U
  119. #define GPIOE_PIN1 1U
  120. #define GPIOE_PIN2 2U
  121. #define GPIOE_PIN3 3U
  122. #define GPIOE_PIN4 4U
  123. #define GPIOE_PIN5 5U
  124. #define GPIOE_PIN6 6U
  125. #define GPIOE_PIN7 7U
  126. #define GPIOE_PIN8 8U
  127. #define GPIOE_PIN9 9U
  128. #define GPIOE_PIN10 10U
  129. #define GPIOE_PIN11 11U
  130. #define GPIOE_PIN12 12U
  131. #define GPIOE_PIN13 13U
  132. #define GPIOE_PIN14 14U
  133. #define GPIOE_PIN15 15U
  134. #define GPIOF_PIN0 0U
  135. #define GPIOF_PIN1 1U
  136. #define GPIOF_PIN2 2U
  137. #define GPIOF_PIN3 3U
  138. #define GPIOF_PIN4 4U
  139. #define GPIOF_PIN5 5U
  140. #define GPIOF_PIN6 6U
  141. #define GPIOF_PIN7 7U
  142. #define GPIOF_PIN8 8U
  143. #define GPIOF_PIN9 9U
  144. #define GPIOF_PIN10 10U
  145. #define GPIOF_PIN11 11U
  146. #define GPIOF_PIN12 12U
  147. #define GPIOF_PIN13 13U
  148. #define GPIOF_PIN14 14U
  149. #define GPIOF_PIN15 15U
  150. /*
  151. * I/O ports initial setup, this configuration is established soon after reset
  152. * in the initialization code.
  153. *
  154. * The digits have the following meaning:
  155. * 0 - Analog input.
  156. * 1 - Push Pull output 10MHz.
  157. * 2 - Push Pull output 2MHz.
  158. * 3 - Push Pull output 50MHz.
  159. * 4 - Digital input.
  160. * 5 - Open Drain output 10MHz.
  161. * 6 - Open Drain output 2MHz.
  162. * 7 - Open Drain output 50MHz.
  163. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  164. * 9 - Alternate Push Pull output 10MHz.
  165. * A - Alternate Push Pull output 2MHz.
  166. * B - Alternate Push Pull output 50MHz.
  167. * C - Reserved.
  168. * D - Alternate Open Drain output 10MHz.
  169. * E - Alternate Open Drain output 2MHz.
  170. * F - Alternate Open Drain output 50MHz.
  171. * Please refer to the STM32 Reference Manual for details.
  172. */
  173. /*
  174. * Port A setup.
  175. * Everything input with pull-up except:
  176. * PA2 - Alternate output (GPIOA_ARD_D1, GPIOA_USART2_TX).
  177. * PA3 - Normal input (GPIOA_ARD_D0, GPIOA_USART2_RX).
  178. * PA5 - Push Pull output (GPIOA_LED_GREEN).
  179. * PA13 - Pull-up input (GPIOA_SWDIO).
  180. * PA14 - Pull-down input (GPIOA_SWCLK).
  181. */
  182. #define VAL_GPIOACRL 0x88384B88 /* PA7...PA0 */
  183. #define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */
  184. #define VAL_GPIOAODR 0xFFFFBFDF
  185. /*
  186. * Port B setup.
  187. * Everything input with pull-up except:
  188. * PB3 - Pull-up input (GPIOA_SWO).
  189. */
  190. #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
  191. #define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
  192. #define VAL_GPIOBODR 0xFFFFFFFF
  193. /*
  194. * Port C setup.
  195. * Everything input with pull-up except:
  196. * PC13 - Normal input (GPIOC_BUTTON).
  197. */
  198. #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
  199. #define VAL_GPIOCCRH 0x88488888 /* PC15...PC8 */
  200. #define VAL_GPIOCODR 0xFFFFFFFF
  201. /*
  202. * Port D setup.
  203. * Everything input with pull-up except:
  204. * PD0 - Normal input (GPIOD_OSC_IN).
  205. * PD1 - Normal input (GPIOD_OSC_OUT).
  206. */
  207. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  208. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  209. #define VAL_GPIODODR 0xFFFFFFFF
  210. /*
  211. * Port E setup.
  212. * Everything input with pull-up except:
  213. */
  214. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  215. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  216. #define VAL_GPIOEODR 0xFFFFFFFF
  217. /*
  218. * USB bus activation macro, required by the USB driver.
  219. */
  220. #define usb_lld_connect_bus(usbp)
  221. /*
  222. * USB bus de-activation macro, required by the USB driver.
  223. */
  224. #define usb_lld_disconnect_bus(usbp)
  225. #if !defined(_FROM_ASM_)
  226. #ifdef __cplusplus
  227. extern "C" {
  228. #endif
  229. void boardInit(void);
  230. #ifdef __cplusplus
  231. }
  232. #endif
  233. #endif /* _FROM_ASM_ */
  234. #endif /* _BOARD_H_ */