Clean up pins debugging

This commit is contained in:
Scott Lahteine 2020-03-05 17:56:17 -06:00
parent 6cd99e6a77
commit ca4423ed2a
3 changed files with 71 additions and 40 deletions

View File

@ -61,12 +61,12 @@ inline void toggle_pins() {
pin_t pin = GET_PIN_MAP_PIN_M43(i);
if (!VALID_PIN(pin)) continue;
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
report_pin_state_extended(pin, ignore_protection, true, PSTR("Untouched "));
SERIAL_EOL();
}
else {
watchdog_refresh();
report_pin_state_extended(pin, ignore_protection, true, "Pulsing ");
report_pin_state_extended(pin, ignore_protection, true, PSTR("Pulsing "));
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
if (pin == TEENSY_E2) {
SET_OUTPUT(TEENSY_E2);

View File

@ -862,6 +862,43 @@
#define E7_ENABLE_PIN -1
#endif
//
// Destroy unused CS pins
//
#if !AXIS_HAS_SPI(X)
#undef X_CS_PIN
#endif
#if !AXIS_HAS_SPI(Y)
#undef Y_CS_PIN
#endif
#if !AXIS_HAS_SPI(Z)
#undef Z_CS_PIN
#endif
#if !AXIS_HAS_SPI(E0)
#undef E0_CS_PIN
#endif
#if !AXIS_HAS_SPI(E1)
#undef E1_CS_PIN
#endif
#if !AXIS_HAS_SPI(E2)
#undef E2_CS_PIN
#endif
#if !AXIS_HAS_SPI(E3)
#undef E3_CS_PIN
#endif
#if !AXIS_HAS_SPI(E4)
#undef E4_CS_PIN
#endif
#if !AXIS_HAS_SPI(E5)
#undef E5_CS_PIN
#endif
#if !AXIS_HAS_SPI(E6)
#undef E6_CS_PIN
#endif
#if !AXIS_HAS_SPI(E7)
#undef E7_CS_PIN
#endif
#ifndef X_CS_PIN
#define X_CS_PIN -1
#endif
@ -1170,6 +1207,9 @@
#if HAS_FILAMENT_SENSOR
#define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
#else
#undef FIL_RUNOUT_PIN
#undef FIL_RUNOUT1_PIN
#endif
#ifndef LCD_PINS_D4

View File

@ -207,17 +207,32 @@ static void print_input_or_output(const bool isout) {
}
// pretty report with PWM info
inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = false, const char *start_string = "") {
inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, PGM_P const start_string=nullptr) {
char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
bool found = false, multi_name_pin = false;
auto alt_pin_echo = [](const pin_t &pin) {
#if AVR_AT90USB1286_FAMILY
// Use FastIO for pins Teensy doesn't expose
if (pin == 46) {
print_input_or_output(IS_OUTPUT(46));
SERIAL_CHAR('0' + READ(46));
return false;
}
else if (pin == 47) {
print_input_or_output(IS_OUTPUT(47));
SERIAL_CHAR('0' + READ(47));
return false;
}
#endif
return true;
};
for (uint8_t x = 0; x < COUNT(pin_array); x++) { // scan entire array and report all instances of this pin
if (GET_ARRAY_PIN(x) == pin) {
if (found) multi_name_pin = true;
found = true;
if (!multi_name_pin) { // report digital and analog pin number only on the first time through
sprintf_P(buffer, PSTR("%sPIN: "), start_string); // digital pin number
SERIAL_ECHO(buffer);
if (!found) { // report digital and analog pin number only on the first time through
if (start_string) serialprintPGM(start_string);
serialprintPGM(PSTR("PIN: "));
PRINT_PIN(pin);
PRINT_PORT(pin);
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
@ -228,27 +243,14 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
}
else {
SERIAL_CHAR('.');
SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string)); // add padding if not the first instance found
SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(start_string) : 0)); // add padding if not the first instance found
}
PRINT_ARRAY_NAME(x);
if (extended) {
if (pin_is_protected(pin) && !ignore)
SERIAL_ECHOPGM("protected ");
else {
#if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46 || pin == 47) {
if (pin == 46) {
print_input_or_output(IS_OUTPUT(46));
SERIAL_CHAR('0' + READ(46));
}
else if (pin == 47) {
print_input_or_output(IS_OUTPUT(47));
SERIAL_CHAR('0' + READ(47));
}
}
else
#endif
{
if (alt_pin_echo(pin)) {
if (!GET_ARRAY_IS_DIGITAL(x)) {
sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
SERIAL_ECHO(buffer);
@ -274,12 +276,14 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
}
}
SERIAL_EOL();
multi_name_pin = found;
found = true;
} // end of IF
} // end of for loop
if (!found) {
sprintf_P(buffer, PSTR("%sPIN: "), start_string);
SERIAL_ECHO(buffer);
if (start_string) serialprintPGM(start_string);
serialprintPGM(PSTR("PIN: "));
PRINT_PIN(pin);
PRINT_PORT(pin);
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
@ -290,21 +294,8 @@ inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = fa
SERIAL_ECHO_SP(8); // add padding if not an analog pin
SERIAL_ECHOPGM("<unused/unknown>");
if (extended) {
#if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46 || pin == 47) {
SERIAL_ECHO_SP(12);
if (pin == 46) {
print_input_or_output(IS_OUTPUT(46));
SERIAL_CHAR('0' + READ(46));
}
else {
print_input_or_output(IS_OUTPUT(47));
SERIAL_CHAR('0' + READ(47));
}
}
else
#endif
{
if (alt_pin_echo(pin)) {
if (pwm_status(pin)) {
// do nothing
}