My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

pinsDebug_STM32GENERIC.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. #pragma once
  20. /**
  21. * Support routines for STM32GENERIC (Maple)
  22. */
  23. /**
  24. * Translation of routines & variables used by pinsDebug.h
  25. */
  26. #ifdef BOARD_NR_GPIO_PINS // Only in STM32GENERIC (Maple)
  27. #ifdef __STM32F1__
  28. #include "../HAL_STM32F1/fastio_STM32F1.h"
  29. #elif defined(STM32F4) || defined(STM32F7)
  30. #include "../HAL_STM32_F4_F7/fastio_STM32_F4_F7.h"
  31. #endif
  32. extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
  33. #define NUM_DIGITAL_PINS BOARD_NR_GPIO_PINS
  34. #define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
  35. #define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
  36. #define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
  37. #define pwm_status(pin) PWM_PIN(pin)
  38. #define digitalRead_mod(p) extDigitalRead(p)
  39. #define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
  40. #define PRINT_PORT(p) print_port(p)
  41. #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
  42. #define MULTI_NAME_PAD 21 // space needed to be pretty if not first name assigned to a pin
  43. // pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
  44. #ifndef M43_NEVER_TOUCH
  45. #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
  46. #endif
  47. static inline int8_t get_pin_mode(pin_t pin) {
  48. return VALID_PIN(pin) ? _GET_MODE(pin) : -1;
  49. }
  50. static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
  51. if (!VALID_PIN(pin)) return -1;
  52. int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel);
  53. #ifdef NUM_ANALOG_INPUTS
  54. if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = ADCx;
  55. #endif
  56. return pin_t(adc_channel);
  57. }
  58. static inline bool IS_ANALOG(pin_t pin) {
  59. if (!VALID_PIN(pin)) return false;
  60. if (PIN_MAP[pin].adc_channel != ADCx) {
  61. #ifdef NUM_ANALOG_INPUTS
  62. if (PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS) return false;
  63. #endif
  64. return _GET_MODE(pin) == GPIO_INPUT_ANALOG && !M43_NEVER_TOUCH(pin);
  65. }
  66. return false;
  67. }
  68. static inline bool GET_PINMODE(const pin_t pin) {
  69. return VALID_PIN(pin) && !IS_INPUT(pin);
  70. }
  71. static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
  72. const pin_t pin = GET_ARRAY_PIN(array_pin);
  73. return (!IS_ANALOG(pin)
  74. #ifdef NUM_ANALOG_INPUTS
  75. || PIN_MAP[pin].adc_channel >= NUM_ANALOG_INPUTS
  76. #endif
  77. );
  78. }
  79. #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
  80. static inline void pwm_details(const pin_t pin) {
  81. if (PWM_PIN(pin)) {
  82. timer_dev * const tdev = PIN_MAP[pin].timer_device;
  83. const uint8_t channel = PIN_MAP[pin].timer_channel;
  84. const char num = (
  85. #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
  86. tdev == &timer8 ? '8' :
  87. tdev == &timer5 ? '5' :
  88. #endif
  89. tdev == &timer4 ? '4' :
  90. tdev == &timer3 ? '3' :
  91. tdev == &timer2 ? '2' :
  92. tdev == &timer1 ? '1' : '?'
  93. );
  94. char buffer[10];
  95. sprintf_P(buffer, PSTR(" TIM%c CH%c"), num, ('0' + channel));
  96. SERIAL_ECHO(buffer);
  97. }
  98. }
  99. static inline void print_port(pin_t pin) {
  100. const char port = 'A' + char(pin >> 4); // pin div 16
  101. const int16_t gbit = PIN_MAP[pin].gpio_bit;
  102. char buffer[8];
  103. sprintf_P(buffer, PSTR("P%c%hd "), port, gbit);
  104. if (gbit < 10) SERIAL_CHAR(' ');
  105. SERIAL_ECHO(buffer);
  106. }
  107. #endif // BOARD_NR_GPIO_PINS