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.

pinsDebug.h 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Support routines for Due
  24. */
  25. /**
  26. * Translation of routines & variables used by pinsDebug.h
  27. */
  28. #include "../shared/Marduino.h"
  29. /**
  30. * Due/Marlin quirks
  31. *
  32. * a) determining the state of a pin
  33. * The Due/Arduino status definitions for the g_pinStatus[pin] array are:
  34. * #define PIN_STATUS_DIGITAL_INPUT_PULLUP (0x01)
  35. * #define PIN_STATUS_DIGITAL_INPUT (0x02)
  36. * #define PIN_STATUS_DIGITAL_OUTPUT (0x03)
  37. * #define PIN_STATUS_ANALOG (0x04)
  38. * #define PIN_STATUS_PWM (0x05)
  39. * #define PIN_STATUS_TIMER (0x06)
  40. *
  41. * These are only valid if the following Due/Arduino provided functions are used:
  42. * analogRead
  43. * analogWrite
  44. * digitalWrite
  45. * pinMode
  46. *
  47. * The FASTIO routines do not touch the g_pinStatus[pin] array.
  48. *
  49. * The net result is that both the g_pinStatus[pin] array and the PIO_OSR register
  50. * needs to be looked at when determining if a pin is an input or an output.
  51. *
  52. * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs. FYI - they run at 1KHz
  53. *
  54. * c) NUM_DIGITAL_PINS does not include the analog pins
  55. *
  56. * d) Pins 0-78 are defined for Due but 78 has a comment of "unconnected!". 78 is
  57. * included just in case.
  58. */
  59. #define NUMBER_PINS_TOTAL PINS_COUNT
  60. #define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
  61. #define PRINT_PORT(p)
  62. #define NAME_FORMAT(p) PSTR("%-##p##s")
  63. #define PRINT_ARRAY_NAME(x) do {sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer);} while (0)
  64. #define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer);} while (0)
  65. #define GET_ARRAY_PIN(p) pin_array[p].pin
  66. #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
  67. #define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
  68. #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
  69. #define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1)))
  70. #define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \
  71. ((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM))
  72. #define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin
  73. bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
  74. volatile Pio* port = g_APinDescription[pin].pPort;
  75. uint32_t mask = g_APinDescription[pin].ulPin;
  76. uint8_t pin_status = g_pinStatus[pin] & 0xF;
  77. return ( (pin_status == 0 && (port->PIO_OSR & mask))
  78. || pin_status == PIN_STATUS_DIGITAL_OUTPUT
  79. || pwm_status(pin));
  80. }
  81. void pwm_details(int32_t pin) {
  82. if (pwm_status(pin)) {
  83. uint32_t chan = g_APinDescription[pin].ulPWMChannel;
  84. SERIAL_ECHOPAIR("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
  85. }
  86. }
  87. /**
  88. * DUE Board pin | PORT | Label
  89. * ----------------+--------+-------
  90. * 0 | PA8 | "RX0"
  91. * 1 | PA9 | "TX0"
  92. * 2 TIOA0 | PB25 |
  93. * 3 TIOA7 | PC28 |
  94. * 4 NPCS1 | PA29 |
  95. * TIOB6 | PC26 |
  96. * 5 TIOA6 | PC25 |
  97. * 6 PWML7 | PC24 |
  98. * 7 PWML6 | PC23 |
  99. * 8 PWML5 | PC22 |
  100. * 9 PWML4 | PC21 |
  101. * 10 NPCS0 | PA28 |
  102. * TIOB7 | PC29 |
  103. * 11 TIOA8 | PD7 |
  104. * 12 TIOB8 | PD8 |
  105. * 13 TIOB0 | PB27 | LED AMBER "L"
  106. * 14 TXD3 | PD4 | "TX3"
  107. * 15 RXD3 | PD5 | "RX3"
  108. * 16 TXD1 | PA13 | "TX2"
  109. * 17 RXD1 | PA12 | "RX2"
  110. * 18 TXD0 | PA11 | "TX1"
  111. * 19 RXD0 | PA10 | "RX1"
  112. * 20 | PB12 | "SDA"
  113. * 21 | PB13 | "SCL"
  114. * 22 | PB26 |
  115. * 23 | PA14 |
  116. * 24 | PA15 |
  117. * 25 | PD0 |
  118. * 26 | PD1 |
  119. * 27 | PD2 |
  120. * 28 | PD3 |
  121. * 29 | PD6 |
  122. * 30 | PD9 |
  123. * 31 | PA7 |
  124. * 32 | PD10 |
  125. * 33 | PC1 |
  126. * 34 | PC2 |
  127. * 35 | PC3 |
  128. * 36 | PC4 |
  129. * 37 | PC5 |
  130. * 38 | PC6 |
  131. * 39 | PC7 |
  132. * 40 | PC8 |
  133. * 41 | PC9 |
  134. * 42 | PA19 |
  135. * 43 | PA20 |
  136. * 44 | PC19 |
  137. * 45 | PC18 |
  138. * 46 | PC17 |
  139. * 47 | PC16 |
  140. * 48 | PC15 |
  141. * 49 | PC14 |
  142. * 50 | PC13 |
  143. * 51 | PC12 |
  144. * 52 NPCS2 | PB21 |
  145. * 53 | PB14 |
  146. * 54 | PA16 | "A0"
  147. * 55 | PA24 | "A1"
  148. * 56 | PA23 | "A2"
  149. * 57 | PA22 | "A3"
  150. * 58 TIOB2 | PA6 | "A4"
  151. * 69 | PA4 | "A5"
  152. * 60 TIOB1 | PA3 | "A6"
  153. * 61 TIOA1 | PA2 | "A7"
  154. * 62 | PB17 | "A8"
  155. * 63 | PB18 | "A9"
  156. * 64 | PB19 | "A10"
  157. * 65 | PB20 | "A11"
  158. * 66 | PB15 | "DAC0"
  159. * 67 | PB16 | "DAC1"
  160. * 68 | PA1 | "CANRX"
  161. * 69 | PA0 | "CANTX"
  162. * 70 | PA17 | "SDA1"
  163. * 71 | PA18 | "SCL1"
  164. * 72 | PC30 | LED AMBER "RX"
  165. * 73 | PA21 | LED AMBER "TX"
  166. * 74 MISO | PA25 |
  167. * 75 MOSI | PA26 |
  168. * 76 SCLK | PA27 |
  169. * 77 NPCS0 | PA28 |
  170. * 78 NPCS3 | PB23 | unconnected!
  171. *
  172. * USB pin | PORT
  173. * ----------------+--------
  174. * ID | PB11
  175. * VBOF | PB10
  176. *
  177. */