board.h 5.9 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 LeafLabs Maple Mini.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_MAPLEMINI_STM32_F103
  22. #define BOARD_NAME "BluePill"
  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 STM32F103xB
  32. /*
  33. * IO pins assignments
  34. */
  35. /* on-board */
  36. #define GPIOC_LED 13
  37. /* LCD */
  38. #define LINE_LED PAL_LINE(GPIOC, 13U)
  39. #define LINE_LCD_CS PAL_LINE(GPIOA, 4U)
  40. #define LINE_LCD_DC PAL_LINE(GPIOA, 6U)
  41. #define LCD_DC_CMD palClearLine(LINE_LCD_DC)
  42. #define LCD_DC_DATA palSetLine(LINE_LCD_DC)
  43. #define LCD_CS_RES palClearLine(LINE_LCD_CS)
  44. #define LCD_CS_SET palSetLine(LINE_LCD_CS)
  45. /* J1 connector */
  46. // pin 1: VBAT - Coin Cell 3V
  47. #define GPIOC_TAMPER_RTC 13 // pin 2
  48. #define GPIOC_OSC32_IN 14 // pin 3
  49. #define GPIOC_OSD32_OUT 15 // pin 4
  50. #define GPIOA_USART2_CTS 0 // pin 5
  51. #define GPIOA_USART2_RTS 1 // pin 6
  52. #define GPIOA_USART2_TX 2 // pin 7
  53. #define GPIOA_USART2_RX 3 // pin 8
  54. #define GPIOA_SPI1_NSS 4 // pin 9 LCD_CS
  55. #define GPIOA_SPI1_SCK 5 // pin 10 LCD_SCL
  56. #define GPIOA_SPI1_MISO 6 // pin 11 LCD_DC
  57. #define GPIOA_SPI1_MOSI 7 // pin 12 LCD_SDA
  58. #define GPIOB_ADC12_IN8 0 // pin 13
  59. #define GPIOB_ADC12_IN9 1 // pin 14
  60. #define GPIOB_I2C2_SCL 10 // pin 15
  61. #define GPIOB_I2C2_SDA 11 // pin 16
  62. // pin 17: RESET
  63. // pin 18: 3V3
  64. // pin 19: GND
  65. // pin 20: GND
  66. /* J2 connector */
  67. // pin 1: 3V3
  68. // pin 2: GND
  69. // pin 3: 5V
  70. #define GPIOB_TIM4_CH4 9 // pin 4
  71. #define GPIOB_TIM4_CH3 8 // pin 5
  72. #define GPIOB_I2C1_SDA 7 // pin 6
  73. #define GPIOB_I2C1_SCL 6 // pin 7
  74. #define GPIOB_I2C1_SMBA 5 // pin 8
  75. #define GPIOB_JTRST 4 // pin 9
  76. #define GPIOB_JTDO 3 // pin 10
  77. #define GPIOA_JTDI 15 // pin 11
  78. #define GPIOA_USBDP 12 // pin 12
  79. #define GPIOA_USBDM 11 // pin 13
  80. #define GPIOA_USART1_RX 10 // pin 14
  81. #define GPIOA_USART1_TX 9 // pin 15
  82. #define GPIOA_USART1_CK 8 // pin 16
  83. #define GPIOB_SPI2_MOSI 15 // pin 17
  84. #define GPIOB_SPI2_MISO 14 // pin 18
  85. #define GPIOB_SPI2_SCK 13 // pin 19
  86. #define GPIOB_SPI2_NSS 12 // pin 20
  87. /*
  88. * I/O ports initial setup, this configuration is established soon after reset
  89. * in the initialization code.
  90. *
  91. * The digits have the following meaning:
  92. * 0 - Analog input.
  93. * 1 - Push Pull output 10MHz.
  94. * 2 - Push Pull output 2MHz.
  95. * 3 - Push Pull output 50MHz.
  96. * 4 - Digital input.
  97. * 5 - Open Drain output 10MHz.
  98. * 6 - Open Drain output 2MHz.
  99. * 7 - Open Drain output 50MHz.
  100. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  101. * 9 - Alternate Push Pull output 10MHz.
  102. * A - Alternate Push Pull output 2MHz.
  103. * B - Alternate Push Pull output 50MHz.
  104. * C - Reserved.
  105. * D - Alternate Open Drain output 10MHz.
  106. * E - Alternate Open Drain output 2MHz.
  107. * F - Alternate Open Drain output 50MHz.
  108. * Please refer to the STM32 Reference Manual for details.
  109. */
  110. /*
  111. * Port A setup.
  112. * Everything input with pull-up except:
  113. * PA4 - Push Pull output (LCD_CS).
  114. * PA5 - Alternate output (LCD_SCL - SPI1 SCK).
  115. * PA6 - Push Pull output (LCD_DC).
  116. * PA7 - Alternate output (LCD_DSA - SPI1 MOSI).
  117. */
  118. #define VAL_GPIOACRL 0xB3B38888 /* PA7...PA0 */
  119. #define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */
  120. #define VAL_GPIOAODR 0xFFFFFFFF
  121. /*
  122. * Port B setup.
  123. * Everything input with pull-up except:
  124. */
  125. #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
  126. #define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
  127. #define VAL_GPIOBODR 0xFFFFFFFF
  128. /*
  129. * Port C setup.
  130. * Everything input with pull-up except:
  131. * PC13 - Push Pull output (LED).
  132. */
  133. #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
  134. #define VAL_GPIOCCRH 0x88288888 /* PC15...PC8 */
  135. #define VAL_GPIOCODR 0xFFFFFFFF
  136. /*
  137. * Port D setup.
  138. * Everything input with pull-up except:
  139. * PD0 - Normal input (XTAL).
  140. * PD1 - Normal input (XTAL).
  141. */
  142. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  143. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  144. #define VAL_GPIODODR 0xFFFFFFFF
  145. /*
  146. * Port E setup.
  147. * Everything input with pull-up except:
  148. */
  149. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  150. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  151. #define VAL_GPIOEODR 0xFFFFFFFF
  152. /*
  153. * USB bus activation macro, required by the USB driver.
  154. */
  155. #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
  156. /*
  157. * USB bus de-activation macro, required by the USB driver.
  158. */
  159. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
  160. #if !defined(_FROM_ASM_)
  161. #ifdef __cplusplus
  162. extern "C" {
  163. #endif
  164. void boardInit(void);
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif /* _FROM_ASM_ */
  169. #endif /* _BOARD_H_ */