mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-01-22 17:52:57 +00:00
🔧 Simplify sensitive pins (#27219)
This commit is contained in:
parent
b6284c9f01
commit
c95825a0ff
5 changed files with 552 additions and 981 deletions
|
@ -159,7 +159,7 @@ typedef Servo hal_servo_t;
|
|||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#define HAL_SENSITIVE_PINS 0, 1,
|
||||
#define HAL_SENSITIVE_PINS 0, 1
|
||||
|
||||
#ifdef __AVR_AT90USB1286__
|
||||
#define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
|
||||
|
|
|
@ -159,7 +159,7 @@ constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) {
|
|||
// Parse a G-code word into a pin index
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||
// P0.6 thru P0.9 are for the onboard SD card
|
||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09,
|
||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
|
|
|
@ -30,6 +30,3 @@
|
|||
#undef F_CPU
|
||||
#define F_CPU BOARD_F_CPU
|
||||
#endif
|
||||
|
||||
// The Sensitive Pins array is not optimizable
|
||||
#define RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
|
|
|
@ -308,23 +308,12 @@ bool wait_for_heatup = false;
|
|||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnarrowing"
|
||||
|
||||
#ifndef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
template <pin_t ...D>
|
||||
constexpr pin_t OnlyPins<_SP_END, D...>::table[sizeof...(D)];
|
||||
#endif
|
||||
|
||||
bool pin_is_protected(const pin_t pin) {
|
||||
#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS };
|
||||
const size_t pincount = COUNT(sensitive_pins);
|
||||
#else
|
||||
static constexpr size_t pincount = OnlyPins<SENSITIVE_PINS>::size;
|
||||
static const pin_t (&sensitive_pins)[pincount] PROGMEM = OnlyPins<SENSITIVE_PINS>::table;
|
||||
#endif
|
||||
for (uint8_t i = 0; i < pincount; ++i) {
|
||||
const pin_t * const pptr = &sensitive_pins[i];
|
||||
if (pin == (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(pptr) : (pin_t)pgm_read_byte(pptr))) return true;
|
||||
}
|
||||
#define pgm_read_pin(P) (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(P) : (pin_t)pgm_read_byte(P))
|
||||
for (uint8_t i = 0; i < COUNT(sensitive_dio); ++i)
|
||||
if (pin == pgm_read_pin(&sensitive_dio[i])) return true;
|
||||
for (uint8_t i = 0; i < COUNT(sensitive_aio); ++i)
|
||||
if (pin == analogInputToDigitalPin(pgm_read_pin(&sensitive_dio[i]))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue