board.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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_INEMO_M1_DISCOVERY
  22. #define BOARD_NAME "STMicroelectronics INEMO-M1 Discovery"
  23. /*
  24. * Board frequencies.
  25. */
  26. #define STM32_LSECLK 0
  27. #define STM32_HSECLK 8000000
  28. /*
  29. * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
  30. */
  31. #define STM32F103xE
  32. /*
  33. * IO pins assignments.
  34. */
  35. #define GPIOA_PRESS_INT 0
  36. #define GPIOA_LED_BLUE 1
  37. #define GPIOA_PA2 2
  38. #define GPIOA_PA3 3
  39. #define GPIOA_PA4 4
  40. #define GPIOA_PA5 5
  41. #define GPIOA_PA6 6
  42. #define GPIOA_PA7 7
  43. #define GPIOA_USB_EN 9
  44. #define GPIOA_BUTTON 10
  45. #define GPIOA_USB_DM 11
  46. #define GPIOA_USB_DP 12
  47. #define GPIOA_SWDIO 13
  48. #define GPIOA_SWCLK 14
  49. #define GPIOB_SWO 3
  50. #define GPIOB_I2C1_SCL 6
  51. #define GPIOB_I2C1_SDA 7
  52. #define GPIOB_PB8 8
  53. #define GPIOB_PB9 9
  54. #define GPIOB_I2C2_SCL 10
  55. #define GPIOB_I2C2_SDA 11
  56. #define GPIOB_SPI2_CS 12
  57. #define GPIOB_SPI2_SCK 13
  58. #define GPIOB_SPI2_MISO 14
  59. #define GPIOB_SPI2_MOSI 15
  60. #define GPIOC_GYRO_INT1 6
  61. #define GPIOC_LMS_DRDY 7
  62. #define GPIOC_LMS_INT1 8
  63. #define GPIOC_GYRO_DRDY 9
  64. #define GPIOD_LMS_INT2 2
  65. /*
  66. * I/O ports initial setup, this configuration is established soon after reset
  67. * in the initialization code.
  68. *
  69. * The digits have the following meaning:
  70. * 0 - Analog input.
  71. * 1 - Push Pull output 10MHz.
  72. * 2 - Push Pull output 2MHz.
  73. * 3 - Push Pull output 50MHz.
  74. * 4 - Digital input.
  75. * 5 - Open Drain output 10MHz.
  76. * 6 - Open Drain output 2MHz.
  77. * 7 - Open Drain output 50MHz.
  78. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  79. * 9 - Alternate Push Pull output 10MHz.
  80. * A - Alternate Push Pull output 2MHz.
  81. * B - Alternate Push Pull output 50MHz.
  82. * C - Reserved.
  83. * D - Alternate Open Drain output 10MHz.
  84. * E - Alternate Open Drain output 2MHz.
  85. * F - Alternate Open Drain output 50MHz.
  86. * Please refer to the STM32 Reference Manual for details.
  87. */
  88. /*
  89. * Port A setup.
  90. * Everything input with pull-up except:
  91. * PA0 - Push Pull output (GPIOA_PRESS_INT).
  92. * PA1 - Push Pull output (GPIOA_LED_BLUE).
  93. * PA9 - Push Pull output (GPIOA_USB_EN).
  94. * PA10 - Normal input (GPIOA_BUTTON).
  95. * PA11 - Normal input (GPIOA_USB_DM).
  96. * PA12 - Normal input (GPIOA_USB_DP).
  97. * PA13 - Pull-up input (GPIOA_SWDIO).
  98. * PA14 - Pull-down input (GPIOA_SWCLK).
  99. */
  100. #define VAL_GPIOACRL 0x88888838 /* PA7...PA0 */
  101. #define VAL_GPIOACRH 0x88844438 /* PA15...PA8 */
  102. #define VAL_GPIOAODR 0xFFFFBDFD
  103. /*
  104. * Port B setup.
  105. * Everything input with pull-up except:
  106. * PB3 - Pull-up input (GPIOB_SWO).
  107. * PB6,7 - Alternate open drain (I2C1).
  108. * PB10,11 - Alternate open drain (I2C2).
  109. * PB12 - Push Pull output (GPIOB_SPI2_CS).
  110. * PB13 - Alternate output (GPIOB_SPI2_SCK).
  111. * PB14 - Normal input (GPIOB_SPI2_MISO).
  112. * PB15 - Alternate output (GPIOB_SPI2_MOSI).
  113. */
  114. #define VAL_GPIOBCRL 0xEE888888 /* PB7...PB0 */
  115. #define VAL_GPIOBCRH 0xB4B3EE88 /* PB15...PB8 */
  116. #define VAL_GPIOBODR 0xFFFFFFFF
  117. /*
  118. * Port C setup.
  119. * Everything input with pull-up except:
  120. */
  121. #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
  122. #define VAL_GPIOCCRH 0x88888888 /* PC15...PC8 */
  123. #define VAL_GPIOCODR 0xFFFFFFFF
  124. /*
  125. * Port D setup.
  126. * Everything input with pull-up except:
  127. * PD0 - Normal input (XTAL).
  128. * PD1 - Normal input (XTAL).
  129. */
  130. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  131. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  132. #define VAL_GPIODODR 0xFFFFFFFF
  133. /*
  134. * Port E setup.
  135. * Everything input with pull-up except:
  136. */
  137. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  138. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  139. #define VAL_GPIOEODR 0xFFFFFFFF
  140. /*
  141. * Port F setup.
  142. * Everything input with pull-up except:
  143. */
  144. #define VAL_GPIOFCRL 0x88888888 /* PF7...PF0 */
  145. #define VAL_GPIOFCRH 0x88888888 /* PF15...PF8 */
  146. #define VAL_GPIOFODR 0xFFFFFFFF
  147. /*
  148. * Port G setup.
  149. * Everything input with pull-up except:
  150. */
  151. #define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */
  152. #define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */
  153. #define VAL_GPIOGODR 0xFFFFFFFF
  154. /*
  155. * USB bus activation macro, required by the USB driver.
  156. */
  157. #define usb_lld_connect_bus(usbp) palSetPad(GPIOA, GPIOA_USB_EN)
  158. /*
  159. * USB bus de-activation macro, required by the USB driver.
  160. */
  161. #define usb_lld_disconnect_bus(usbp) palClearPad(GPIOA, GPIOA_USB_EN)
  162. #if !defined(_FROM_ASM_)
  163. #ifdef __cplusplus
  164. extern "C" {
  165. #endif
  166. void boardInit(void);
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170. #endif /* _FROM_ASM_ */
  171. #endif /* _BOARD_H_ */