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.3KB

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