Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 13, 2022
1 parent 7428a4d commit 03ece3e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,18 @@ const XrefInfo pin_xref[] PROGMEM = {
#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1')
#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 )
#define PORT_NUM(P) ((P >> 4) & 0x0007)
#define PORT_ALPHA(P) ('A' + (P >> 4))
#define PORT_ALPHA(P) ('A' + (P >> 4))

/**
* Translation of routines & variables used by pinsDebug.h
*/

#if PA0 >= NUM_DIGITAL_PINS
#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS
#define HAS_HIGH_ANALOG_PINS 1
#endif
#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1)
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)
#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 VALID_PIN(P) WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
#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 @@ -168,7 +169,7 @@ bool GET_PINMODE(const pin_t Ard_num) {
}

int8_t digital_pin_to_analog_pin(const pin_t Ard_num) {
if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_FIRST + NUM_ANALOG_INPUTS - 1))
if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))
return Ard_num - NUM_ANALOG_FIRST;

const uint32_t ind = digitalPinToAnalogInput(Ard_num);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/TEENSY40_41/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
#define GET_ARRAY_PIN(p) pin_array[p].pin
#define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital
#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0)
#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
#define pwm_status(pin) HAL_pwm_status(pin)
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 : TERN(HAS_HIGH_ANALOG_PINS, NUM_DIGITAL_PINS, NUMBER_PINS_TOTAL) - 1;
last_pin = parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1;

if (first_pin > last_pin) return;

Expand Down

0 comments on commit 03ece3e

Please sign in to comment.