mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
[avr] Made SPI.usingInterrupt() synchronized (Andrew Kroll)
This commit is contained in:
parent
d9537cb7da
commit
84b6cc27a5
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user