Skip to content

Commit 78f79ed

Browse files
committed
Add SPI.notUsingInterrupt(...)
1 parent 8f5e2eb commit 78f79ed

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

libraries/SPI/SPI.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ void SPIClass::usingInterrupt(int interruptNumber)
112112
interrupts();
113113
}
114114

115+
void SPIClass::notUsingInterrupt(int interruptNumber)
116+
{
117+
if ((interruptNumber == NOT_AN_INTERRUPT) || (interruptNumber == EXTERNAL_INT_NMI))
118+
return;
119+
120+
if (interruptMode & SPI_IMODE_GLOBAL)
121+
return; // can't go back, as there is no reference count
122+
123+
uint8_t irestore = interruptsStatus();
124+
noInterrupts();
125+
126+
interruptMask &= ~(1 << interruptNumber);
127+
128+
if (interruptMask == 0)
129+
interruptMode = SPI_IMODE_NONE;
130+
131+
if (irestore)
132+
interrupts();
133+
}
134+
115135
void SPIClass::beginTransaction(SPISettings settings)
116136
{
117137
if (interruptMode != SPI_IMODE_NONE)

libraries/SPI/SPI.h

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// - SPISetting(clock, bitOrder, dataMode)
3030
#define SPI_HAS_TRANSACTION 1
3131

32+
// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method
33+
#define SPI_HAS_NOTUSINGINTERRUPT 1
34+
3235
#define SPI_MODE0 0x02
3336
#define SPI_MODE1 0x00
3437
#define SPI_MODE2 0x03
@@ -100,6 +103,7 @@ class SPIClass {
100103

101104
// Transaction Functions
102105
void usingInterrupt(int interruptNumber);
106+
void notUsingInterrupt(int interruptNumber);
103107
void beginTransaction(SPISettings settings);
104108
void endTransaction(void);
105109

0 commit comments

Comments
 (0)