board.h 4.9 KB

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