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 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. void boardInit(void) {
  48. // afio_remap(AFIO_REMAP_I2C1);
  49. }
  50. // Pin map: this lets the basic I/O functions (digitalWrite(),
  51. // analogRead(), pwmWrite()) translate from pin numbers to STM32
  52. // peripherals.
  53. //
  54. // PMAP_ROW() lets us specify a row (really a struct stm32_pin_info)
  55. // in the pin map. Its arguments are:
  56. //
  57. // - GPIO device for the pin (&gpioa, etc.)
  58. // - GPIO bit for the pin (0 through 15)
  59. // - Timer device, or NULL if none
  60. // - Timer channel (1 to 4, for PWM), or 0 if none
  61. // - ADC device, or NULL if none
  62. // - ADC channel, or ADCx if none
  63. extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
  64. /*
  65. gpio_dev *gpio_device; GPIO device
  66. timer_dev *timer_device; Pin's timer device, if any.
  67. const adc_dev *adc_device; ADC device, if any.
  68. uint8 gpio_bit; Pin's GPIO port bit.
  69. uint8 timer_channel; Timer channel, or 0 if none.
  70. uint8 adc_channel; Pin ADC channel, or ADCx if none.
  71. */
  72. {&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */
  73. {&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */
  74. {&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */
  75. {&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */
  76. {&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */
  77. {&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */
  78. {&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */
  79. {&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */
  80. {&gpioa, &timer1, NULL, 8, 1, ADCx}, /* PA8 */
  81. {&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */
  82. {&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */
  83. {&gpioa, NULL, NULL, 11, 0, ADCx}, /* PA11 */
  84. {&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */
  85. {&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */
  86. {&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */
  87. {&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */
  88. {&gpiob, &timer3, &adc1, 0, 3, 8}, /* PB0 */
  89. {&gpiob, &timer3, &adc1, 1, 4, 9}, /* PB1 */
  90. {&gpiob, NULL, NULL, 2, 0, ADCx}, /* PB2 */
  91. {&gpiob, NULL, NULL, 3, 0, ADCx}, /* PB3 */
  92. {&gpiob, NULL, NULL, 4, 0, ADCx}, /* PB4 */
  93. {&gpiob, NULL, NULL, 5, 0, ADCx}, /* PB5 */
  94. {&gpiob, &timer4, NULL, 6, 1, ADCx}, /* PB6 */
  95. {&gpiob, &timer4, NULL, 7, 2, ADCx}, /* PB7 */
  96. {&gpiob, &timer4, NULL, 8, 3, ADCx}, /* PB8 */
  97. {&gpiob, NULL, NULL, 9, 0, ADCx}, /* PB9 */
  98. {&gpiob, NULL, NULL, 10, 0, ADCx}, /* PB10 */
  99. {&gpiob, NULL, NULL, 11, 0, ADCx}, /* PB11 */
  100. {&gpiob, NULL, NULL, 12, 0, ADCx}, /* PB12 */
  101. {&gpiob, NULL, NULL, 13, 0, ADCx}, /* PB13 */
  102. {&gpiob, NULL, NULL, 14, 0, ADCx}, /* PB14 */
  103. {&gpiob, NULL, NULL, 15, 0, ADCx}, /* PB15 */
  104. {&gpioc, NULL, &adc1, 0, 0, 10}, /* PC0 */
  105. {&gpioc, NULL, &adc1, 1, 0, 11}, /* PC1 */
  106. {&gpioc, NULL, &adc1, 2, 0, 12}, /* PC2 */
  107. {&gpioc, NULL, &adc1, 3, 0, 13}, /* PC3 */
  108. {&gpioc, NULL, &adc1, 4, 0, 14}, /* PC4 */
  109. {&gpioc, NULL, &adc1, 5, 0, 15}, /* PC5 */
  110. {&gpioc, &timer8, NULL, 6, 1, ADCx}, /* PC6 */
  111. {&gpioc, &timer8, NULL, 7, 2, ADCx}, /* PC7 */
  112. {&gpioc, &timer8, NULL, 8, 3, ADCx}, /* PC8 */
  113. {&gpioc, &timer8, NULL, 9, 4, ADCx}, /* PC9 */
  114. {&gpioc, NULL, NULL, 10, 0, ADCx}, /* PC10 UART4_TX/SDIO_D2 */
  115. {&gpioc, NULL, NULL, 11, 0, ADCx}, /* PC11 UART4_RX/SDIO_D3 */
  116. {&gpioc, NULL, NULL, 12, 0, ADCx}, /* PC12 UART5_TX/SDIO_CK */
  117. {&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 TAMPER-RTC */
  118. {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 OSC32_IN */
  119. {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 OSC32_OUT */
  120. {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */
  121. {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */
  122. {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */
  123. };
  124. /* Basically everything that is defined as having a timer us PWM */
  125. extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
  126. PA0,PA1,PA2,PA3,PA6,PA7,PA8,PA9,PA10,PB0,PB1,PB6,PB7,PB8,PB9,PC6,PC7,PC8,PC9
  127. };
  128. /* Basically everything that is defined having ADC */
  129. extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
  130. PA0,PA1,PA2,PA3,PA4,PA5,PA6,PA7,PB0,PB1,PC0,PC1,PC2,PC3,PC4,PC5
  131. };
  132. /* not sure what this us used for */
  133. extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
  134. BOARD_JTMS_SWDIO_PIN,
  135. BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
  136. };
  137. DEFINE_HWSERIAL(Serial1, 1);
  138. DEFINE_HWSERIAL(Serial2, 2);
  139. DEFINE_HWSERIAL(Serial3, 3);
  140. DEFINE_HWSERIAL_UART(Serial4, 4);
  141. DEFINE_HWSERIAL_UART(Serial5, 5);