Skip to content

Commit

Permalink
PINS_DEBUGGING support on STM32G0B1RE
Browse files Browse the repository at this point in the history
Resolves issue MarlinFirmware#23386 by adding missing NUM_ANALOG_FIRST.

Updates VALID_PIN so analog pins starting at 0xc0; which is
great than NUM_PINS_TOTAL; are not filtered out of M43 output.

Updates "M42 P" output to start at P0 instead of P4.  First
11 analog pins are printed correctly but A11 is incorrectly
shown as P19 instead of P26.
  • Loading branch information
cbagwell committed Sep 10, 2022
1 parent 45cf997 commit 7428a4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const XrefInfo pin_xref[] PROGMEM = {
#define HAS_HIGH_ANALOG_PINS 1
#endif
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)
#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL)
#define VALID_PIN(ANUM) (((ANUM) >= 0 && (ANUM) < NUM_DIGITAL_PINS) TERN_(HAS_HIGH_ANALOG_PINS, || ((ANUM) >= NUM_ANALOG_FIRST && (ANUM) < NUM_ANALOG_FIRST+NUM_ANALOG_INPUTS)))
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
#define PRINT_PIN(Q)
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
Expand Down Expand Up @@ -206,8 +206,11 @@ void port_print(const pin_t Ard_num) {
SERIAL_ECHO_SP(7);

// Print number to be used with M42
int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1);
if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8;
int calc_p = Ard_num;
if (Ard_num > NUM_DIGITAL_PINS) {
calc_p -= NUM_ANALOG_FIRST;
if (calc_p > 7) calc_p += 8;
}
SERIAL_ECHOPGM(" M42 P", calc_p);
SERIAL_CHAR(' ');
if (calc_p < 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#define NUM_DIGITAL_PINS 62
#define NUM_REMAP_PINS 2
#define NUM_ANALOG_INPUTS 16
#define NUM_ANALOG_FIRST PA0

// SPI definitions
#ifndef PIN_SPI_SS
Expand Down

0 comments on commit 7428a4d

Please sign in to comment.