board.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 Olimex STM32-LCD proto board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_OLIMEX_STM32_LCD
  22. #define BOARD_NAME "Olimex STM32-LCD"
  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 STM32F10X_HD
  32. /*
  33. * IO pins assignments.
  34. */
  35. #define GPIOA_SPI1NSS 4
  36. #define GPIOB_SPI2NSS 12
  37. #define GPIOA_USB_P 0
  38. #define GPIOD_USB_DISC 2
  39. #define GPIOE_TFT_RST 2
  40. #define GPIOD_TFT_LIGHT 13
  41. #define GPIOC_TFT_YD 0
  42. #define GPIOC_TFT_YU 1
  43. #define GPIOC_TFT_XL 2
  44. #define GPIOC_TFT_XR 3
  45. /*
  46. * I/O ports initial setup, this configuration is established soon after reset
  47. * in the initialization code.
  48. *
  49. * The digits have the following meaning:
  50. * 0 - Analog input.
  51. * 1 - Push Pull output 10MHz.
  52. * 2 - Push Pull output 2MHz.
  53. * 3 - Push Pull output 50MHz.
  54. * 4 - Digital input.
  55. * 5 - Open Drain output 10MHz.
  56. * 6 - Open Drain output 2MHz.
  57. * 7 - Open Drain output 50MHz.
  58. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  59. * 9 - Alternate Push Pull output 10MHz.
  60. * A - Alternate Push Pull output 2MHz.
  61. * B - Alternate Push Pull output 50MHz.
  62. * C - Reserved.
  63. * D - Alternate Open Drain output 10MHz.
  64. * E - Alternate Open Drain output 2MHz.
  65. * F - Alternate Open Drain output 50MHz.
  66. * Please refer to the STM32 Reference Manual for details.
  67. */
  68. /*
  69. * Port A setup.
  70. * Everything input with pull-up except:
  71. * PA0 - Normal input (USB P).
  72. * PA2 - Alternate output (USART2 TX).
  73. * PA3 - Normal input (USART2 RX).
  74. * PA11 - Normal input (USB DM).
  75. * PA12 - Normal input (USB DP).
  76. */
  77. #define VAL_GPIOACRL 0x88884B84 /* PA7...PA0 */
  78. #define VAL_GPIOACRH 0x88844888 /* PA15...PA8 */
  79. #define VAL_GPIOAODR 0xFFFFFFFF
  80. /*
  81. * Port B setup.
  82. * Everything input with pull-up except:
  83. */
  84. #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
  85. #define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
  86. #define VAL_GPIOBODR 0xFFFFFFFF
  87. /*
  88. * Port C setup.
  89. * Everything input with pull-up except:
  90. * PC0 - Analog Input (TP_YD).
  91. * PC1 - Analog Input (TP_YU).
  92. * PC2 - Analog Input (TP_XL).
  93. * PC3 - Analog Input (TP_XR).
  94. * PC8 - Alternate PP 50M (SD_D0).
  95. * PC9 - Alternate PP 50M (SD_D1).
  96. * PC10 - Alternate PP 50M (SD_D2).
  97. * PC11 - Alternate PP 50M (SD_D3).
  98. * PC12 - Alternate PP 50M (SD_CLK).
  99. * PC14 - Normal input (XTAL).
  100. * PC15 - Normal input (XTAL).
  101. */
  102. #define VAL_GPIOCCRL 0x88880000 /* PC7...PC0 */
  103. #define VAL_GPIOCCRH 0x448BBBBB /* PC15...PC8 */
  104. #define VAL_GPIOCODR 0xFFFFFFFF
  105. /*
  106. * Port D setup.
  107. * Everything input with pull-up except:
  108. * PD2 - Alternate PP 50M (SD_CMD)
  109. * PD0 - Alternate PP 50M (FSMC_D2)
  110. * PD1 - Alternate PP 50M (FSMC_D3)
  111. * PD4 - Alternate PP 50M (TFT_RD)
  112. * PD5 - Alternate PP 50M (TFT_WR)
  113. * PD7 - Alternate PP 50M (TFT_CS)
  114. * PD8 - Alternate PP 50M (FSMC_D13)
  115. * PD9 - Alternate PP 50M (FSMC_D14)
  116. * PD10 - Alternate PP 50M (FSMC_D15)
  117. * PD14 - Alternate PP 50M (FSMC_D0)
  118. * PD15 - Alternate PP 50M (FSMC_D1)
  119. */
  120. #define VAL_GPIODCRL 0xBBBB8BBB /* PD7...PD0 */
  121. #define VAL_GPIODCRH 0xBB388BBB /* PD15...PD8 */
  122. #define VAL_GPIODODR 0xFFFFFFFF
  123. /*
  124. * Port E setup.
  125. * Everything input with pull-up except:
  126. * PE2 - Digital Output (TFT_RST)
  127. * PE3 - Alternate PP 50M (TFT_RS)
  128. * PE7 - Alternate PP 50M (FSMC_D4)
  129. * PE8 - Alternate PP 50M (FSMC_D5)
  130. * PE9 - Alternate PP 50M (FSMC_D6)
  131. * PE10 - Alternate PP 50M (FSMC_D7)
  132. * PE11 - Alternate PP 50M (FSMC_D8)
  133. * PE12 - Alternate PP 50M (FSMC_D9)
  134. * PE13 - Alternate PP 50M (FSMC_D10)
  135. * PE14 - Alternate PP 50M (FSMC_D11)
  136. * PE15 - Alternate PP 50M (FSMC_D12)
  137. */
  138. #define VAL_GPIOECRL 0xB888B388 /* PE7...PE0 */
  139. #define VAL_GPIOECRH 0xBBBBBBBB /* PE15...PE8 */
  140. #define VAL_GPIOEODR 0xFFFFFFFF
  141. /*
  142. * Port F setup.
  143. * Everything input with pull-up expect:
  144. */
  145. #define VAL_GPIOFCRL 0x88888888 /* PF7...PF0 */
  146. #define VAL_GPIOFCRH 0x88888888 /* PF15...PF8 */
  147. #define VAL_GPIOFODR 0xFFFFFFFF
  148. /*
  149. * Port G setup.
  150. * Everything input with pull-up expect:
  151. */
  152. #define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */
  153. #define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */
  154. #define VAL_GPIOGODR 0xFFFFFFFF
  155. /*
  156. * USB bus activation macro, required by the USB driver.
  157. */
  158. #define usb_lld_connect_bus(usbp) palClearPad(GPIOD, GPIOD_USB_DISC)
  159. /*
  160. * USB bus de-activation macro, required by the USB driver.
  161. */
  162. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOD, GPIOD_USB_DISC)
  163. #if !defined(_FROM_ASM_)
  164. #ifdef __cplusplus
  165. extern "C" {
  166. #endif
  167. void boardInit(void);
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif /* _FROM_ASM_ */
  172. #endif /* _BOARD_H_ */