My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

pinsDebug.h 6.2KB

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