File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
hardware/arduino/avr/libraries/SPI Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -141,3 +141,44 @@ void SPIClass::usingInterrupt(uint8_t interruptNumber)
141
141
SREG = sreg;
142
142
}
143
143
144
+ void SPIClass::notUsingInterrupt (uint8_t interruptNumber)
145
+ {
146
+ uint8_t mask = 0 ;
147
+ uint8_t sreg = SREG;
148
+ noInterrupts (); // Protect from a scheduler and prevent transactionBegin
149
+ switch (interruptNumber) {
150
+ #ifdef SPI_INT0_MASK
151
+ case 0 : mask = SPI_INT0_MASK; break ;
152
+ #endif
153
+ #ifdef SPI_INT1_MASK
154
+ case 1 : mask = SPI_INT1_MASK; break ;
155
+ #endif
156
+ #ifdef SPI_INT2_MASK
157
+ case 2 : mask = SPI_INT2_MASK; break ;
158
+ #endif
159
+ #ifdef SPI_INT3_MASK
160
+ case 3 : mask = SPI_INT3_MASK; break ;
161
+ #endif
162
+ #ifdef SPI_INT4_MASK
163
+ case 4 : mask = SPI_INT4_MASK; break ;
164
+ #endif
165
+ #ifdef SPI_INT5_MASK
166
+ case 5 : mask = SPI_INT5_MASK; break ;
167
+ #endif
168
+ #ifdef SPI_INT6_MASK
169
+ case 6 : mask = SPI_INT6_MASK; break ;
170
+ #endif
171
+ #ifdef SPI_INT7_MASK
172
+ case 7 : mask = SPI_INT7_MASK; break ;
173
+ #endif
174
+ default :
175
+ if (interruptMask) {
176
+ modeFlags.interruptMode = 1 ;
177
+ } else {
178
+ modeFlags.interruptMode = 0 ;
179
+ }
180
+ break ;
181
+ }
182
+ interruptMask &= ~mask;
183
+ SREG = sreg;
184
+ }
Original file line number Diff line number Diff line change 20
20
// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode)
21
21
#define SPI_HAS_TRANSACTION 1
22
22
23
+ // SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrup() method
24
+ #define SPI_HAS_NOTUSINGINTERRUPT 1
25
+
23
26
// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version.
24
27
// This way when there is a bug fix you can check this define to alert users
25
28
// of your code if it uses better version of this library.
@@ -169,6 +172,8 @@ class SPIClass {
169
172
// with attachInterrupt. If SPI is used from a different interrupt
170
173
// (eg, a timer), interruptNumber should be 255.
171
174
static void usingInterrupt (uint8_t interruptNumber);
175
+ // And this does the opposite.
176
+ static void notUsingInterrupt (uint8_t interruptNumber);
172
177
173
178
// Before using SPI.transfer() or asserting chip select pins,
174
179
// this function is used to gain exclusive access to the SPI bus
You can’t perform that action at this time.
0 commit comments