aboutsummaryrefslogtreecommitdiff
path: root/libraries/SPI
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/SPI')
-rw-r--r--libraries/SPI/SPI.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp
index 40d4278..077b6a3 100644
--- a/libraries/SPI/SPI.cpp
+++ b/libraries/SPI/SPI.cpp
@@ -111,11 +111,9 @@ void SPIClass::end() {
void SPIClass::usingInterrupt(uint8_t interruptNumber)
{
- uint8_t mask;
-
- if (interruptMode > 1) return;
-
- noInterrupts();
+ uint8_t mask = 0;
+ uint8_t sreg = SREG;
+ noInterrupts(); // Protect from a scheduler and prevent transactionBegin
switch (interruptNumber) {
#ifdef SPI_INT0_MASK
case 0: mask = SPI_INT0_MASK; break;
@@ -143,12 +141,12 @@ void SPIClass::usingInterrupt(uint8_t interruptNumber)
#endif
default:
interruptMode = 2;
- interrupts();
- return;
+ break;
}
- interruptMode = 1;
interruptMask |= mask;
- interrupts();
+ if (!interruptMode)
+ interruptMode = 1;
+ SREG = sreg;
}
void SPIClass::notUsingInterrupt(uint8_t interruptNumber)