@ -54,7 +54,7 @@ void endstop_ISR(void) { endstops.update(); }
# undef digitalPinToPCICR
# define digitalPinToPCICR(p) ( WITHIN(p, 10, 15) || \
WITHIN ( p , 50 , 53 ) | | \
WITHIN ( p , 62 , 69 ) ? & PCICR : ( uint8_t * ) 0 )
WITHIN ( p , 62 , 69 ) ? & PCICR : nullptr )
# undef digitalPinToPCICRbit
# define digitalPinToPCICRbit(p) ( WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? 0 : \
WITHIN ( p , 14 , 15 ) ? 1 : \
@ -64,7 +64,7 @@ void endstop_ISR(void) { endstops.update(); }
# define digitalPinToPCMSK(p) ( WITHIN(p, 10, 13) || WITHIN(p, 50, 53) ? &PCMSK0 : \
WITHIN ( p , 14 , 15 ) ? & PCMSK1 : \
WITHIN ( p , 62 , 69 ) ? & PCMSK2 : \
( uint8_t * ) 0 )
nullptr )
# undef digitalPinToPCMSKbit
# define digitalPinToPCMSKbit(p) ( WITHIN(p, 10, 13) ? ((p) - 6) : \
( p ) = = 14 | | ( p ) = = 51 ? 2 : \
@ -78,9 +78,11 @@ void endstop_ISR(void) { endstops.update(); }
// Install Pin change interrupt for a pin. Can be called multiple times.
void pciSetup ( const int8_t pin ) {
SBI ( * digitalPinToPCMSK ( pin ) , digitalPinToPCMSKbit ( pin ) ) ; // enable pin
SBI ( PCIFR , digitalPinToPCICRbit ( pin ) ) ; // clear any outstanding interrupt
SBI ( PCICR , digitalPinToPCICRbit ( pin ) ) ; // enable interrupt for the group
if ( digitalPinToPCMSK ( pin ) ! = nullptr ) {
SBI ( * digitalPinToPCMSK ( pin ) , digitalPinToPCMSKbit ( pin ) ) ; // enable pin
SBI ( PCIFR , digitalPinToPCICRbit ( pin ) ) ; // clear any outstanding interrupt
SBI ( PCICR , digitalPinToPCICRbit ( pin ) ) ; // enable interrupt for the group
}
}
// Handlers for pin change interrupts
@ -107,7 +109,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( X_MAX_PIN ) , endstop_ISR , CHANGE ) ; // assign it
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( X_MAX_PIN ) ! = NULL , " X_MAX_PIN is not interrupt-capable " ) ; // if pin has no pin change interrupt - error
static_assert ( digitalPinToPCICR ( X_MAX_PIN ) , " X_MAX_PIN is not interrupt-capable " ) ; // if pin has no pin change interrupt - error
pciSetup ( X_MAX_PIN ) ; // assign it
# endif
# endif
@ -117,7 +119,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( X_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( X_MIN_PIN ) ! = NULL , " X_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( X_MIN_PIN ) , " X_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( X_MIN_PIN ) ;
# endif
# endif
@ -127,7 +129,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Y_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Y_MAX_PIN ) ! = NULL , " Y_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Y_MAX_PIN ) , " Y_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( Y_MAX_PIN ) ;
# endif
# endif
@ -137,7 +139,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Y_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Y_MIN_PIN ) ! = NULL , " Y_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Y_MIN_PIN ) , " Y_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( Y_MIN_PIN ) ;
# endif
# endif
@ -147,7 +149,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z_MAX_PIN ) ! = NULL , " Z_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z_MAX_PIN ) , " Z_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( Z_MAX_PIN ) ;
# endif
# endif
@ -157,7 +159,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z_MIN_PIN ) ! = NULL , " Z_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z_MIN_PIN ) , " Z_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( Z_MIN_PIN ) ;
# endif
# endif
@ -167,7 +169,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( X2_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( X2_MAX_PIN ) ! = NULL , " X2_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( X2_MAX_PIN ) , " X2_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( X2_MAX_PIN ) ;
# endif
# endif
@ -177,7 +179,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( X2_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( X2_MIN_PIN ) ! = NULL , " X2_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( X2_MIN_PIN ) , " X2_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( X2_MIN_PIN ) ;
# endif
# endif
@ -187,7 +189,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Y2_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Y2_MAX_PIN ) ! = NULL , " Y2_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Y2_MAX_PIN ) , " Y2_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( Y2_MAX_PIN ) ;
# endif
# endif
@ -197,7 +199,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Y2_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Y2_MIN_PIN ) ! = NULL , " Y2_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Y2_MIN_PIN ) , " Y2_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( Y2_MIN_PIN ) ;
# endif
# endif
@ -207,7 +209,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z2_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z2_MAX_PIN ) ! = NULL , " Z2_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z2_MAX_PIN ) , " Z2_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( Z2_MAX_PIN ) ;
# endif
# endif
@ -217,7 +219,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z2_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z2_MIN_PIN ) ! = NULL , " Z2_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z2_MIN_PIN ) , " Z2_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( Z2_MIN_PIN ) ;
# endif
# endif
@ -227,7 +229,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z3_MAX_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z3_MAX_PIN ) ! = NULL , " Z3_MAX_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z3_MAX_PIN ) , " Z3_MAX_PIN is not interrupt-capable " ) ;
pciSetup ( Z3_MAX_PIN ) ;
# endif
# endif
@ -237,7 +239,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z3_MIN_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z3_MIN_PIN ) ! = NULL , " Z3_MIN_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z3_MIN_PIN ) , " Z3_MIN_PIN is not interrupt-capable " ) ;
pciSetup ( Z3_MIN_PIN ) ;
# endif
# endif
@ -247,7 +249,7 @@ void setup_endstop_interrupts( void ) {
attachInterrupt ( digitalPinToInterrupt ( Z_MIN_PROBE_PIN ) , endstop_ISR , CHANGE ) ;
# else
// Not all used endstop/probe -pins can raise interrupts. Please deactivate ENDSTOP_INTERRUPTS or change the pin configuration!
static_assert ( digitalPinToPCICR ( Z_MIN_PROBE_PIN ) ! = NULL , " Z_MIN_PROBE_PIN is not interrupt-capable " ) ;
static_assert ( digitalPinToPCICR ( Z_MIN_PROBE_PIN ) , " Z_MIN_PROBE_PIN is not interrupt-capable " ) ;
pciSetup ( Z_MIN_PROBE_PIN ) ;
# endif
# endif