Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

board.h 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. ChibiOS - Copyright (C) 2006..2015 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 a Generic STM32F103 board.
  17. */
  18. /*
  19. * Board identifier.
  20. */
  21. #define BOARD_GENERIC_STM32_F103
  22. #define BOARD_NAME "Generic STM32F103x board"
  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. #define GPIOD_OSC_IN 0
  38. #define GPIOD_OSC_OUT 1
  39. /* In case your board has a "USB enable" hardware
  40. controlled by a pin, define it here. (It could be just
  41. a 1.5k resistor connected to D+ line.)
  42. */
  43. /*
  44. #define GPIOB_USB_DISC 10
  45. */
  46. /*
  47. * I/O ports initial setup, this configuration is established soon after reset
  48. * in the initialization code.
  49. *
  50. * The digits have the following meaning:
  51. * 0 - Analog input.
  52. * 1 - Push Pull output 10MHz.
  53. * 2 - Push Pull output 2MHz.
  54. * 3 - Push Pull output 50MHz.
  55. * 4 - Digital input.
  56. * 5 - Open Drain output 10MHz.
  57. * 6 - Open Drain output 2MHz.
  58. * 7 - Open Drain output 50MHz.
  59. * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
  60. * 9 - Alternate Push Pull output 10MHz.
  61. * A - Alternate Push Pull output 2MHz.
  62. * B - Alternate Push Pull output 50MHz.
  63. * C - Reserved.
  64. * D - Alternate Open Drain output 10MHz.
  65. * E - Alternate Open Drain output 2MHz.
  66. * F - Alternate Open Drain output 50MHz.
  67. * Please refer to the STM32 Reference Manual for details.
  68. */
  69. /*
  70. * Port A setup.
  71. * Everything input with pull-up except:
  72. * PA2 - Alternate output (USART2 TX).
  73. * PA3 - Normal input (USART2 RX).
  74. * PA9 - Alternate output (USART1 TX).
  75. * PA10 - Normal input (USART1 RX).
  76. */
  77. #define VAL_GPIOACRL 0x88884B88 /* PA7...PA0 */
  78. #define VAL_GPIOACRH 0x888884B8 /* PA15...PA8 */
  79. #define VAL_GPIOAODR 0xFFFFFFFF
  80. /*
  81. * Port B setup.
  82. * Everything input with pull-up except:
  83. * PB10 - Push Pull output (USB switch).
  84. */
  85. #define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
  86. #define VAL_GPIOBCRH 0x88888388 /* PB15...PB8 */
  87. #define VAL_GPIOBODR 0xFFFFFFFF
  88. /*
  89. * Port C setup.
  90. * Everything input with pull-up except:
  91. * PC13 - Push Pull output (LED).
  92. */
  93. #define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
  94. #define VAL_GPIOCCRH 0x88388888 /* PC15...PC8 */
  95. #define VAL_GPIOCODR 0xFFFFFFFF
  96. /*
  97. * Port D setup.
  98. * Everything input with pull-up except:
  99. * PD0 - Normal input (XTAL).
  100. * PD1 - Normal input (XTAL).
  101. */
  102. #define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
  103. #define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
  104. #define VAL_GPIODODR 0xFFFFFFFF
  105. /*
  106. * Port E setup.
  107. * Everything input with pull-up except:
  108. */
  109. #define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
  110. #define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
  111. #define VAL_GPIOEODR 0xFFFFFFFF
  112. /*
  113. * USB bus activation macro, required by the USB driver.
  114. */
  115. /* The point is that most of the generic STM32F103* boards
  116. have a 1.5k resistor connected on one end to the D+ line
  117. and on the other end to some pin. Or even a slightly more
  118. complicated "USB enable" circuit, controlled by a pin.
  119. That should go here.
  120. However on some boards (e.g. one that I have), there's no
  121. such hardware. In which case it's better to not do anything.
  122. */
  123. /*
  124. #define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
  125. */
  126. #define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT);
  127. /*
  128. * USB bus de-activation macro, required by the USB driver.
  129. */
  130. /*
  131. #define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
  132. */
  133. #define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12);
  134. #if !defined(_FROM_ASM_)
  135. #ifdef __cplusplus
  136. extern "C" {
  137. #endif
  138. void boardInit(void);
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif /* _FROM_ASM_ */
  143. #endif /* _BOARD_H_ */