Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch stm32 pins_debugging #22896

Merged
merged 11 commits into from
Apr 21, 2022
12 changes: 7 additions & 5 deletions Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const XrefInfo pin_xref[] PROGMEM = {
/**
* Translation of routines & variables used by pinsDebug.h
*/
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL)
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
#define PRINT_PIN(Q)
Expand Down Expand Up @@ -196,10 +196,12 @@ void port_print(const pin_t Ard_num) {
SERIAL_ECHO_SP(7);

// Print number to be used with M42
sprintf_P(buffer, PSTR(" M42 P%d "), Ard_num);
SERIAL_ECHO(buffer);
if (Ard_num < 10) SERIAL_CHAR(' ');
if (Ard_num < 100) SERIAL_CHAR(' ');
int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1);
if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8;
SERIAL_ECHOPGM(" M42 P", calc_p);
SERIAL_CHAR(' ');
if (calc_p < 10) SERIAL_CHAR(' ');
if (calc_p < 100) SERIAL_CHAR(' ');
}

bool pwm_status(const pin_t Ard_num) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M43.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void GcodeSuite::M43() {

// 'P' Get the range of pins to test or watch
uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
last_pin = parser.seenval('P') ? first_pin : NUMBER_PINS_TOTAL - 1;
last_pin = parser.seenval('P') ? first_pin : TERN(HAL_STM32, NUM_DIGITAL_PINS, NUMBER_PINS_TOTAL) - 1;
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

if (first_pin > last_pin) return;

Expand Down