From 6b1cf99066fdd4a104ff0b8378480fb34d707462 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 24 Jan 2019 16:14:02 +0100 Subject: [PATCH] conditional compilation updated --- Firmware/Marlin_main.cpp | 4 ++-- Firmware/fsensor.cpp | 34 ++++++++++++++++++---------------- Firmware/fsensor.h | 4 ++-- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 066eef27..ee1ee55a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1481,9 +1481,9 @@ void setup() setup_fan_interrupt(); #endif //DEBUG_DISABLE_FANCHECK -#ifdef FILAMENT_SENSOR +#ifdef PAT9125 fsensor_setup_interrupt(); -#endif //FILAMENT_SENSOR +#endif //PAT9125 for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); #ifndef DEBUG_DISABLE_STARTMSGS diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index c5f8ee40..c0654ee2 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -388,7 +388,7 @@ bool fsensor_oq_result(void) printf_P(_N("fsensor_oq_result %S\n"), (res?_OK:_NG)); return res; } - +#ifdef PAT9125 ISR(FSENSOR_INT_PIN_VECT) { if (mmu_enabled || ir_sensor_detected) return; @@ -475,6 +475,23 @@ ISR(FSENSOR_INT_PIN_VECT) return; } +void fsensor_setup_interrupt(void) +{ + + pinMode(FSENSOR_INT_PIN, OUTPUT); + digitalWrite(FSENSOR_INT_PIN, LOW); + fsensor_int_pin_old = 0; + + //pciSetup(FSENSOR_INT_PIN); +// !!! "pciSetup()" does not provide the correct results for some MCU pins +// so interrupt registers settings: + FSENSOR_INT_PIN_PCMSK_REG |= bit(FSENSOR_INT_PIN_PCMSK_BIT); // enable corresponding PinChangeInterrupt (individual pin) + PCIFR |= bit(FSENSOR_INT_PIN_PCICR_BIT); // clear previous occasional interrupt (set of pins) + PCICR |= bit(FSENSOR_INT_PIN_PCICR_BIT); // enable corresponding PinChangeInterrupt (set of pins) +} + +#endif //PAT9125 + void fsensor_st_block_begin(block_t* bl) { if (!fsensor_enabled) return; @@ -569,18 +586,3 @@ void fsensor_update(void) } #endif //PAT9125 } - -void fsensor_setup_interrupt(void) -{ - - pinMode(FSENSOR_INT_PIN, OUTPUT); - digitalWrite(FSENSOR_INT_PIN, LOW); - fsensor_int_pin_old = 0; - - //pciSetup(FSENSOR_INT_PIN); -// !!! "pciSetup()" does not provide the correct results for some MCU pins -// so interrupt registers settings: - FSENSOR_INT_PIN_PCMSK_REG |= bit(FSENSOR_INT_PIN_PCMSK_BIT); // enable corresponding PinChangeInterrupt (individual pin) - PCIFR |= bit(FSENSOR_INT_PIN_PCICR_BIT); // clear previous occasional interrupt (set of pins) - PCICR |= bit(FSENSOR_INT_PIN_PCICR_BIT); // enable corresponding PinChangeInterrupt (set of pins) -} diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index 3237b5a7..71922fbf 100644 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -35,13 +35,13 @@ extern bool fsensor_autoload_enabled; extern void fsensor_autoload_set(bool State); extern void fsensor_update(void); - +#ifdef PAT9125 //! setup pin-change interrupt extern void fsensor_setup_interrupt(void); //! @name autoload support //! @{ -#ifdef PAT9125 + extern void fsensor_autoload_check_start(void); extern void fsensor_autoload_check_stop(void); #endif //PAT9125