board.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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-103STK proto board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_OLIMEX_STM32_103STK
  22. #define BOARD_NAME "Olimex STM32-103STK"
  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. #define GPIOA_BUTTON_WAKEUP 0
  36. #define GPIOC_BUTTON_TAMPER 13
  37. #define GPIOC_JOY 5
  38. #define GPIOC_JOY_CENTER_BUT 6
  39. #define GPIOA_SPI1NSS 4
  40. #define GPIOB_SPI2NSS 12
  41. #define GPIOC_MMCWP 2
  42. #define GPIOC_MMCCP 1
  43. #define GPIOC_USB_P 4
  44. #define GPIOC_LCD_RES 7
  45. #define GPIOC_NRF_CE 8
  46. #define GPIOC_NRF_IRQ 9
  47. #define GPIOC_LCD_E 10
  48. #define GPIOC_USB_DISC 11
  49. #define GPIOC_LED 12
  50. #define GPIOB_ACCEL_IRQ 5
  51. /*
  52. * I/O ports initial setup, this configuration is established soon after reset
  53. * in the initialization code.
  54. *
  55. * The digits have the following meaning:
  56. * 0 - Analog input.
  57. * 1 - Push Pull output 10MHz.
  58. * 2 - Push Pull output 2MHz.
  59. * 3 - Push Pull output 50MHz.
  60. * 4 - Digital input.
  61. * 5 - Open Drain output 10MHz.
  62. * 6 - Open Drain output 2MHz.
  63. * 7 - Open Drain output 50MHz.
  64. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  65. * 9 - Alternate Push Pull output 10MHz.
  66. * A - Alternate Push Pull output 2MHz.
  67. * B - Alternate Push Pull output 50MHz.
  68. * C - Reserved.
  69. * D - Alternate Open Drain output 10MHz.
  70. * E - Alternate Open Drain output 2MHz.
  71. * F - Alternate Open Drain output 50MHz.
  72. * Please refer to the STM32 Reference Manual for details.
  73. */
  74. /*
  75. * Port A setup.
  76. * Everything input with pull-up except:
  77. * PA0 - Normal input (BUTTON).
  78. * PA2 - Alternate output (USART2 TX).
  79. * PA3 - Normal input (USART2 RX).
  80. */
  81. #define VAL_GPIOACRL 0x88884B84 /* PA7...PA0 */
  82. #define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */
  83. #define VAL_GPIOAODR 0xFFFFFFFF
  84. /*
  85. * Port B setup.
  86. * Everything input with pull-up except:
  87. * PB6,7 - Alternate open drain (I2C1).
  88. * PB10,11 - Alternate open drain (I2C2).
  89. * PB12 - Push Pull output (MMC SPI2 NSS).
  90. * PB13 - Alternate output (MMC SPI2 SCK).
  91. * PB14 - Normal input (MMC SPI2 MISO).
  92. * PB15 - Alternate output (MMC SPI2 MOSI).
  93. */
  94. #define VAL_GPIOBCRL 0xEE888888 /* PB7...PB0 */
  95. #define VAL_GPIOBCRH 0xB4B3EE88 /* PB15...PB8 */
  96. #define VAL_GPIOBODR 0xFFFFFFFF
  97. /*
  98. * Port C setup.
  99. * Everything input with pull-up except:
  100. * PC4 - Normal input because there is an external resistor.
  101. * PC5 - Analog input (joystick).
  102. * PC6 - Normal input because there is an external resistor.
  103. * PC7 - Normal input because there is an external resistor.
  104. * PC10 - Push Pull output (CAN CNTRL).
  105. * PC11 - Push Pull output (USB DISC).
  106. * PC12 - Open Drain output (LED).
  107. */
  108. #define VAL_GPIOCCRL 0x44048888 /* PC7...PC0 */
  109. #define VAL_GPIOCCRH 0x88863388 /* PC15...PC8 */
  110. #define VAL_GPIOCODR 0xFFFFFFFF
  111. /*
  112. * Port D setup.
  113. * Everything input with pull-up except:
  114. * PD0 - Normal input (XTAL).
  115. * PD1 - Normal input (XTAL).
  116. */
  117. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  118. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  119. #define VAL_GPIODODR 0xFFFFFFFF
  120. /*
  121. * Port E setup.
  122. * Everything input with pull-up except:
  123. */
  124. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  125. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  126. #define VAL_GPIOEODR 0xFFFFFFFF
  127. /*
  128. * USB bus activation macro, required by the USB driver.
  129. */
  130. #define usb_lld_connect_bus(usbp) palClearPad(GPIOC, GPIOC_USB_DISC)
  131. /*
  132. * USB bus de-activation macro, required by the USB driver.
  133. */
  134. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOC, GPIOC_USB_DISC)
  135. #if !defined(_FROM_ASM_)
  136. #ifdef __cplusplus
  137. extern "C" {
  138. #endif
  139. void boardInit(void);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* _FROM_ASM_ */
  144. #endif /* _BOARD_H_ */