File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,12 @@ void SPIClass::usingInterrupt(int interruptNumber)
88
88
interruptMode = SPI_IMODE_GLOBAL;
89
89
else
90
90
{
91
- if (irqMap == NULL ) {
92
- irqMap = (uint8_t *)malloc (EXTERNAL_NUM_INTERRUPTS);
93
- }
91
+ #ifdef USE_MALLOC_FOR_IRQ_MAP
92
+ if (irqMap == NULL ) {
93
+ irqMap = (uint8_t *)malloc (EXTERNAL_NUM_INTERRUPTS);
94
+ }
95
+ #endif
96
+
94
97
interruptMode |= SPI_IMODE_EXTINT;
95
98
if (interruptNumber < 32 ) {
96
99
interruptMask_lo |= 1 << interruptNumber;
@@ -116,8 +119,10 @@ void SPIClass::notUsingInterrupt(int interruptNumber)
116
119
117
120
if (interruptMask_lo == 0 && interruptMask_hi == 0 ) {
118
121
interruptMode = SPI_IMODE_NONE;
119
- free (irqMap);
120
- irqMap = NULL ;
122
+ #ifdef USE_MALLOC_FOR_IRQ_MAP
123
+ free (irqMap);
124
+ irqMap = NULL ;
125
+ #endif
121
126
}
122
127
}
123
128
@@ -181,8 +186,8 @@ void SPIClass::beginTransaction(SPISettings settings)
181
186
{
182
187
detachMaskedInterrupts ();
183
188
}
184
- config (settings);
185
189
}
190
+ config (settings);
186
191
}
187
192
188
193
void SPIClass::endTransaction (void )
Original file line number Diff line number Diff line change 22
22
23
23
#include < Arduino.h>
24
24
25
+ #ifndef USE_MALLOC_FOR_IRQ_MAP
26
+ #define USE_MALLOC_FOR_IRQ_MAP 1
27
+ #endif
28
+
25
29
// SPI_HAS_TRANSACTION means SPI has
26
30
// - beginTransaction()
27
31
// - endTransaction()
@@ -161,6 +165,7 @@ class SPIClass {
161
165
void setClockDivider (uint8_t uc_div);
162
166
163
167
private:
168
+
164
169
void init ();
165
170
void config (SPISettings settings);
166
171
@@ -184,9 +189,15 @@ class SPIClass {
184
189
char interruptSave;
185
190
uint32_t interruptMask_lo;
186
191
uint32_t interruptMask_hi;
187
- uint8_t * irqMap = NULL ;
192
+
193
+ #if USE_MALLOC_FOR_IRQ_MAP
194
+ uint8_t * irqMap = NULL ;
195
+ #else
196
+ volatile uint8_t irqMap[EXTERNAL_NUM_INTERRUPTS];
197
+ #endif
188
198
};
189
199
200
+
190
201
#if SPI_INTERFACES_COUNT > 0
191
202
extern SPIClass SPI;
192
203
#endif
@@ -199,4 +210,4 @@ class SPIClass {
199
210
#define SPI_CLOCK_DIV64 ( SPI_PRESC_DIV64_gc )
200
211
#define SPI_CLOCK_DIV128 ( SPI_PRESC_DIV128_gc )
201
212
202
- #endif
213
+ #endif
You can’t perform that action at this time.
0 commit comments