From c9e35004e754be5a9474fa92b0d8847836c137e9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 20 Mar 2017 06:10:31 -0500 Subject: [PATCH] pinsDebug with more features, uses less RAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've just uploaded a major change to pinsDebug. The big change was creating an array in FLASH that contained every active pin definition. That reduced the RAM memory usage considerably but increased the FLASH usage. Creating the array requires going through the pin list twice. Rather than having two copies of it in the code I moved the list out to another file (pinsDebug_list.h) and then just did two #includes. From the user’s view they’ll see the following changes: 1. Now reports all the names assigned to a pin 2. The port is now reported in addition to the pin number. 3. When PWM0A & PWM1C share a pin, both PWMs are reported 4. More PWM/Timer info is reported One new item that may cause some concern is the usage of the LINE predefined preprocessor macro. It may not be available if the Arduino IDE goes to a different compiler. Includes support for 1284 & 1286 families. Memory usage changes when enabling PINS_DEBUGGING: ATmega2560 FLASH . without 52576 . with new 64592 . with old 62826 . new-out 12016 . old-out 10250 . new-old 1766 . RAM . without 2807 . with new 2875 . with old 3545 . new-out 68 . old-out 738 . new-old -670 ================================================================== minor changes - mostly formatting 1) added newline to end of teensyduino file 2) changed flag name from TEENSYDUINO to TEENSYDUINO_IDE. Got warnings about redefining TEENSYDUINO 3) removed some trailing spaces reduce PROGMEM size & update pin list Reduced PROGMEM usage by 1) converting often used macro to a function 2) moved as much as possible into the function This required creating two arrays of address pointers for the PWM registers. ================================================================== update with new M3, M4, M5 pin names ================================================================== report I/O status for unused/unknown pins --- Marlin/pinsDebug.h | 1166 +++++++++++++-------------------------- Marlin/pinsDebug_list.h | 775 ++++++++++++++++++++++++++ 2 files changed, 1151 insertions(+), 790 deletions(-) create mode 100644 Marlin/pinsDebug_list.h diff --git a/Marlin/pinsDebug.h b/Marlin/pinsDebug.h index 8fe48da2a..ec20e47cb 100644 --- a/Marlin/pinsDebug.h +++ b/Marlin/pinsDebug.h @@ -20,649 +20,99 @@ * */ -#include "macros.h" bool endstop_monitor_flag = false; +#define NAME_FORMAT "%-28s" // one place to specify the format of all the sources of names + // "-" left justify, "28" minimum width of name, pad with blanks + +#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7))) + +#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)) +#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)) +#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)) + +/** + * This routine minimizes RAM usage by creating a FLASH resident array to + * store the pin names, pin numbers and analog/digital flag. + * + * Creating the array in FLASH is a two pass process. The first pass puts the + * name strings into FLASH. The second pass actually creates the array. + * + * Both passes use the same pin list. The list contains two macro names. The + * actual macro definitions are changed depending on which pass is being done. + * + */ + +// first pass - put the name strings into FLASH + +#define _ADD_PIN_2(PIN_NAME, ENTRY_NAME) static const unsigned char ENTRY_NAME[] PROGMEM = {PIN_NAME}; +#define _ADD_PIN(PIN_NAME, COUNTER) _ADD_PIN_2(PIN_NAME, entry_NAME_##COUNTER) +#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) +#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER) + +#line 0 // set __LINE__ to a known value for the first pass + +#include "pinsDebug_list.h" + +#line 59 // set __LINE__ to the correct line number or else compiler error messages don't make sense + +// manually add pins that have names that are macros which don't play well with these macros +#if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY) + static const unsigned char RXD_NAME[] PROGMEM = {"RXD"}; + static const unsigned char TXD_NAME[] PROGMEM = {"TXD"}; +#endif + +///////////////////////////////////////////////////////////////////////////// + +// second pass - create the array + +#undef _ADD_PIN_2 +#undef _ADD_PIN +#undef REPORT_NAME_DIGITAL +#undef REPORT_NAME_ANALOG + +#define _ADD_PIN_2( ENTRY_NAME, NAME, IS_DIGITAL) {(const char*) ENTRY_NAME, (const char*)NAME, (const char*)IS_DIGITAL}, +#define _ADD_PIN( NAME, COUNTER, IS_DIGITAL) _ADD_PIN_2( entry_NAME_##COUNTER, NAME, IS_DIGITAL) +#define REPORT_NAME_DIGITAL(NAME, COUNTER) _ADD_PIN( NAME, COUNTER, (uint8_t)1) +#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN( analogInputToDigitalPin(NAME), COUNTER, 0) + + +const char* const pin_array[][3] PROGMEM = { + +/** + * [pin name] [pin number] [is digital or analog] 1 = digital, 0 = analog + * Each entry takes up 6 bytes in FLASH: + * 2 byte pointer to location of the name string + * 2 bytes containing the pin number + * analog pin numbers were convereted to digital when the array was created + * 2 bytes containing the digital/analog bool flag + */ + + // manually add pins ... + #if SERIAL_PORT == 0 + #if AVR_ATmega2560_FAMILY + {RXD_NAME, 0, 1}, + {TXD_NAME, 1, 1}, + #elif AVR_ATmega1284_FAMILY + {RXD_NAME, 8, 1}, + {TXD_NAME, 9, 1}, + #endif + #endif + + #line 0 // set __LINE__ to the SAME known value for the second pass + #include "pinsDebug_list.h" + +}; // done populating the array + +#line 109 // set __LINE__ to the correct line number or else compiler error messages don't make sense + +#define n_array (sizeof (pin_array) / sizeof (const char *))/3 + #if !defined(TIMER1B) // working with Teensyduino extension so need to re-define some things #include "pinsDebug_Teensyduino.h" #endif -#define NAME_FORMAT "%-28s" // one place to specify the format of all the sources of names - // "-" left justify, "28" minimum width of name, pad with blanks - -#define _PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); return true; } -#define PIN_SAY(NAME) if (pin == NAME) _PIN_SAY(#NAME); - -#define _ANALOG_PIN_SAY(NAME) { sprintf(buffer, NAME_FORMAT, NAME); SERIAL_ECHO(buffer); pin_is_analog = true; return true; } -#define ANALOG_PIN_SAY(NAME) if (pin == analogInputToDigitalPin(NAME)) _ANALOG_PIN_SAY(#NAME); - -#define IS_ANALOG(P) ( WITHIN(P, analogInputToDigitalPin(0), analogInputToDigitalPin(15)) || (P) <= analogInputToDigitalPin(5) ) - -int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed - uint8_t port = digitalPinToPort(pin); - return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW; -} - -/** - * Report pin name for a given fastio digital pin index - */ -static bool report_pin_name(int8_t pin, bool &pin_is_analog) { - - char buffer[30]; // for the sprintf statements - pin_is_analog = false; // default to digital pin - - if (IS_ANALOG(pin)) { - sprintf(buffer, "(A%2d) ", int(pin - analogInputToDigitalPin(0))); - SERIAL_ECHO(buffer); - } - else SERIAL_ECHOPGM(" "); - - #if defined(RXD) && RXD >= 0 - if (pin == 0) { sprintf(buffer, NAME_FORMAT, "RXD"); SERIAL_ECHO(buffer); return true; } - #endif - - #if defined(TXD) && TXD >= 0 - if (pin == 1) { sprintf(buffer, NAME_FORMAT, "TXD"); SERIAL_ECHO(buffer); return true; } - #endif - - // Pin list updated from 7 OCT RCBugfix branch - max length of pin name is 24 - #if defined(__FD) && __FD >= 0 - PIN_SAY(__FD) - #endif - #if defined(__FS) && __FS >= 0 - PIN_SAY(__FS) - #endif - #if defined(__GD) && __GD >= 0 - PIN_SAY(__GD) - #endif - #if defined(__GS) && __GS >= 0 - PIN_SAY(__GS) - #endif - - #if PIN_EXISTS(AVR_MISO) - PIN_SAY(AVR_MISO_PIN); - #endif - #if PIN_EXISTS(AVR_MOSI) - PIN_SAY(AVR_MOSI_PIN); - #endif - #if PIN_EXISTS(AVR_SCK) - PIN_SAY(AVR_SCK_PIN); - #endif - #if PIN_EXISTS(AVR_SS) - PIN_SAY(AVR_SS_PIN); - #endif - #if PIN_EXISTS(BEEPER) - PIN_SAY(BEEPER_PIN); - #endif - #if defined(BTN_CENTER) && BTN_CENTER >= 0 - PIN_SAY(BTN_CENTER); - #endif - #if defined(BTN_DOWN) && BTN_DOWN >= 0 - PIN_SAY(BTN_DOWN); - #endif - #if defined(BTN_DWN) && BTN_DWN >= 0 - PIN_SAY(BTN_DWN); - #endif - #if defined(BTN_EN1) && BTN_EN1 >= 0 - PIN_SAY(BTN_EN1); - #endif - #if defined(BTN_EN2) && BTN_EN2 >= 0 - PIN_SAY(BTN_EN2); - #endif - #if defined(BTN_ENC) && BTN_ENC >= 0 - PIN_SAY(BTN_ENC); - #endif - #if defined(BTN_HOME) && BTN_HOME >= 0 - PIN_SAY(BTN_HOME); - #endif - #if defined(BTN_LEFT) && BTN_LEFT >= 0 - PIN_SAY(BTN_LEFT); - #endif - #if defined(BTN_LFT) && BTN_LFT >= 0 - PIN_SAY(BTN_LFT); - #endif - #if defined(BTN_RIGHT) && BTN_RIGHT >= 0 - PIN_SAY(BTN_RIGHT); - #endif - #if defined(BTN_RT) && BTN_RT >= 0 - PIN_SAY(BTN_RT); - #endif - #if defined(BTN_UP) && BTN_UP >= 0 - PIN_SAY(BTN_UP); - #endif - #if PIN_EXISTS(CONTROLLERFAN) - PIN_SAY(CONTROLLERFAN_PIN); - #endif - #if PIN_EXISTS(DAC_DISABLE) - PIN_SAY(DAC_DISABLE_PIN); - #endif - #if defined(DAC_STEPPER_GAIN) && DAC_STEPPER_GAIN >= 0 - PIN_SAY(DAC_STEPPER_GAIN); - #endif - #if defined(DAC_STEPPER_VREF) && DAC_STEPPER_VREF >= 0 - PIN_SAY(DAC_STEPPER_VREF); - #endif - #if PIN_EXISTS(DEBUG) - PIN_SAY(DEBUG_PIN); - #endif - #if PIN_EXISTS(DIGIPOTSS) - PIN_SAY(DIGIPOTSS_PIN); - #endif - #if defined(DOGLCD_A0) && DOGLCD_A0 >= 0 - PIN_SAY(DOGLCD_A0); - #endif - #if defined(DOGLCD_CS) && DOGLCD_CS >= 0 - PIN_SAY(DOGLCD_CS); - #endif - #if defined(DOGLCD_MOSI) && DOGLCD_MOSI >= 0 - PIN_SAY(DOGLCD_MOSI); - #endif - #if defined(DOGLCD_SCK) && DOGLCD_SCK >= 0 - PIN_SAY(DOGLCD_SCK); - #endif - #if PIN_EXISTS(E0_ATT) - PIN_SAY(E0_ATT_PIN); - #endif - #if PIN_EXISTS(E0_AUTO_FAN) - PIN_SAY(E0_AUTO_FAN_PIN); - #endif - #if PIN_EXISTS(E1_AUTO_FAN) - PIN_SAY(E1_AUTO_FAN_PIN); - #endif - #if PIN_EXISTS(E2_AUTO_FAN) - PIN_SAY(E2_AUTO_FAN_PIN); - #endif - #if PIN_EXISTS(E3_AUTO_FAN) - PIN_SAY(E3_AUTO_FAN_PIN); - #endif - #if PIN_EXISTS(E0_DIR) - PIN_SAY(E0_DIR_PIN); - #endif - #if PIN_EXISTS(E0_ENABLE) - PIN_SAY(E0_ENABLE_PIN); - #endif - #if PIN_EXISTS(E0_MS1) - PIN_SAY(E0_MS1_PIN); - #endif - #if PIN_EXISTS(E0_MS2) - PIN_SAY(E0_MS2_PIN); - #endif - #if PIN_EXISTS(E0_STEP) - PIN_SAY(E0_STEP_PIN); - #endif - #if PIN_EXISTS(E1_DIR) - PIN_SAY(E1_DIR_PIN); - #endif - #if PIN_EXISTS(E1_ENABLE) - PIN_SAY(E1_ENABLE_PIN); - #endif - #if PIN_EXISTS(E1_MS1) - PIN_SAY(E1_MS1_PIN); - #endif - #if PIN_EXISTS(E1_MS2) - PIN_SAY(E1_MS2_PIN); - #endif - #if PIN_EXISTS(E1_STEP) - PIN_SAY(E1_STEP_PIN); - #endif - #if PIN_EXISTS(E2_DIR) - PIN_SAY(E2_DIR_PIN); - #endif - #if PIN_EXISTS(E2_ENABLE) - PIN_SAY(E2_ENABLE_PIN); - #endif - #if PIN_EXISTS(E2_STEP) - PIN_SAY(E2_STEP_PIN); - #endif - #if PIN_EXISTS(E3_DIR) - PIN_SAY(E3_DIR_PIN); - #endif - #if PIN_EXISTS(E3_ENABLE) - PIN_SAY(E3_ENABLE_PIN); - #endif - #if PIN_EXISTS(E3_STEP) - PIN_SAY(E3_STEP_PIN); - #endif - #if PIN_EXISTS(E4_DIR) - PIN_SAY(E4_DIR_PIN); - #endif - #if PIN_EXISTS(E4_ENABLE) - PIN_SAY(E4_ENABLE_PIN); - #endif - #if PIN_EXISTS(E4_STEP) - PIN_SAY(E4_STEP_PIN); - #endif - #if defined(encrot1) && encrot1 >= 0 - PIN_SAY(encrot1); - #endif - #if defined(encrot2) && encrot2 >= 0 - PIN_SAY(encrot2); - #endif - #if defined(encrot3) && encrot3 >= 0 - PIN_SAY(encrot3); - #endif - #if defined(EXT_AUX_A0_IO) && EXT_AUX_A0_IO >= 0 - PIN_SAY(EXT_AUX_A0_IO); - #endif - #if defined(EXT_AUX_A1) && EXT_AUX_A1 >= 0 - PIN_SAY(EXT_AUX_A1); - #endif - #if defined(EXT_AUX_A1_IO) && EXT_AUX_A1_IO >= 0 - PIN_SAY(EXT_AUX_A1_IO); - #endif - #if defined(EXT_AUX_A2) && EXT_AUX_A2 >= 0 - PIN_SAY(EXT_AUX_A2); - #endif - #if defined(EXT_AUX_A2_IO) && EXT_AUX_A2_IO >= 0 - PIN_SAY(EXT_AUX_A2_IO); - #endif - #if defined(EXT_AUX_A3) && EXT_AUX_A3 >= 0 - PIN_SAY(EXT_AUX_A3); - #endif - #if defined(EXT_AUX_A3_IO) && EXT_AUX_A3_IO >= 0 - PIN_SAY(EXT_AUX_A3_IO); - #endif - #if defined(EXT_AUX_A4) && EXT_AUX_A4 >= 0 - PIN_SAY(EXT_AUX_A4); - #endif - #if defined(EXT_AUX_A4_IO) && EXT_AUX_A4_IO >= 0 - PIN_SAY(EXT_AUX_A4_IO); - #endif - #if defined(EXT_AUX_PWM_D24) && EXT_AUX_PWM_D24 >= 0 - PIN_SAY(EXT_AUX_PWM_D24); - #endif - #if defined(EXT_AUX_RX1_D2) && EXT_AUX_RX1_D2 >= 0 - PIN_SAY(EXT_AUX_RX1_D2); - #endif - #if defined(EXT_AUX_SDA_D1) && EXT_AUX_SDA_D1 >= 0 - PIN_SAY(EXT_AUX_SDA_D1); - #endif - #if defined(EXT_AUX_TX1_D3) && EXT_AUX_TX1_D3 >= 0 - PIN_SAY(EXT_AUX_TX1_D3); - #endif - - #if PIN_EXISTS(FAN) - PIN_SAY(FAN_PIN); - #endif - #if PIN_EXISTS(FAN1) - PIN_SAY(FAN1_PIN); - #endif - #if PIN_EXISTS(FAN2) - PIN_SAY(FAN2_PIN); - #endif - #if PIN_EXISTS(FIL_RUNOUT) - PIN_SAY(FIL_RUNOUT_PIN); - #endif - #if PIN_EXISTS(FILWIDTH) - ANALOG_PIN_SAY(FILWIDTH_PIN); - #endif - #if defined(GEN7_VERSION) && GEN7_VERSION >= 0 - PIN_SAY(GEN7_VERSION); - #endif - #if PIN_EXISTS(HEATER_0) - PIN_SAY(HEATER_0_PIN); - #endif - #if PIN_EXISTS(HEATER_1) - PIN_SAY(HEATER_1_PIN); - #endif - #if PIN_EXISTS(HEATER_2) - PIN_SAY(HEATER_2_PIN); - #endif - #if PIN_EXISTS(HEATER_3) - PIN_SAY(HEATER_3_PIN); - #endif - #if PIN_EXISTS(HEATER_4) - PIN_SAY(HEATER_4_PIN); - #endif - #if PIN_EXISTS(HEATER_5) - PIN_SAY(HEATER_5_PIN); - #endif - #if PIN_EXISTS(HEATER_6) - PIN_SAY(HEATER_6_PIN); - #endif - #if PIN_EXISTS(HEATER_7) - PIN_SAY(HEATER_7_PIN); - #endif - #if PIN_EXISTS(HEATER_BED) - PIN_SAY(HEATER_BED_PIN); - #endif - #if defined(I2C_SCL) && I2C_SCL >= 0 - PIN_SAY(I2C_SCL); - #endif - #if defined(I2C_SDA) && I2C_SDA >= 0 - PIN_SAY(I2C_SDA); - #endif - #if PIN_EXISTS(KILL) - PIN_SAY(KILL_PIN); - #endif - #if PIN_EXISTS(LCD_BACKLIGHT) - PIN_SAY(LCD_BACKLIGHT_PIN); - #endif - #if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0 - PIN_SAY(LCD_CONTRAST); - #endif - #if defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0 - PIN_SAY(LCD_PINS_D4); - #endif - #if defined(LCD_PINS_D5) && LCD_PINS_D5 >= 0 - PIN_SAY(LCD_PINS_D5); - #endif - #if defined(LCD_PINS_D6) && LCD_PINS_D6 >= 0 - PIN_SAY(LCD_PINS_D6); - #endif - #if defined(LCD_PINS_D7) && LCD_PINS_D7 >= 0 - PIN_SAY(LCD_PINS_D7); - #endif - #if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0 - PIN_SAY(LCD_PINS_ENABLE); - #endif - #if defined(LCD_PINS_RS) && LCD_PINS_RS >= 0 - PIN_SAY(LCD_PINS_RS); - #endif - #if defined(LCD_SDSS) && LCD_SDSS >= 0 - PIN_SAY(LCD_SDSS); - #endif - #if PIN_EXISTS(LED) - PIN_SAY(LED_PIN); - #endif - #if PIN_EXISTS(CASE_LIGHT) - PIN_SAY(CASE_LIGHT_PIN); - #endif - #if PIN_EXISTS(MAIN_VOLTAGE_MEASURE) - PIN_SAY(MAIN_VOLTAGE_MEASURE_PIN); - #endif - #if defined(MAX6675_SS) && MAX6675_SS >= 0 - PIN_SAY(MAX6675_SS); - #endif - #if PIN_EXISTS(MISO) - PIN_SAY(MISO_PIN); - #endif - #if PIN_EXISTS(MOSFET_D) - PIN_SAY(MOSFET_D_PIN); - #endif - #if PIN_EXISTS(MOSI) - PIN_SAY(MOSI_PIN); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - PIN_SAY(MOTOR_CURRENT_PWM_E_PIN); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - PIN_SAY(MOTOR_CURRENT_PWM_XY_PIN); - #endif - #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - PIN_SAY(MOTOR_CURRENT_PWM_Z_PIN); - #endif - #if defined(NUM_TLCS) && NUM_TLCS >= 0 - PIN_SAY(NUM_TLCS); - #endif - #if PIN_EXISTS(PHOTOGRAPH) - PIN_SAY(PHOTOGRAPH_PIN); - #endif - #if PIN_EXISTS(PS_ON) - PIN_SAY(PS_ON_PIN); - #endif - #if PIN_EXISTS(RAMPS_D10) - PIN_SAY(RAMPS_D10_PIN); - #endif - #if PIN_EXISTS(RAMPS_D8) - PIN_SAY(RAMPS_D8_PIN); - #endif - #if PIN_EXISTS(RAMPS_D9) - PIN_SAY(RAMPS_D9_PIN); - #endif - #if PIN_EXISTS(RX_ENABLE) - PIN_SAY(RX_ENABLE_PIN); - #endif - #if PIN_EXISTS(SAFETY_TRIGGERED) - PIN_SAY(SAFETY_TRIGGERED_PIN); - #endif - #if PIN_EXISTS(SCK) - PIN_SAY(SCK_PIN); - #endif - #if defined(SCL) && SCL >= 0 - PIN_SAY(SCL); - #endif - #if PIN_EXISTS(SD_DETECT) - PIN_SAY(SD_DETECT_PIN); - #endif - #if defined(SDA) && SDA >= 0 - PIN_SAY(SDA); - #endif - #if defined(SDPOWER) && SDPOWER >= 0 - PIN_SAY(SDPOWER); - #endif - #if defined(SDSS) && SDSS >= 0 - PIN_SAY(SDSS); - #endif - #if PIN_EXISTS(SERVO0) - PIN_SAY(SERVO0_PIN); - #endif - #if PIN_EXISTS(SERVO1) - PIN_SAY(SERVO1_PIN); - #endif - #if PIN_EXISTS(SERVO2) - PIN_SAY(SERVO2_PIN); - #endif - #if PIN_EXISTS(SERVO3) - PIN_SAY(SERVO3_PIN); - #endif - #if defined(SHIFT_CLK) && SHIFT_CLK >= 0 - PIN_SAY(SHIFT_CLK); - #endif - #if defined(SHIFT_EN) && SHIFT_EN >= 0 - PIN_SAY(SHIFT_EN); - #endif - #if defined(SHIFT_LD) && SHIFT_LD >= 0 - PIN_SAY(SHIFT_LD); - #endif - #if defined(SHIFT_OUT) && SHIFT_OUT >= 0 - PIN_SAY(SHIFT_OUT); - #endif - #if PIN_EXISTS(SLED) - PIN_SAY(SLED_PIN); - #endif - #if PIN_EXISTS(SLEEP_WAKE) - PIN_SAY(SLEEP_WAKE_PIN); - #endif - #if PIN_EXISTS(SOL1) - PIN_SAY(SOL1_PIN); - #endif - #if PIN_EXISTS(SOL2) - PIN_SAY(SOL2_PIN); - #endif - #if PIN_EXISTS(SPINDLE_ENABLE) - PIN_SAY(SPINDLE_ENABLE_PIN); - #endif - #if PIN_EXISTS(SPINDLE_SPEED) - PIN_SAY(SPINDLE_SPEED_PIN); - #endif - #if PIN_EXISTS(SS) - PIN_SAY(SS_PIN); - #endif - #if PIN_EXISTS(STAT_LED_BLUE) - PIN_SAY(STAT_LED_BLUE_PIN); - #endif - #if PIN_EXISTS(STAT_LED_RED) - PIN_SAY(STAT_LED_RED_PIN); - #endif - #if PIN_EXISTS(STEPPER_RESET) - PIN_SAY(STEPPER_RESET_PIN); - #endif - #if PIN_EXISTS(SUICIDE) - PIN_SAY(SUICIDE_PIN); - #endif - #if defined(TC1) && TC1 >= 0 - ANALOG_PIN_SAY(TC1); - #endif - #if defined(TC2) && TC2 >= 0 - ANALOG_PIN_SAY(TC2); - #endif - #if PIN_EXISTS(TEMP_0) - ANALOG_PIN_SAY(TEMP_0_PIN); - #endif - #if PIN_EXISTS(TEMP_1) - ANALOG_PIN_SAY(TEMP_1_PIN); - #endif - #if PIN_EXISTS(TEMP_2) - ANALOG_PIN_SAY(TEMP_2_PIN); - #endif - #if PIN_EXISTS(TEMP_3) - ANALOG_PIN_SAY(TEMP_3_PIN); - #endif - #if PIN_EXISTS(TEMP_4) - ANALOG_PIN_SAY(TEMP_4_PIN); - #endif - #if PIN_EXISTS(TEMP_BED) - ANALOG_PIN_SAY(TEMP_BED_PIN); - #endif - #if PIN_EXISTS(TEMP_X) - ANALOG_PIN_SAY(TEMP_X_PIN); - #endif - #if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT >= 0 - PIN_SAY(TLC_BLANK_BIT); - #endif - #if PIN_EXISTS(TLC_BLANK) - PIN_SAY(TLC_BLANK_PIN); - #endif - #if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT >= 0 - PIN_SAY(TLC_CLOCK_BIT); - #endif - #if PIN_EXISTS(TLC_CLOCK) - PIN_SAY(TLC_CLOCK_PIN); - #endif - #if defined(TLC_DATA_BIT) && TLC_DATA_BIT >= 0 - PIN_SAY(TLC_DATA_BIT); - #endif - #if PIN_EXISTS(TLC_DATA) - PIN_SAY(TLC_DATA_PIN); - #endif - #if PIN_EXISTS(TLC_XLAT) - PIN_SAY(TLC_XLAT_PIN); - #endif - #if PIN_EXISTS(TX_ENABLE) - PIN_SAY(TX_ENABLE_PIN); - #endif - #if defined(UNUSED_PWM) && UNUSED_PWM >= 0 - PIN_SAY(UNUSED_PWM); - #endif - #if PIN_EXISTS(X_ATT) - PIN_SAY(X_ATT_PIN); - #endif - #if PIN_EXISTS(X_DIR) - PIN_SAY(X_DIR_PIN); - #endif - #if PIN_EXISTS(X_ENABLE) - PIN_SAY(X_ENABLE_PIN); - #endif - #if PIN_EXISTS(X_MAX) - PIN_SAY(X_MAX_PIN); - #endif - #if PIN_EXISTS(X_MIN) - PIN_SAY(X_MIN_PIN); - #endif - #if PIN_EXISTS(X_MS1) - PIN_SAY(X_MS1_PIN); - #endif - #if PIN_EXISTS(X_MS2) - PIN_SAY(X_MS2_PIN); - #endif - #if PIN_EXISTS(X_STEP) - PIN_SAY(X_STEP_PIN); - #endif - #if PIN_EXISTS(X_STOP) - PIN_SAY(X_STOP_PIN); - #endif - #if PIN_EXISTS(X2_DIR) - PIN_SAY(X2_DIR_PIN); - #endif - #if PIN_EXISTS(X2_ENABLE) - PIN_SAY(X2_ENABLE_PIN); - #endif - #if PIN_EXISTS(X2_STEP) - PIN_SAY(X2_STEP_PIN); - #endif - #if PIN_EXISTS(Y_ATT) - PIN_SAY(Y_ATT_PIN); - #endif - #if PIN_EXISTS(Y_DIR) - PIN_SAY(Y_DIR_PIN); - #endif - #if PIN_EXISTS(Y_ENABLE) - PIN_SAY(Y_ENABLE_PIN); - #endif - #if PIN_EXISTS(Y_MAX) - PIN_SAY(Y_MAX_PIN); - #endif - #if PIN_EXISTS(Y_MIN) - PIN_SAY(Y_MIN_PIN); - #endif - #if PIN_EXISTS(Y_MS1) - PIN_SAY(Y_MS1_PIN); - #endif - #if PIN_EXISTS(Y_MS2) - PIN_SAY(Y_MS2_PIN); - #endif - #if PIN_EXISTS(Y_STEP) - PIN_SAY(Y_STEP_PIN); - #endif - #if PIN_EXISTS(Y_STOP) - PIN_SAY(Y_STOP_PIN); - #endif - #if PIN_EXISTS(Y2_DIR) - PIN_SAY(Y2_DIR_PIN); - #endif - #if PIN_EXISTS(Y2_ENABLE) - PIN_SAY(Y2_ENABLE_PIN); - #endif - #if PIN_EXISTS(Y2_STEP) - PIN_SAY(Y2_STEP_PIN); - #endif - #if PIN_EXISTS(Z_ATT) - PIN_SAY(Z_ATT_PIN); - #endif - #if PIN_EXISTS(Z_DIR) - PIN_SAY(Z_DIR_PIN); - #endif - #if PIN_EXISTS(Z_ENABLE) - PIN_SAY(Z_ENABLE_PIN); - #endif - #if PIN_EXISTS(Z_MAX) - PIN_SAY(Z_MAX_PIN); - #endif - #if PIN_EXISTS(Z_MIN) - PIN_SAY(Z_MIN_PIN); - #endif - #if PIN_EXISTS(Z_MIN_PROBE) - PIN_SAY(Z_MIN_PROBE_PIN); - #endif - #if PIN_EXISTS(Z_MS1) - PIN_SAY(Z_MS1_PIN); - #endif - #if PIN_EXISTS(Z_MS2) - PIN_SAY(Z_MS2_PIN); - #endif - #if PIN_EXISTS(Z_STEP) - PIN_SAY(Z_STEP_PIN); - #endif - #if PIN_EXISTS(Z_STOP) - PIN_SAY(Z_STOP_PIN); - #endif - #if PIN_EXISTS(Z2_DIR) - PIN_SAY(Z2_DIR_PIN); - #endif - #if PIN_EXISTS(Z2_ENABLE) - PIN_SAY(Z2_ENABLE_PIN); - #endif - #if PIN_EXISTS(Z2_STEP) - PIN_SAY(Z2_STEP_PIN); - #endif - - sprintf(buffer, NAME_FORMAT, " "); - SERIAL_ECHO(buffer); - - return false; -} // report_pin_name #define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0) #define PWM_CASE(N,Z) \ @@ -682,16 +132,18 @@ static bool pwm_status(uint8_t pin) { switch(digitalPinToTimer(pin)) { #if defined(TCCR0A) && defined(COM0A1) - PWM_CASE(0,A); + #if defined (TIMER0A) + PWM_CASE(0,A); + #endif PWM_CASE(0,B); #endif #if defined(TCCR1A) && defined(COM1A1) PWM_CASE(1,A); PWM_CASE(1,B); - #if defined(COM1C1) && defined(TIMER1C) - PWM_CASE(1,C); - #endif + #if defined(COM1C1) && defined (TIMER1C) + PWM_CASE(1,C); + #endif #endif #if defined(TCCR2A) && defined(COM2A1) @@ -726,167 +178,230 @@ static bool pwm_status(uint8_t pin) { SERIAL_PROTOCOLPGM(" "); } // pwm_status -#define WGM_MAKE3(N) (((TCCR##N##B & _BV(WGM##N##2)) >> 1) | (TCCR##N##A & (_BV(WGM##N##0) | _BV(WGM##N##1)))) -#define WGM_MAKE4(N) (WGM_MAKE3(N) | (TCCR##N##B & _BV(WGM##N##3)) >> 1) -#define TIMER_PREFIX(T,L,N) do{ \ - WGM = WGM_MAKE##N(T); \ - SERIAL_PROTOCOLPGM(" TIMER"); \ - SERIAL_PROTOCOLPGM(STRINGIFY(T) STRINGIFY(L)); \ - SERIAL_PROTOCOLPAIR(" WGM: ", WGM); \ - SERIAL_PROTOCOLPAIR(" TIMSK" STRINGIFY(T) ": ", TIMSK##T); \ - }while(0) -#define WGM_TEST1 (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) -#define WGM_TEST2 (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) + +const uint8_t* const PWM_other[][3] PROGMEM = { + {&TCCR0A, &TCCR0B, &TIMSK0}, + {&TCCR1A, &TCCR1B, &TIMSK1}, + #if defined(TCCR2A) && defined(COM2A1) + {&TCCR2A, &TCCR2B, &TIMSK2}, + #endif + #if defined(TCCR3A) && defined(COM3A1) + {&TCCR3A, &TCCR3B, &TIMSK3}, + #endif + #ifdef TCCR4A + {&TCCR4A, &TCCR4B, &TIMSK4}, + #endif + #if defined(TCCR5A) && defined(COM5A1) + {&TCCR5A, &TCCR5B, &TIMSK5}, + #endif +}; + + +const uint8_t* const PWM_OCR[][3] PROGMEM = { + + #if defined (TIMER0A) + {&OCR0A,&OCR0B,0}, + #else + {0,&OCR0B,0}, + #endif + + #if defined(COM1C1) && defined (TIMER1C) + { (const uint8_t*) &OCR1A, (const uint8_t*) &OCR1B, (const uint8_t*) &OCR1C}, + #else + { (const uint8_t*) &OCR1A, (const uint8_t*) &OCR1B,0}, + #endif + + #if defined(TCCR2A) && defined(COM2A1) + {&OCR2A,&OCR2B,0}, + #endif + + #if defined(TCCR3A) && defined(COM3A1) + #if defined(COM3C1) + { (const uint8_t*) &OCR3A, (const uint8_t*) &OCR3B, (const uint8_t*) &OCR3C}, + #else + { (const uint8_t*) &OCR3A, (const uint8_t*) &OCR3B,0}, + #endif + #endif + + #ifdef TCCR4A + { (const uint8_t*) &OCR4A, (const uint8_t*) &OCR4B, (const uint8_t*) &OCR4C}, + #endif + + #if defined(TCCR5A) && defined(COM5A1) + { (const uint8_t*) &OCR5A, (const uint8_t*) &OCR5B, (const uint8_t*) &OCR5C}, + #endif +}; + + +#define TCCR_A(T) pgm_read_word(&PWM_other[T][0]) +#define TCCR_B(T) pgm_read_word(&PWM_other[T][1]) +#define TIMSK(T) pgm_read_word(&PWM_other[T][2]) +#define CS_0 0 +#define CS_1 1 +#define CS_2 2 +#define WGM_0 0 +#define WGM_1 1 +#define WGM_2 3 +#define WGM_3 4 +#define TOIE 0 + + +#define OCR_VAL(T, L) pgm_read_word(&PWM_OCR[T][L]) + static void err_is_counter() { - SERIAL_PROTOCOLPGM(" Can't be used as a PWM because of counter mode"); + SERIAL_PROTOCOLPGM(" non-standard PWM mode"); } static void err_is_interrupt() { - SERIAL_PROTOCOLPGM(" Can't be used as a PWM because it's being used as an interrupt"); + SERIAL_PROTOCOLPGM(" compare interrupt enabled "); } static void err_prob_interrupt() { - SERIAL_PROTOCOLPGM(" Probably can't be used as a PWM because counter/timer is being used as an interrupt"); + SERIAL_PROTOCOLPGM(" overflow interrupt enabled"); } static void can_be_used() { SERIAL_PROTOCOLPGM(" can be used as PWM "); } -static void pwm_details(uint8_t pin) { +void com_print(uint8_t N, uint8_t Z) { + uint8_t *TCCRA = (uint8_t*) TCCR_A(N); + SERIAL_PROTOCOLPGM(" COM"); + SERIAL_PROTOCOLCHAR(N + '0'); + switch(Z) { + case 'A' : + SERIAL_PROTOCOLPAIR("A: ", ((*TCCRA & (_BV(7) | _BV(6))) >> 6)); + break; + case 'B' : + SERIAL_PROTOCOLPAIR("B: ", ((*TCCRA & (_BV(5) | _BV(4))) >> 4)); + break; + case 'C' : + SERIAL_PROTOCOLPAIR("C: ", ((*TCCRA & (_BV(3) | _BV(2))) >> 2)); + break; + } +} + +void timer_prefix(uint8_t T, char L, uint8_t N){ // T - timer L - pwm n - WGM bit layout + char buffer[20]; // for the sprintf statements + uint8_t *TCCRB = (uint8_t*) TCCR_B(T); + uint8_t *TCCRA = (uint8_t*) TCCR_A(T); + uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1)))); + if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1); + + SERIAL_PROTOCOLPGM(" TIMER"); + SERIAL_PROTOCOLCHAR(T + '0'); + SERIAL_PROTOCOLCHAR(L); + SERIAL_PROTOCOLPGM(" "); + + if (N == 3) { + uint8_t *OCRVAL8 = (uint8_t*) OCR_VAL(T, L - 'A'); + PWM_PRINT(*OCRVAL8); + } + else { + uint16_t *OCRVAL16 = (uint16_t*) OCR_VAL(T, L - 'A'); + PWM_PRINT(*OCRVAL16); + } + SERIAL_PROTOCOLPAIR(" WGM: ", WGM); + com_print(T,L); + SERIAL_PROTOCOLPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) )); + + SERIAL_PROTOCOLPGM(" TCCR"); + SERIAL_PROTOCOLCHAR(T + '0'); + SERIAL_PROTOCOLPAIR("A: ", *TCCRA); + + SERIAL_PROTOCOLPGM(" TCCR"); + SERIAL_PROTOCOLCHAR(T + '0'); + SERIAL_PROTOCOLPAIR("B: ", *TCCRB); + + uint8_t *TMSK = (uint8_t*) TIMSK(T); + SERIAL_PROTOCOLPGM(" TIMSK"); + SERIAL_PROTOCOLCHAR(T + '0'); + SERIAL_PROTOCOLPAIR(": ", *TMSK); + + uint8_t OCIE = L - 'A' + 1; + if (N == 3) {if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter();} + else {if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter();} + if (TEST(*TMSK, OCIE)) err_is_interrupt(); + if (TEST(*TMSK, TOIE)) err_prob_interrupt(); +} + + + +static void pwm_details(uint8_t pin) { + char buffer[20]; // for the sprintf statements uint8_t WGM; switch(digitalPinToTimer(pin)) { + #if defined(TCCR0A) && defined(COM0A1) - case TIMER0A: - TIMER_PREFIX(0,A,3); - if (WGM_TEST1) err_is_counter(); - else if (TEST(TIMSK0, OCIE0A)) err_is_interrupt(); - else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt(); - else can_be_used(); - break; + + #if defined (TIMER0A) + case TIMER0A: + timer_prefix(0,'A',3); + break; + #endif case TIMER0B: - TIMER_PREFIX(0,B,3); - if (WGM_TEST1) err_is_counter(); - else if (TEST(TIMSK0, OCIE0B)) err_is_interrupt(); - else if (TEST(TIMSK0, TOIE0)) err_prob_interrupt(); - else can_be_used(); + timer_prefix(0,'B',3); break; #endif #if defined(TCCR1A) && defined(COM1A1) case TIMER1A: - TIMER_PREFIX(1,A,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK1, OCIE1A)) err_is_interrupt(); - else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(1,'A',4); break; case TIMER1B: - TIMER_PREFIX(1,B,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK1, OCIE1B)) err_is_interrupt(); - else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(1,'B',4); break; - #if defined(COM1C1) && defined(TIMER1C) + #if defined(COM1C1) && defined (TIMER1C) case TIMER1C: - TIMER_PREFIX(1,C,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK1, OCIE1C)) err_is_interrupt(); - else if (TIMSK1 & (_BV(TOIE1) | _BV(ICIE1))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(1,'C',4); break; #endif #endif #if defined(TCCR2A) && defined(COM2A1) case TIMER2A: - TIMER_PREFIX(2,A,3); - if (WGM_TEST1) err_is_counter(); - else if (TIMSK2 & (_BV(TOIE2) | _BV(OCIE2A))) err_is_interrupt(); - else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt(); - else can_be_used(); + timer_prefix(2,'A',3); break; case TIMER2B: - TIMER_PREFIX(2,B,3); - if (WGM_TEST1) err_is_counter(); - else if (TEST(TIMSK2, OCIE2B)) err_is_interrupt(); - else if (TEST(TIMSK2, TOIE2)) err_prob_interrupt(); - else can_be_used(); + timer_prefix(2,'B',3); break; #endif #if defined(TCCR3A) && defined(COM3A1) case TIMER3A: - TIMER_PREFIX(3,A,3); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK3, OCIE3A)) err_is_interrupt(); - else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(3,'A',4); break; case TIMER3B: - TIMER_PREFIX(3,B,3); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK3, OCIE3B)) err_is_interrupt(); - else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt(); - else can_be_used(); - break; - #ifdef COM3C1 - case TIMER3C: - TIMER_PREFIX(3,C,3); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK3, OCIE3C)) err_is_interrupt(); - else if (TIMSK3 & (_BV(TOIE3) | _BV(ICIE3))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(3,'B',4); break; + #if defined(COM3C1) + case TIMER3C: + timer_prefix(3,'C',4); + break; #endif #endif #ifdef TCCR4A case TIMER4A: - TIMER_PREFIX(4,A,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK4, OCIE4A)) err_is_interrupt(); - else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(4,'A',4); break; case TIMER4B: - TIMER_PREFIX(4,B,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK4, OCIE4B)) err_is_interrupt(); - else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(4,'B',4); break; case TIMER4C: - TIMER_PREFIX(4,C,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK4, OCIE4C)) err_is_interrupt(); - else if (TIMSK4 & (_BV(TOIE4) | _BV(ICIE4))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(4,'C',4); break; #endif #if defined(TCCR5A) && defined(COM5A1) case TIMER5A: - TIMER_PREFIX(5,A,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK5, OCIE5A)) err_is_interrupt(); - else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(5,'A',4); break; case TIMER5B: - TIMER_PREFIX(5,B,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK5, OCIE5B)) err_is_interrupt(); - else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(5,'B',4); break; case TIMER5C: - TIMER_PREFIX(5,C,4); - if (WGM_TEST2) err_is_counter(); - else if (TEST(TIMSK5, OCIE5C)) err_is_interrupt(); - else if (TIMSK5 & (_BV(TOIE5) | _BV(ICIE5))) err_prob_interrupt(); - else can_be_used(); + timer_prefix(5,'C',4); break; #endif @@ -894,65 +409,136 @@ static void pwm_details(uint8_t pin) { } SERIAL_PROTOCOLPGM(" "); -} // pwm_details -inline void report_pin_state(int8_t pin) { - SERIAL_ECHO((int)pin); - SERIAL_CHAR(' '); - bool dummy; - if (report_pin_name(pin, dummy)) { - if (pin_is_protected(pin)) - SERIAL_ECHOPGM(" (protected)"); - else { - SERIAL_ECHOPGM(" = "); - pinMode(pin, INPUT_PULLUP); - SERIAL_ECHO(digitalRead(pin)); - if (IS_ANALOG(pin)) { - SERIAL_CHAR(' '); SERIAL_CHAR('('); - SERIAL_ECHO(analogRead(pin - analogInputToDigitalPin(0))); - SERIAL_CHAR(')'); - } +// on pins that have two PWMs, print info on second PWM + #if AVR_ATmega2560_FAMILY || AVR_AT90USB1286_FAMILY + // looking for port B7 - PWMs 0A and 1C + if ( ('B' == digitalPinToPort(pin) + 64) && (0x80 == digitalPinToBitMask(pin))) { + #if !defined(TEENSYDUINO_IDE) + SERIAL_EOL; + SERIAL_PROTOCOLPGM (" . TIMER1C is also tied to this pin "); + timer_prefix(1,'C',4); + #else + SERIAL_EOL; + SERIAL_PROTOCOLPGM (" . TIMER0A is also tied to this pin "); + timer_prefix(0,'A',3); + #endif } - } - SERIAL_EOL; -} + #endif +} // pwm_details bool get_pinMode(int8_t pin) { return *portModeRegister(digitalPinToPort(pin)) & digitalPinToBitMask(pin); } +#if !defined(digitalRead_mod) // use Teensyduino's version of digitalRead - it doesn't disable the PWMs + int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed + uint8_t port = digitalPinToPort(pin); + return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW; + } +#endif + +void print_port(int8_t pin) { // print port number + #if defined(digitalPinToPort) + SERIAL_PROTOCOLPGM(" Port: "); + uint8_t x = digitalPinToPort(pin) + 64; + SERIAL_CHAR(x); + uint8_t temp = digitalPinToBitMask(pin); + for (x = '0'; (x < '9' && !(temp == 1)); x++){ + temp = temp >> 1; + } + SERIAL_CHAR(x); + #else + SERIAL_PROTOCOLPGM(" ") + #endif +} + + // pretty report with PWM info -inline void report_pin_state_extended(int8_t pin, bool ignore) { - +inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = true) { + uint8_t temp_char; + char *name_mem_pointer; char buffer[30]; // for the sprintf statements + bool found = false; + bool multi_name_pin = false; + for (uint8_t x = 0; x < n_array; x++) { // scan entire array and report all instances of this pin + if (pgm_read_byte(&pin_array[x][1]) == pin) { + if (found == true) multi_name_pin = true; + found = true; + if (multi_name_pin == false) { // report digitial and analog pin number only on the first time through + sprintf(buffer, "PIN:% 3d ", pin); // digital pin number + SERIAL_ECHO(buffer); + print_port(pin); + if (IS_ANALOG(pin)) { + sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number + SERIAL_ECHO(buffer); + } + else SERIAL_ECHOPGM(" "); // add padding if not an analog pin + } + else SERIAL_ECHOPGM(". "); // add padding if not the first instance found + name_mem_pointer = (char*) pgm_read_word(&pin_array[x][0]); + for (uint8_t y = 0; y < 28; y++) { // always print pin name + temp_char = pgm_read_byte(name_mem_pointer + y); + if (temp_char != 0) MYSERIAL.write(temp_char); + else { + for (uint8_t i = 0; i < 28 - y; i++) MYSERIAL.write(" "); + break; + } + } + if (pin_is_protected(pin) && !ignore) + SERIAL_ECHOPGM("protected "); + else { + if (!(pgm_read_byte(&pin_array[x][2]))) { + sprintf(buffer, "Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0))); + SERIAL_ECHO(buffer); + } + else { + if (!get_pinMode(pin)) { +// pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this + // because this could interfere with inductive/capacitive + // sensors (high impedance voltage divider) and with PT100 amplifier + SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin)); + } + else if (pwm_status(pin)) { + // do nothing + } + else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin)); + } + if (multi_name_pin == false && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report + } + SERIAL_EOL; + } // end of IF + } // end of for loop - // report pin number - sprintf(buffer, "PIN:% 3d ", pin); - SERIAL_ECHO(buffer); - - // report pin name - bool analog_pin; - report_pin_name(pin, analog_pin); - - // report pin state - if (pin_is_protected(pin) && !ignore) - SERIAL_ECHOPGM("protected "); - else { - if (analog_pin) { - sprintf(buffer, "Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0))); + if (found == false) { + sprintf(buffer, "PIN:% 3d ", pin); + SERIAL_ECHO(buffer); + print_port(pin); + if (IS_ANALOG(pin)) { + sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number SERIAL_ECHO(buffer); } - else { - if (!get_pinMode(pin)) { - pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin)); - } - else if (pwm_status(pin)) { - // do nothing - } - else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin)); + else SERIAL_ECHOPGM(" "); // add padding if not an analog pin + SERIAL_ECHOPGM(""); + if (get_pinMode(pin)) { + SERIAL_PROTOCOLPAIR(" Output = ", digitalRead_mod(pin)); } + else { + if (IS_ANALOG(pin)) { + sprintf(buffer, " Analog in =% 5d", analogRead(pin - analogInputToDigitalPin(0))); + SERIAL_ECHO(buffer); + } + else { + SERIAL_ECHOPGM(" "); // add padding if not an analog pin + } + SERIAL_PROTOCOLPAIR(" Input = ", digitalRead_mod(pin)); + } +// if (!pwm_status(pin)) SERIAL_ECHOPGM(" "); // add padding if it's not a PWM pin + if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report + SERIAL_EOL; } - - // report PWM capabilities - pwm_details(pin); - SERIAL_EOL; +} + +inline void report_pin_state(int8_t pin) { + + report_pin_state_extended(pin, false, false); + } diff --git a/Marlin/pinsDebug_list.h b/Marlin/pinsDebug_list.h new file mode 100644 index 000000000..9ce20fb13 --- /dev/null +++ b/Marlin/pinsDebug_list.h @@ -0,0 +1,775 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + + // Please update this list when adding new pins to Marlin. + // The order doesn't matter. + // Following this pattern is a must. + // If the new pin name is over 28 characters long then pinsDebug.h will need to be modified. + + // Pin list updated from 18 FEB 2017 RCBugfix branch - max length of pin name is 24 +#if defined(__FD) && __FD >= 0 + REPORT_NAME_DIGITAL(__FD, __LINE__ ) +#endif +#if defined(__FS) && __FS >= 0 + REPORT_NAME_DIGITAL(__FS, __LINE__ ) +#endif +#if defined(__GD) && __GD >= 0 + REPORT_NAME_DIGITAL(__GD, __LINE__ ) +#endif +#if defined(__GS) && __GS >= 0 + REPORT_NAME_DIGITAL(__GS, __LINE__ ) +#endif +#if PIN_EXISTS(AVR_MISO) + REPORT_NAME_DIGITAL(AVR_MISO_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(AVR_MOSI) + REPORT_NAME_DIGITAL(AVR_MOSI_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(AVR_SCK) + REPORT_NAME_DIGITAL(AVR_SCK_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(AVR_SS) + REPORT_NAME_DIGITAL(AVR_SS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(BEEPER) + REPORT_NAME_DIGITAL(BEEPER_PIN, __LINE__ ) +#endif +#if defined(BTN_CENTER) && BTN_CENTER >= 0 + REPORT_NAME_DIGITAL(BTN_CENTER, __LINE__ ) +#endif +#if defined(BTN_DOWN) && BTN_DOWN >= 0 + REPORT_NAME_DIGITAL(BTN_DOWN, __LINE__ ) +#endif +#if defined(BTN_DWN) && BTN_DWN >= 0 + REPORT_NAME_DIGITAL(BTN_DWN, __LINE__ ) +#endif +#if defined(BTN_EN1) && BTN_EN1 >= 0 + REPORT_NAME_DIGITAL(BTN_EN1, __LINE__ ) +#endif +#if defined(BTN_EN2) && BTN_EN2 >= 0 + REPORT_NAME_DIGITAL(BTN_EN2, __LINE__ ) +#endif +#if defined(BTN_ENC) && BTN_ENC >= 0 + REPORT_NAME_DIGITAL(BTN_ENC, __LINE__ ) +#endif +#if defined(BTN_HOME) && BTN_HOME >= 0 + REPORT_NAME_DIGITAL(BTN_HOME, __LINE__ ) +#endif +#if defined(BTN_LEFT) && BTN_LEFT >= 0 + REPORT_NAME_DIGITAL(BTN_LEFT, __LINE__ ) +#endif +#if defined(BTN_LFT) && BTN_LFT >= 0 + REPORT_NAME_DIGITAL(BTN_LFT, __LINE__ ) +#endif +#if defined(BTN_RIGHT) && BTN_RIGHT >= 0 + REPORT_NAME_DIGITAL(BTN_RIGHT, __LINE__ ) +#endif +#if defined(BTN_RT) && BTN_RT >= 0 + REPORT_NAME_DIGITAL(BTN_RT, __LINE__ ) +#endif +#if defined(BTN_UP) && BTN_UP >= 0 + REPORT_NAME_DIGITAL(BTN_UP, __LINE__ ) +#endif +#if PIN_EXISTS(CASE_LIGHT) + REPORT_NAME_DIGITAL(CASE_LIGHT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(CONTROLLERFAN) + REPORT_NAME_DIGITAL(CONTROLLERFAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(CUTOFF_RESET) + REPORT_NAME_DIGITAL(CUTOFF_RESET_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(CUTOFF_TEST) + REPORT_NAME_DIGITAL(CUTOFF_TEST_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(DAC_DISABLE) + REPORT_NAME_DIGITAL(DAC_DISABLE_PIN, __LINE__ ) +#endif +#if defined(DAC_STEPPER_VREF) && DAC_STEPPER_VREF >= 0 + REPORT_NAME_DIGITAL(DAC_STEPPER_VREF, __LINE__ ) +#endif +#if PIN_EXISTS(DEBUG) + REPORT_NAME_DIGITAL(DEBUG_PIN, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SCL) && DIGIPOTS_I2C_SCL >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SCL, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SDA_E0) && DIGIPOTS_I2C_SDA_E0 >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SDA_E0, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SDA_E1) && DIGIPOTS_I2C_SDA_E1 >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SDA_E1, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SDA_X) && DIGIPOTS_I2C_SDA_X >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SDA_X, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SDA_Y) && DIGIPOTS_I2C_SDA_Y >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SDA_Y, __LINE__ ) +#endif +#if defined(DIGIPOTS_I2C_SDA_Z) && DIGIPOTS_I2C_SDA_Z >= 0 + REPORT_NAME_DIGITAL(DIGIPOTS_I2C_SDA_Z, __LINE__ ) +#endif +#if PIN_EXISTS(DIGIPOTSS) + REPORT_NAME_DIGITAL(DIGIPOTSS_PIN, __LINE__ ) +#endif +#if defined(DOGLCD_A0) && DOGLCD_A0 >= 0 + REPORT_NAME_DIGITAL(DOGLCD_A0, __LINE__ ) +#endif +#if defined(DOGLCD_CS) && DOGLCD_CS >= 0 + REPORT_NAME_DIGITAL(DOGLCD_CS, __LINE__ ) +#endif +#if defined(DOGLCD_MOSI) && DOGLCD_MOSI >= 0 + REPORT_NAME_DIGITAL(DOGLCD_MOSI, __LINE__ ) +#endif +#if defined(DOGLCD_SCK) && DOGLCD_SCK >= 0 + REPORT_NAME_DIGITAL(DOGLCD_SCK, __LINE__ ) +#endif +#if PIN_EXISTS(E0_ATT) + REPORT_NAME_DIGITAL(E0_ATT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_AUTO_FAN) + REPORT_NAME_DIGITAL(E0_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_CS) + REPORT_NAME_DIGITAL(E0_CS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_DIR) + REPORT_NAME_DIGITAL(E0_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_ENABLE) + REPORT_NAME_DIGITAL(E0_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_MS1) + REPORT_NAME_DIGITAL(E0_MS1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_MS2) + REPORT_NAME_DIGITAL(E0_MS2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E0_STEP) + REPORT_NAME_DIGITAL(E0_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_AUTO_FAN) + REPORT_NAME_DIGITAL(E1_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_CS) + REPORT_NAME_DIGITAL(E1_CS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_DIR) + REPORT_NAME_DIGITAL(E1_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_ENABLE) + REPORT_NAME_DIGITAL(E1_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_MS1) + REPORT_NAME_DIGITAL(E1_MS1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_MS2) + REPORT_NAME_DIGITAL(E1_MS2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E1_STEP) + REPORT_NAME_DIGITAL(E1_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E2_AUTO_FAN) + REPORT_NAME_DIGITAL(E2_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E2_DIR) + REPORT_NAME_DIGITAL(E2_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E2_ENABLE) + REPORT_NAME_DIGITAL(E2_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E2_STEP) + REPORT_NAME_DIGITAL(E2_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E3_AUTO_FAN) + REPORT_NAME_DIGITAL(E3_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E3_DIR) + REPORT_NAME_DIGITAL(E3_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E3_ENABLE) + REPORT_NAME_DIGITAL(E3_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E3_STEP) + REPORT_NAME_DIGITAL(E3_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E4_DIR) + REPORT_NAME_DIGITAL(E4_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E4_ENABLE) + REPORT_NAME_DIGITAL(E4_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(E4_STEP) + REPORT_NAME_DIGITAL(E4_STEP_PIN, __LINE__ ) +#endif +#if defined(encrot0) && encrot0 >= 0 + REPORT_NAME_DIGITAL(encrot0, __LINE__ ) +#endif +#if defined(encrot1) && encrot1 >= 0 + REPORT_NAME_DIGITAL(encrot1, __LINE__ ) +#endif +#if defined(encrot2) && encrot2 >= 0 + REPORT_NAME_DIGITAL(encrot2, __LINE__ ) +#endif +#if defined(encrot3) && encrot3 >= 0 + REPORT_NAME_DIGITAL(encrot3, __LINE__ ) +#endif +#if defined(EXT_AUX_A0) && EXT_AUX_A0 >= 0 && EXT_AUX_A0 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(EXT_AUX_A0, __LINE__ ) +#endif +#if defined(EXT_AUX_A0) && EXT_AUX_A0 >= 0 && EXT_AUX_A0 >= NUM_ANALOG_INPUTS + REPORT_NAME_DIGITAL(EXT_AUX_A0, __LINE__ ) +#endif +#if defined(EXT_AUX_A0_IO) && EXT_AUX_A0_IO >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_A0_IO, __LINE__ ) +#endif +#if defined(EXT_AUX_A1) && EXT_AUX_A1 >= 0 && EXT_AUX_A1 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(EXT_AUX_A1, __LINE__ ) +#endif +#if defined(EXT_AUX_A1) && EXT_AUX_A1 >= 0 && EXT_AUX_A1 >= NUM_ANALOG_INPUTS + REPORT_NAME_DIGITAL(EXT_AUX_A1, __LINE__ ) +#endif +#if defined(EXT_AUX_A1_IO) && EXT_AUX_A1_IO >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_A1_IO, __LINE__ ) +#endif +#if defined(EXT_AUX_A2) && EXT_AUX_A2 >= 0 && EXT_AUX_A2 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(EXT_AUX_A2, __LINE__ ) +#endif +#if defined(EXT_AUX_A2) && EXT_AUX_A2 >= 0 && EXT_AUX_A2 >= NUM_ANALOG_INPUTS + REPORT_NAME_DIGITAL(EXT_AUX_A2, __LINE__ ) +#endif +#if defined(EXT_AUX_A2_IO) && EXT_AUX_A2_IO >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_A2_IO, __LINE__ ) +#endif +#if defined(EXT_AUX_A3) && EXT_AUX_A3 >= 0 && EXT_AUX_A3 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(EXT_AUX_A3, __LINE__ ) +#endif +#if defined(EXT_AUX_A3) && EXT_AUX_A3 >= 0 && EXT_AUX_A3 >= NUM_ANALOG_INPUTS + REPORT_NAME_DIGITAL(EXT_AUX_A3, __LINE__ ) +#endif +#if defined(EXT_AUX_A3_IO) && EXT_AUX_A3_IO >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_A3_IO, __LINE__ ) +#endif +#if defined(EXT_AUX_A4) && EXT_AUX_A4 >= 0 && EXT_AUX_A4 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(EXT_AUX_A4, __LINE__ ) +#endif +#if defined(EXT_AUX_A4) && EXT_AUX_A4 >= 0 && EXT_AUX_A4 >= NUM_ANALOG_INPUTS + REPORT_NAME_DIGITAL(EXT_AUX_A4, __LINE__ ) +#endif +#if defined(EXT_AUX_A4_IO) && EXT_AUX_A4_IO >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_A4_IO, __LINE__ ) +#endif +#if defined(EXT_AUX_PWM_D24) && EXT_AUX_PWM_D24 >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_PWM_D24, __LINE__ ) +#endif +#if defined(EXT_AUX_RX1_D2) && EXT_AUX_RX1_D2 >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_RX1_D2, __LINE__ ) +#endif +#if defined(EXT_AUX_SCL_D0) && EXT_AUX_SCL_D0 >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_SCL_D0, __LINE__ ) +#endif +#if defined(EXT_AUX_SDA_D1) && EXT_AUX_SDA_D1 >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_SDA_D1, __LINE__ ) +#endif +#if defined(EXT_AUX_TX1_D3) && EXT_AUX_TX1_D3 >= 0 + REPORT_NAME_DIGITAL(EXT_AUX_TX1_D3, __LINE__ ) +#endif +#if defined(EXTRUDER_0_AUTO_FAN) && EXTRUDER_0_AUTO_FAN >= 0 + REPORT_NAME_DIGITAL(EXTRUDER_0_AUTO_FAN, __LINE__ ) +#endif +#if defined(EXTRUDER_1_AUTO_FAN) && EXTRUDER_1_AUTO_FAN >= 0 + REPORT_NAME_DIGITAL(EXTRUDER_1_AUTO_FAN, __LINE__ ) +#endif +#if PIN_EXISTS(FAN) + REPORT_NAME_DIGITAL(FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(FAN1) + REPORT_NAME_DIGITAL(FAN1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(FAN2) + REPORT_NAME_DIGITAL(FAN2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(FIL_RUNOUT) + REPORT_NAME_DIGITAL(FIL_RUNOUT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(FILWIDTH) && FILWIDTH_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(FILWIDTH_PIN, __LINE__ ) +#endif +#if defined(GEN7_VERSION) && GEN7_VERSION >= 0 + REPORT_NAME_DIGITAL(GEN7_VERSION, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_0) + REPORT_NAME_DIGITAL(HEATER_0_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_1) + REPORT_NAME_DIGITAL(HEATER_1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_2) + REPORT_NAME_DIGITAL(HEATER_2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_3) + REPORT_NAME_DIGITAL(HEATER_3_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_4) + REPORT_NAME_DIGITAL(HEATER_4_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_5) + REPORT_NAME_DIGITAL(HEATER_5_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_6) + REPORT_NAME_DIGITAL(HEATER_6_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_7) + REPORT_NAME_DIGITAL(HEATER_7_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HEATER_BED) + REPORT_NAME_DIGITAL(HEATER_BED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(HOME) + REPORT_NAME_DIGITAL(HOME_PIN, __LINE__ ) +#endif +#if defined(I2C_SCL) && I2C_SCL >= 0 + REPORT_NAME_DIGITAL(I2C_SCL, __LINE__ ) +#endif +#if defined(I2C_SDA) && I2C_SDA >= 0 + REPORT_NAME_DIGITAL(I2C_SDA, __LINE__ ) +#endif +#if PIN_EXISTS(KILL) + REPORT_NAME_DIGITAL(KILL_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(LCD_BACKLIGHT) + REPORT_NAME_DIGITAL(LCD_BACKLIGHT_PIN, __LINE__ ) +#endif +#if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0 + REPORT_NAME_DIGITAL(LCD_CONTRAST, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_D4, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_D5, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_D6, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_D7, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_ENABLE, __LINE__ ) +#endif +#if PIN_EXISTS(LCD) + REPORT_NAME_DIGITAL(LCD_PINS_RS, __LINE__ ) +#endif +#if defined(LCD_SDSS) && LCD_SDSS >= 0 + REPORT_NAME_DIGITAL(LCD_SDSS, __LINE__ ) +#endif +#if PIN_EXISTS(LED) + REPORT_NAME_DIGITAL(LED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MAIN_VOLTAGE_MEASURE) && MAIN_VOLTAGE_MEASURE_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(MAIN_VOLTAGE_MEASURE_PIN, __LINE__ ) +#endif +#if defined(MAX6675_SS) && MAX6675_SS >= 0 + REPORT_NAME_DIGITAL(MAX6675_SS, __LINE__ ) +#endif +#if PIN_EXISTS(MISO) + REPORT_NAME_DIGITAL(MISO_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOSFET_A) + REPORT_NAME_DIGITAL(MOSFET_A_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOSFET_B) + REPORT_NAME_DIGITAL(MOSFET_B_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOSFET_C) + REPORT_NAME_DIGITAL(MOSFET_C_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOSFET_D) + REPORT_NAME_DIGITAL(MOSFET_D_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOSI) + REPORT_NAME_DIGITAL(MOSI_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + REPORT_NAME_DIGITAL(MOTOR_CURRENT_PWM_E_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + REPORT_NAME_DIGITAL(MOTOR_CURRENT_PWM_XY_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) + REPORT_NAME_DIGITAL(MOTOR_CURRENT_PWM_Z_PIN, __LINE__ ) +#endif +#if defined(NUM_TLCS) && NUM_TLCS >= 0 + REPORT_NAME_DIGITAL(NUM_TLCS, __LINE__ ) +#endif +#if PIN_EXISTS(ORIG_E0_AUTO_FAN) + REPORT_NAME_DIGITAL(ORIG_E0_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(ORIG_E1_AUTO_FAN) + REPORT_NAME_DIGITAL(ORIG_E1_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(ORIG_E2_AUTO_FAN) + REPORT_NAME_DIGITAL(ORIG_E2_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(ORIG_E3_AUTO_FAN) + REPORT_NAME_DIGITAL(ORIG_E3_AUTO_FAN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(PHOTOGRAPH) + REPORT_NAME_DIGITAL(PHOTOGRAPH_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(PS_ON) + REPORT_NAME_DIGITAL(PS_ON_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(PWM_1) + REPORT_NAME_DIGITAL(PWM_1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(PWM_2) + REPORT_NAME_DIGITAL(PWM_2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(RAMPS_D10) + REPORT_NAME_DIGITAL(RAMPS_D10_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(RAMPS_D8) + REPORT_NAME_DIGITAL(RAMPS_D8_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(RAMPS_D9) + REPORT_NAME_DIGITAL(RAMPS_D9_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(RX_ENABLE) + REPORT_NAME_DIGITAL(RX_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SAFETY_TRIGGERED) + REPORT_NAME_DIGITAL(SAFETY_TRIGGERED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SCK) + REPORT_NAME_DIGITAL(SCK_PIN, __LINE__ ) +#endif +#if defined(SCL) && SCL >= 0 + REPORT_NAME_DIGITAL(SCL, __LINE__ ) +#endif +#if PIN_EXISTS(SD_DETECT) + REPORT_NAME_DIGITAL(SD_DETECT_PIN, __LINE__ ) +#endif +#if defined(SDA) && SDA >= 0 + REPORT_NAME_DIGITAL(SDA, __LINE__ ) +#endif +#if defined(SDPOWER) && SDPOWER >= 0 + REPORT_NAME_DIGITAL(SDPOWER, __LINE__ ) +#endif +#if defined(SDSS) && SDSS >= 0 + REPORT_NAME_DIGITAL(SDSS, __LINE__ ) +#endif +#if PIN_EXISTS(SERVO0) + REPORT_NAME_DIGITAL(SERVO0_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SERVO1) + REPORT_NAME_DIGITAL(SERVO1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SERVO2) + REPORT_NAME_DIGITAL(SERVO2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SERVO3) + REPORT_NAME_DIGITAL(SERVO3_PIN, __LINE__ ) +#endif +#if defined(SHIFT_CLK) && SHIFT_CLK >= 0 + REPORT_NAME_DIGITAL(SHIFT_CLK, __LINE__ ) +#endif +#if defined(SHIFT_EN) && SHIFT_EN >= 0 + REPORT_NAME_DIGITAL(SHIFT_EN, __LINE__ ) +#endif +#if defined(SHIFT_LD) && SHIFT_LD >= 0 + REPORT_NAME_DIGITAL(SHIFT_LD, __LINE__ ) +#endif +#if defined(SHIFT_OUT) && SHIFT_OUT >= 0 + REPORT_NAME_DIGITAL(SHIFT_OUT, __LINE__ ) +#endif +#if PIN_EXISTS(SLED) + REPORT_NAME_DIGITAL(SLED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SLEEP_WAKE) + REPORT_NAME_DIGITAL(SLEEP_WAKE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SOL1) + REPORT_NAME_DIGITAL(SOL1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SOL2) + REPORT_NAME_DIGITAL(SOL2_PIN, __LINE__ ) +#endif +#if defined(SPARE_IO) && SPARE_IO >= 0 + REPORT_NAME_DIGITAL(SPARE_IO, __LINE__ ) +#endif +#if PIN_EXISTS(SPINDLE_DIR) + REPORT_NAME_DIGITAL(SPINDLE_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SPINDLE_LASER_ENABLE) + REPORT_NAME_DIGITAL(SPINDLE_LASER_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SPINDLE_SPEED_LASER_POWER) + REPORT_NAME_DIGITAL(SPINDLE_SPEED_LASER_POWER_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SR_CLK) + REPORT_NAME_DIGITAL(SR_CLK_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SR_DATA) + REPORT_NAME_DIGITAL(SR_DATA_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SR_STROBE) + REPORT_NAME_DIGITAL(SR_STROBE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SS) + REPORT_NAME_DIGITAL(SS_PIN, __LINE__ ) +#endif +#if defined(STAT_LED_BLUE) && STAT_LED_BLUE >= 0 + REPORT_NAME_DIGITAL(STAT_LED_BLUE, __LINE__ ) +#endif +#if PIN_EXISTS(STAT_LED_BLUE) + REPORT_NAME_DIGITAL(STAT_LED_BLUE_PIN, __LINE__ ) +#endif +#if defined(STAT_LED_RED) && STAT_LED_RED >= 0 + REPORT_NAME_DIGITAL(STAT_LED_RED, __LINE__ ) +#endif +#if PIN_EXISTS(STAT_LED_RED) + REPORT_NAME_DIGITAL(STAT_LED_RED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(STEPPER_RESET) + REPORT_NAME_DIGITAL(STEPPER_RESET_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(SUICIDE) + REPORT_NAME_DIGITAL(SUICIDE_PIN, __LINE__ ) +#endif +#if defined(TC1) && TC1 >= 0 && TC1 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TC1, __LINE__ ) +#endif +#if defined(TC2) && TC2 >= 0 && TC2 < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TC2, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_0) && TEMP_0_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_0_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_1) && TEMP_1_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_2) && TEMP_2_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_3) && TEMP_3_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_3_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_4) && TEMP_4_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_4_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_BED) && TEMP_BED_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_BED_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_CHAMBER) && TEMP_CHAMBER_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_CHAMBER_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TEMP_X) && TEMP_X_PIN < NUM_ANALOG_INPUTS + REPORT_NAME_ANALOG(TEMP_X_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(THERMO_DO) + REPORT_NAME_DIGITAL(THERMO_DO_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(THERMO_SCK) + REPORT_NAME_DIGITAL(THERMO_SCK_PIN, __LINE__ ) +#endif +#if defined(TLC_BLANK_BIT) && TLC_BLANK_BIT >= 0 + REPORT_NAME_DIGITAL(TLC_BLANK_BIT, __LINE__ ) +#endif +#if PIN_EXISTS(TLC_BLANK) + REPORT_NAME_DIGITAL(TLC_BLANK_PIN, __LINE__ ) +#endif +#if defined(TLC_CLOCK_BIT) && TLC_CLOCK_BIT >= 0 + REPORT_NAME_DIGITAL(TLC_CLOCK_BIT, __LINE__ ) +#endif +#if PIN_EXISTS(TLC_CLOCK) + REPORT_NAME_DIGITAL(TLC_CLOCK_PIN, __LINE__ ) +#endif +#if defined(TLC_DATA_BIT) && TLC_DATA_BIT >= 0 + REPORT_NAME_DIGITAL(TLC_DATA_BIT, __LINE__ ) +#endif +#if PIN_EXISTS(TLC_DATA) + REPORT_NAME_DIGITAL(TLC_DATA_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TLC_XLAT) + REPORT_NAME_DIGITAL(TLC_XLAT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_0) + REPORT_NAME_DIGITAL(TOOL_0_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_0_PWM) + REPORT_NAME_DIGITAL(TOOL_0_PWM_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_1) + REPORT_NAME_DIGITAL(TOOL_1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_1_PWM) + REPORT_NAME_DIGITAL(TOOL_1_PWM_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_2) + REPORT_NAME_DIGITAL(TOOL_2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_2_PWM) + REPORT_NAME_DIGITAL(TOOL_2_PWM_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_3) + REPORT_NAME_DIGITAL(TOOL_3_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_3_PWM) + REPORT_NAME_DIGITAL(TOOL_3_PWM_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TOOL_PWM) + REPORT_NAME_DIGITAL(TOOL_PWM_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(TX_ENABLE) + REPORT_NAME_DIGITAL(TX_ENABLE_PIN, __LINE__ ) +#endif +#if defined(UI1) && UI1 >= 0 + REPORT_NAME_DIGITAL(UI1, __LINE__ ) +#endif +#if defined(UI2) && UI2 >= 0 + REPORT_NAME_DIGITAL(UI2, __LINE__ ) +#endif +#if defined(UNUSED_PWM) && UNUSED_PWM >= 0 + REPORT_NAME_DIGITAL(UNUSED_PWM, __LINE__ ) +#endif +#if PIN_EXISTS(X_ATT) + REPORT_NAME_DIGITAL(X_ATT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_CS) + REPORT_NAME_DIGITAL(X_CS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_DIR) + REPORT_NAME_DIGITAL(X_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_ENABLE) + REPORT_NAME_DIGITAL(X_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_MAX) + REPORT_NAME_DIGITAL(X_MAX_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_MIN) + REPORT_NAME_DIGITAL(X_MIN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_MS1) + REPORT_NAME_DIGITAL(X_MS1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_MS2) + REPORT_NAME_DIGITAL(X_MS2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_STEP) + REPORT_NAME_DIGITAL(X_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X_STOP) + REPORT_NAME_DIGITAL(X_STOP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X2_DIR) + REPORT_NAME_DIGITAL(X2_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X2_ENABLE) + REPORT_NAME_DIGITAL(X2_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(X2_STEP) + REPORT_NAME_DIGITAL(X2_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_ATT) + REPORT_NAME_DIGITAL(Y_ATT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_CS) + REPORT_NAME_DIGITAL(Y_CS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_DIR) + REPORT_NAME_DIGITAL(Y_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_ENABLE) + REPORT_NAME_DIGITAL(Y_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_MAX) + REPORT_NAME_DIGITAL(Y_MAX_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_MIN) + REPORT_NAME_DIGITAL(Y_MIN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_MS1) + REPORT_NAME_DIGITAL(Y_MS1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_MS2) + REPORT_NAME_DIGITAL(Y_MS2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_STEP) + REPORT_NAME_DIGITAL(Y_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y_STOP) + REPORT_NAME_DIGITAL(Y_STOP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y2_DIR) + REPORT_NAME_DIGITAL(Y2_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y2_ENABLE) + REPORT_NAME_DIGITAL(Y2_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Y2_STEP) + REPORT_NAME_DIGITAL(Y2_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_ATT) + REPORT_NAME_DIGITAL(Z_ATT_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_CS) + REPORT_NAME_DIGITAL(Z_CS_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_DIR) + REPORT_NAME_DIGITAL(Z_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_ENABLE) + REPORT_NAME_DIGITAL(Z_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_MAX) + REPORT_NAME_DIGITAL(Z_MAX_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_MIN) + REPORT_NAME_DIGITAL(Z_MIN_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_MIN_PROBE) + REPORT_NAME_DIGITAL(Z_MIN_PROBE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_MS1) + REPORT_NAME_DIGITAL(Z_MS1_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_MS2) + REPORT_NAME_DIGITAL(Z_MS2_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_STEP) + REPORT_NAME_DIGITAL(Z_STEP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z_STOP) + REPORT_NAME_DIGITAL(Z_STOP_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z2_DIR) + REPORT_NAME_DIGITAL(Z2_DIR_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z2_ENABLE) + REPORT_NAME_DIGITAL(Z2_ENABLE_PIN, __LINE__ ) +#endif +#if PIN_EXISTS(Z2_STEP) + REPORT_NAME_DIGITAL(Z2_STEP_PIN, __LINE__ ) +#endif