board.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 "LeafLabs Maple Mini"
  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. * numbering is sorted by onboard/connectors, as from the schematics in
  36. * https://github.com/leaflabs/maplemini
  37. */
  38. /* on-board */
  39. #define GPIOB_LED 1
  40. #define GPIOB_USB_DISC 9
  41. #define GPIOD_OSC_IN 0
  42. #define GPIOD_OSC_OUT 1
  43. /* J1 connector */
  44. // pin 1: AV+
  45. // pin 2: AV-
  46. // pin 3: VBAT
  47. #define GPIOC_TAMPER_RTC 13 // pin 4
  48. #define GPIOC_OSC32_IN 14 // pin 5
  49. #define GPIOC_OSD32_OUT 15 // pin 6
  50. // pin 7: RESET
  51. #define GPIOA_USART2_CTS 0 // pin 8
  52. #define GPIOA_USART2_RTS 1 // pin 9
  53. #define GPIOA_USART2_TX 2 // pin 10
  54. #define GPIOA_USART2_RX 3 // pin 11
  55. #define GPIOA_SPI1_NSS 4 // pin 12
  56. #define GPIOA_SPI1_SCK 5 // pin 13
  57. #define GPIOA_SPI1_MISO 6 // pin 14
  58. #define GPIOA_SPI1_MOSI 7 // pin 15
  59. #define GPIOB_ADC12_IN8 0 // pin 16
  60. #define GPIOB_BOOT1 2 // pin 17
  61. #define GPIOB_I2C2_SCL 10 // pin 18
  62. #define GPIOB_I2C2_SDA 11 // pin 19
  63. // pin 20: VIN
  64. /* J2 connector */
  65. #define GPIOB_SPI2_NSS 12 // pin 1
  66. #define GPIOB_SPI2_SCK 13 // pin 2
  67. #define GPIOB_SPI2_MISO 14 // pin 3
  68. #define GPIOB_SPI2_MOSI 15 // pin 4
  69. #define GPIOA_USART1_CK 8 // pin 5
  70. #define GPIOA_USART1_TX 9 // pin 6
  71. #define GPIOA_USART1_RX 10 // pin 7
  72. #define GPIOA_USBDM 11 // pin 8
  73. #define GPIOA_USBDP 12 // pin 9
  74. #define GPIOA_JTMS 13 // pin 10
  75. #define GPIOA_JTCK 14 // pin 11
  76. #define GPIOA_JTDI 15 // pin 12
  77. #define GPIOB_JTDO 3 // pin 13
  78. #define GPIOB_JTRST 4 // pin 14
  79. #define GPIOB_I2C1_SMBA 5 // pin 15
  80. #define GPIOB_I2C1_SCL 6 // pin 16
  81. #define GPIOB_I2C1_SDA 7 // pin 17
  82. #define GPIOB_BOOT0_BUTTON 8 // pin 18
  83. // pin 19: GND
  84. // pin 20: VCC
  85. /*
  86. * I/O ports initial setup, this configuration is established soon after reset
  87. * in the initialization code.
  88. *
  89. * The digits have the following meaning:
  90. * 0 - Analog input.
  91. * 1 - Push Pull output 10MHz.
  92. * 2 - Push Pull output 2MHz.
  93. * 3 - Push Pull output 50MHz.
  94. * 4 - Digital input.
  95. * 5 - Open Drain output 10MHz.
  96. * 6 - Open Drain output 2MHz.
  97. * 7 - Open Drain output 50MHz.
  98. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  99. * 9 - Alternate Push Pull output 10MHz.
  100. * A - Alternate Push Pull output 2MHz.
  101. * B - Alternate Push Pull output 50MHz.
  102. * C - Reserved.
  103. * D - Alternate Open Drain output 10MHz.
  104. * E - Alternate Open Drain output 2MHz.
  105. * F - Alternate Open Drain output 50MHz.
  106. * Please refer to the STM32 Reference Manual for details.
  107. */
  108. /*
  109. * Port A setup.
  110. * Everything input with pull-up except:
  111. * PA2 - Alternate output (USART2 TX).
  112. * PA3 - Normal input (USART2 RX).
  113. * PA9 - Alternate output (USART1 TX).
  114. * PA10 - Normal input (USART1 RX).
  115. */
  116. #define VAL_GPIOACRL 0x88884B88 /* PA7...PA0 */
  117. #define VAL_GPIOACRH 0x888884B8 /* PA15...PA8 */
  118. #define VAL_GPIOAODR 0xFFFFFFFF
  119. /*
  120. * Port B setup.
  121. * Everything input with pull-up except:
  122. * PB1 - Push Pull output (LED).
  123. * PB9 - Push Pull output (USB switch).
  124. */
  125. #define VAL_GPIOBCRL 0x88888838 /* PB7...PB0 */
  126. #define VAL_GPIOBCRH 0x88888838 /* PB15...PB8 */
  127. #define VAL_GPIOBODR 0xFFFFFFFF
  128. /*
  129. * Port C setup.
  130. * Everything input with pull-up except:
  131. */
  132. #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
  133. #define VAL_GPIOCCRH 0x88888888 /* PC15...PC8 */
  134. #define VAL_GPIOCODR 0xFFFFFFFF
  135. /*
  136. * Port D setup.
  137. * Everything input with pull-up except:
  138. * PD0 - Normal input (XTAL).
  139. * PD1 - Normal input (XTAL).
  140. */
  141. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  142. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  143. #define VAL_GPIODODR 0xFFFFFFFF
  144. /*
  145. * Port E setup.
  146. * Everything input with pull-up except:
  147. */
  148. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  149. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  150. #define VAL_GPIOEODR 0xFFFFFFFF
  151. /*
  152. * USB bus activation macro, required by the USB driver.
  153. */
  154. #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
  155. /*
  156. * USB bus de-activation macro, required by the USB driver.
  157. */
  158. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
  159. #if !defined(_FROM_ASM_)
  160. #ifdef __cplusplus
  161. extern "C" {
  162. #endif
  163. void boardInit(void);
  164. #ifdef __cplusplus
  165. }
  166. #endif
  167. #endif /* _FROM_ASM_ */
  168. #endif /* _BOARD_H_ */