My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.cpp 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /******************************************************************************
  2. * The MIT License
  3. *
  4. * Copyright (c) 2011 LeafLabs, LLC.
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use, copy,
  10. * modify, merge, publish, distribute, sublicense, and/or sell copies
  11. * of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  21. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  22. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. *****************************************************************************/
  26. /**
  27. * @file wirish/boards/maple/board.cpp
  28. * @author Marti Bolivar <mbolivar@leaflabs.com>
  29. * @brief Maple board file.
  30. */
  31. #include <board/board.h> // For this board's header file
  32. /* Roger Clark. Added next to includes for changes to Serial */
  33. #include <libmaple/usart.h>
  34. #include <HardwareSerial.h>
  35. #include <wirish_types.h> // For stm32_pin_info and its contents
  36. // (these go into PIN_MAP).
  37. #include "boards_private.h" // For PMAP_ROW(), which makes
  38. // PIN_MAP easier to read.
  39. // boardInit(): nothing special to do for Maple.
  40. //
  41. // When defining your own board.cpp, you can put extra code in this
  42. // function if you have anything you want done on reset, before main()
  43. // or setup() are called.
  44. //
  45. // If there's nothing special you need done, feel free to leave this
  46. // function out, as we do here.
  47. /*
  48. void boardInit(void) {
  49. }
  50. */
  51. // Pin map: this lets the basic I/O functions (digitalWrite(),
  52. // analogRead(), pwmWrite()) translate from pin numbers to STM32
  53. // peripherals.
  54. //
  55. // PMAP_ROW() lets us specify a row (really a struct stm32_pin_info)
  56. // in the pin map. Its arguments are:
  57. //
  58. // - GPIO device for the pin (&gpioa, etc.)
  59. // - GPIO bit for the pin (0 through 15)
  60. // - Timer device, or NULL if none
  61. // - Timer channel (1 to 4, for PWM), or 0 if none
  62. // - ADC device, or NULL if none
  63. // - ADC channel, or ADCx if none
  64. extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
  65. /*
  66. gpio_dev *gpio_device; GPIO device
  67. timer_dev *timer_device; Pin's timer device, if any.
  68. const adc_dev *adc_device; ADC device, if any.
  69. uint8 gpio_bit; Pin's GPIO port bit.
  70. uint8 timer_channel; Timer channel, or 0 if none.
  71. uint8 adc_channel; Pin ADC channel, or ADCx if none.
  72. */
  73. {&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */
  74. {&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */
  75. {&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */
  76. {&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */
  77. {&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */
  78. {&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */
  79. {&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */
  80. {&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */
  81. {&gpioa, &timer1, NULL, 8, 1, ADCx}, /* PA8 */
  82. {&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */
  83. {&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */
  84. {&gpioa, NULL, NULL, 11, 0, ADCx}, /* PA11 */
  85. {&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */
  86. {&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */
  87. {&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */
  88. {&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */
  89. {&gpiob, &timer3, &adc1, 0, 3, 8}, /* PB0 */
  90. {&gpiob, &timer3, &adc1, 1, 4, 9}, /* PB1 */
  91. {&gpiob, &timer3, &adc1, 2, 4, 9}, /* PB2 */
  92. {&gpiob, NULL, NULL, 3, 0, ADCx}, /* PB3 */
  93. {&gpiob, NULL, NULL, 4, 0, ADCx}, /* PB4 */
  94. {&gpiob, NULL, NULL, 5, 0, ADCx}, /* PB5 */
  95. {&gpiob, &timer4, NULL, 6, 1, ADCx}, /* PB6 */
  96. {&gpiob, &timer4, NULL, 7, 2, ADCx}, /* PB7 */
  97. {&gpiob, &timer4, NULL, 8, 3, ADCx}, /* PB8 */
  98. {&gpiob, &timer4, NULL, 9, 4, ADCx}, /* PB9 */
  99. {&gpiob, NULL, NULL, 10, 0, ADCx}, /* PB10 */
  100. {&gpiob, NULL, NULL, 11, 0, ADCx}, /* PB11 */
  101. {&gpiob, NULL, NULL, 12, 0, ADCx}, /* PB12 */
  102. {&gpiob, NULL, NULL, 13, 0, ADCx}, /* PB13 */
  103. {&gpiob, NULL, NULL, 14, 0, ADCx}, /* PB14 */
  104. {&gpiob, NULL, NULL, 15, 0, ADCx}, /* PB15 */
  105. {&gpioc, NULL, &adc1, 0, 0, 10}, /* PC0 */
  106. {&gpioc, NULL, &adc1, 1, 0, 11}, /* PC1 */
  107. {&gpioc, NULL, &adc1, 2, 0, 12}, /* PC2 */
  108. {&gpioc, NULL, &adc1, 3, 0, 13}, /* PC3 */
  109. {&gpioc, NULL, &adc1, 4, 0, 14}, /* PC4 */
  110. {&gpioc, NULL, &adc1, 5, 0, 15}, /* PC5 */
  111. {&gpioc, &timer8, NULL, 6, 1, ADCx}, /* PC6 */
  112. {&gpioc, &timer8, NULL, 7, 2, ADCx}, /* PC7 */
  113. {&gpioc, &timer8, NULL, 8, 3, ADCx}, /* PC8 */
  114. {&gpioc, &timer8, NULL, 9, 4, ADCx}, /* PC9 */
  115. {&gpioc, NULL, NULL, 10, 0, ADCx}, /* PC10 UART4_TX/SDIO_D2 */
  116. {&gpioc, NULL, NULL, 11, 0, ADCx}, /* PC11 UART4_RX/SDIO_D3 */
  117. {&gpioc, NULL, NULL, 12, 0, ADCx}, /* PC12 UART5_TX/SDIO_CK */
  118. {&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 TAMPER-RTC */
  119. {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 OSC32_IN */
  120. {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 OSC32_OUT */
  121. {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */
  122. {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */
  123. {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */
  124. {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */
  125. {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */
  126. {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */
  127. {&gpiod, NULL, NULL, 6, 0, ADCx} , /* PD6 FSMC_NWAIT */
  128. {&gpiod, NULL, NULL, 7, 0, ADCx} , /* PD7 FSMC_NE1/FSMC_NCE2 */
  129. {&gpiod, NULL, NULL, 8, 0, ADCx} , /* PD8 FSMC_D13 */
  130. {&gpiod, NULL, NULL, 9, 0, ADCx} , /* PD9 FSMC_D14 */
  131. {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */
  132. {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */
  133. {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */
  134. {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */
  135. {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */
  136. {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */
  137. {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */
  138. {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */
  139. {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */
  140. {&gpioe, NULL, NULL, 3, 0, ADCx} , /* PE3 */
  141. {&gpioe, NULL, NULL, 4, 0, ADCx} , /* PE4 */
  142. {&gpioe, NULL, NULL, 5, 0, ADCx} , /* PE5 */
  143. {&gpioe, NULL, NULL, 6, 0, ADCx} , /* PE6 */
  144. {&gpioe, NULL, NULL, 7, 0, ADCx} , /* PE7 */
  145. {&gpioe, NULL, NULL, 8, 0, ADCx} , /* PE8 */
  146. {&gpioe, NULL, NULL, 9, 0, ADCx} , /* PE9 */
  147. {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */
  148. {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */
  149. {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */
  150. {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */
  151. {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */
  152. {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */
  153. {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */
  154. {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */
  155. {&gpiof, NULL, NULL, 2, 0, ADCx} , /* PF2 */
  156. {&gpiof, NULL, NULL, 3, 0, ADCx} , /* PF3 */
  157. {&gpiof, NULL, NULL, 4, 0, ADCx} , /* PF4 */
  158. {&gpiof, NULL, NULL, 5, 0, ADCx} , /* PF5 */
  159. {&gpiof, NULL, NULL, 6, 0, ADCx} , /* PF6 */
  160. {&gpiof, NULL, NULL, 7, 0, ADCx} , /* PF7 */
  161. {&gpiof, NULL, NULL, 8, 0, ADCx} , /* PF8 */
  162. {&gpiof, NULL, NULL, 9, 0, ADCx} , /* PF9 */
  163. {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */
  164. {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */
  165. {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */
  166. {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */
  167. {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */
  168. {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */
  169. {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */
  170. {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */
  171. {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */
  172. {&gpiog, NULL, NULL, 3, 0, ADCx} , /* PG3 */
  173. {&gpiog, NULL, NULL, 4, 0, ADCx} , /* PG4 */
  174. {&gpiog, NULL, NULL, 5, 0, ADCx} , /* PG5 */
  175. {&gpiog, NULL, NULL, 6, 0, ADCx} , /* PG6 */
  176. {&gpiog, NULL, NULL, 7, 0, ADCx} , /* PG7 */
  177. {&gpiog, NULL, NULL, 8, 0, ADCx} , /* PG8 */
  178. {&gpiog, NULL, NULL, 9, 0, ADCx} , /* PG9 */
  179. {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */
  180. {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */
  181. {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */
  182. {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */
  183. {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */
  184. {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */
  185. };
  186. /* Basically everything that is defined as having a timer us PWM */
  187. extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
  188. PA0,PA1,PA2,PA3,PA6,PA7,PA8,PA9,PA10,PB0,PB1,PB6,PB7,PB8,PB9,PC6,PC7,PC8,PC9
  189. };
  190. /* Basically everything that is defined having ADC */
  191. extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
  192. PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PB0,PB1,PC0,PC1,PC2,PC3,PC4,PC5
  193. };
  194. /* not sure what this us used for */
  195. extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
  196. BOARD_JTMS_SWDIO_PIN,
  197. BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
  198. };
  199. #ifdef SERIAL_USB
  200. DEFINE_HWSERIAL(Serial1, 1);
  201. DEFINE_HWSERIAL(Serial2, 2);
  202. DEFINE_HWSERIAL(Serial3, 3);
  203. DEFINE_HWSERIAL_UART(Serial4, 4);
  204. DEFINE_HWSERIAL_UART(Serial5, 5);
  205. #else
  206. DEFINE_HWSERIAL(Serial, 1);
  207. DEFINE_HWSERIAL(Serial1, 2);
  208. DEFINE_HWSERIAL(Serial2, 3);
  209. DEFINE_HWSERIAL_UART(Serial3, 4);
  210. DEFINE_HWSERIAL_UART(Serial4, 5);
  211. #endif