My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * HAL Pins Debugging for Teensy 4.0 (IMXRT1062DVL6A) / 4.1 (IMXRT1062DVJ6A)
  25. */
  26. #warning "PINS_DEBUGGING is not fully supported for Teensy 4.0 / 4.1 so 'M43' may cause hangs."
  27. #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
  28. #define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
  29. #define PRINT_PORT(p)
  30. #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
  31. #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
  32. #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
  33. #define GET_ARRAY_PIN(p) pin_array[p].pin
  34. #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
  35. #define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
  36. #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
  37. #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
  38. #define pwm_status(pin) HAL_pwm_status(pin)
  39. #define GET_PINMODE(PIN) (VALID_PIN(pin) && IS_OUTPUT(pin))
  40. #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
  41. struct pwm_pin_info_struct {
  42. uint8_t type; // 0=no pwm, 1=flexpwm, 2=quad
  43. uint8_t module; // 0-3, 0-3
  44. uint8_t channel; // 0=X, 1=A, 2=B
  45. uint8_t muxval; //
  46. };
  47. #define M(a, b) ((((a) - 1) << 4) | (b))
  48. const struct pwm_pin_info_struct pwm_pin_info[] = {
  49. {1, M(1, 1), 0, 4}, // FlexPWM1_1_X 0 // AD_B0_03
  50. {1, M(1, 0), 0, 4}, // FlexPWM1_0_X 1 // AD_B0_02
  51. {1, M(4, 2), 1, 1}, // FlexPWM4_2_A 2 // EMC_04
  52. {1, M(4, 2), 2, 1}, // FlexPWM4_2_B 3 // EMC_05
  53. {1, M(2, 0), 1, 1}, // FlexPWM2_0_A 4 // EMC_06
  54. {1, M(2, 1), 1, 1}, // FlexPWM2_1_A 5 // EMC_08
  55. {1, M(2, 2), 1, 2}, // FlexPWM2_2_A 6 // B0_10
  56. {1, M(1, 3), 2, 6}, // FlexPWM1_3_B 7 // B1_01
  57. {1, M(1, 3), 1, 6}, // FlexPWM1_3_A 8 // B1_00
  58. {1, M(2, 2), 2, 2}, // FlexPWM2_2_B 9 // B0_11
  59. {2, M(1, 0), 0, 1}, // QuadTimer1_0 10 // B0_00
  60. {2, M(1, 2), 0, 1}, // QuadTimer1_2 11 // B0_02
  61. {2, M(1, 1), 0, 1}, // QuadTimer1_1 12 // B0_01
  62. {2, M(2, 0), 0, 1}, // QuadTimer2_0 13 // B0_03
  63. {2, M(3, 2), 0, 1}, // QuadTimer3_2 14 // AD_B1_02
  64. {2, M(3, 3), 0, 1}, // QuadTimer3_3 15 // AD_B1_03
  65. {0, M(1, 0), 0, 0},
  66. {0, M(1, 0), 0, 0},
  67. {2, M(3, 1), 0, 1}, // QuadTimer3_1 18 // AD_B1_01
  68. {2, M(3, 0), 0, 1}, // QuadTimer3_0 19 // AD_B1_00
  69. {0, M(1, 0), 0, 0},
  70. {0, M(1, 0), 0, 0},
  71. {1, M(4, 0), 1, 1}, // FlexPWM4_0_A 22 // AD_B1_08
  72. {1, M(4, 1), 1, 1}, // FlexPWM4_1_A 23 // AD_B1_09
  73. {1, M(1, 2), 0, 4}, // FlexPWM1_2_X 24 // AD_B0_12
  74. {1, M(1, 3), 0, 4}, // FlexPWM1_3_X 25 // AD_B0_13
  75. {0, M(1, 0), 0, 0},
  76. {0, M(1, 0), 0, 0},
  77. {1, M(3, 1), 2, 1}, // FlexPWM3_1_B 28 // EMC_32
  78. {1, M(3, 1), 1, 1}, // FlexPWM3_1_A 29 // EMC_31
  79. {0, M(1, 0), 0, 0},
  80. {0, M(1, 0), 0, 0},
  81. {0, M(1, 0), 0, 0},
  82. {1, M(2, 0), 2, 1}, // FlexPWM2_0_B 33 // EMC_07
  83. #ifdef ARDUINO_TEENSY40
  84. {1, M(1, 1), 2, 1}, // FlexPWM1_1_B 34 // SD_B0_03
  85. {1, M(1, 1), 1, 1}, // FlexPWM1_1_A 35 // SD_B0_02
  86. {1, M(1, 0), 2, 1}, // FlexPWM1_0_B 36 // SD_B0_01
  87. {1, M(1, 0), 1, 1}, // FlexPWM1_0_A 37 // SD_B0_00
  88. {1, M(1, 2), 2, 1}, // FlexPWM1_2_B 38 // SD_B0_05
  89. {1, M(1, 2), 1, 1}, // FlexPWM1_2_A 39 // SD_B0_04
  90. #endif
  91. #ifdef ARDUINO_TEENSY41
  92. {0, M(1, 0), 0, 0},
  93. {0, M(1, 0), 0, 0},
  94. {1, M(2, 3), 1, 6}, // FlexPWM2_3_A 36 // B1_00
  95. {1, M(2, 3), 2, 6}, // FlexPWM2_3_B 37 // B1_01
  96. {0, M(1, 0), 0, 0},
  97. {0, M(1, 0), 0, 0},
  98. {0, M(1, 0), 0, 0},
  99. {0, M(1, 0), 0, 0},
  100. {1, M(1, 1), 2, 1}, // FlexPWM1_1_B 42 // SD_B0_03
  101. {1, M(1, 1), 1, 1}, // FlexPWM1_1_A 43 // SD_B0_02
  102. {1, M(1, 0), 2, 1}, // FlexPWM1_0_B 44 // SD_B0_01
  103. {1, M(1, 0), 1, 1}, // FlexPWM1_0_A 45 // SD_B0_00
  104. {1, M(1, 2), 2, 1}, // FlexPWM1_2_B 46 // SD_B0_05
  105. {1, M(1, 2), 1, 1}, // FlexPWM1_2_A 47 // SD_B0_04
  106. {0, M(1, 0), 0, 0}, // duplicate FlexPWM1_0_B
  107. {0, M(1, 0), 0, 0}, // duplicate FlexPWM1_2_A
  108. {0, M(1, 0), 0, 0}, // duplicate FlexPWM1_2_B
  109. {1, M(3, 3), 2, 1}, // FlexPWM3_3_B 51 // EMC_22
  110. {0, M(1, 0), 0, 0}, // duplicate FlexPWM1_1_B
  111. {0, M(1, 0), 0, 0}, // duplicate FlexPWM1_1_A
  112. {1, M(3, 0), 1, 1}, // FlexPWM3_0_A 53 // EMC_29
  113. #endif
  114. };
  115. void HAL_print_analog_pin(char buffer[], int8_t pin) {
  116. if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
  117. else if (pin <= 41) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 24));
  118. }
  119. void HAL_analog_pin_state(char buffer[], int8_t pin) {
  120. if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
  121. else if (pin <= 41) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 24));
  122. }
  123. #define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM: %4d"), V); SERIAL_ECHO(buffer); }while(0)
  124. /**
  125. * Print a pin's PWM status.
  126. * Return true if it's currently a PWM pin.
  127. */
  128. bool HAL_pwm_status(int8_t pin) {
  129. char buffer[20]; // for the sprintf statements
  130. const struct pwm_pin_info_struct *info;
  131. if (pin >= CORE_NUM_DIGITAL) return 0;
  132. info = pwm_pin_info + pin;
  133. if (info->type == 0) return 0;
  134. /* TODO decode pwm value from timers */
  135. // for now just indicate if output is set as pwm
  136. PWM_PRINT(*(portConfigRegister(pin)) == info->muxval);
  137. return (*(portConfigRegister(pin)) == info->muxval);
  138. }
  139. static void pwm_details(uint8_t pin) { /* TODO */ }