@@ -312,6 +312,22 @@ bool Adafruit_SPIDevice::write(uint8_t *buffer, size_t len,
312
312
_spi->transferBytes (buffer, nullptr , len);
313
313
}
314
314
} else
315
+ #elif defined(ARDUINO_ARCH_SAMD) && defined(_ADAFRUIT_ZERODMA_H_)
316
+ // The variant of transfer() used below currently only exists in the Adafruit
317
+ // core. It causes a build failure when building against the main Arduino SAMD
318
+ // core. Unfortunately there doesn't seem to be a supported #define that this
319
+ // code can use to tell which core it's building against. This hack (checking
320
+ // for the include guard that gets defined when the Adafruit core's SPI.h
321
+ // includes Adafruit_ZeroDMA.h) works for now, but it should be improved when
322
+ // possible.
323
+ if (_spi) {
324
+ if (prefix_len > 0 ) {
325
+ _spi->transfer (prefix_buffer, nullptr , prefix_len);
326
+ }
327
+ if (len > 0 ) {
328
+ _spi->transfer (buffer, nullptr , len);
329
+ }
330
+ } else
315
331
#endif
316
332
{
317
333
for (size_t i = 0 ; i < prefix_len; i++) {
@@ -417,6 +433,19 @@ bool Adafruit_SPIDevice::write_then_read(uint8_t *write_buffer,
417
433
_spi->transferBytes (write_buffer, nullptr , write_len);
418
434
}
419
435
} else
436
+ #elif defined(ARDUINO_ARCH_SAMD) && defined(_ADAFRUIT_ZERODMA_H_)
437
+ // The variant of transfer() used below currently only exists in the Adafruit
438
+ // core. It causes a build failure when building against the main Arduino SAMD
439
+ // core. Unfortunately there doesn't seem to be a supported #define that this
440
+ // code can use to tell which core it's building against. This hack (checking
441
+ // for the include guard that gets defined when the Adafruit core's SPI.h
442
+ // includes Adafruit_ZeroDMA.h) works for now, but it should be improved when
443
+ // possible.
444
+ if (_spi) {
445
+ if (write_len > 0 ) {
446
+ _spi->transfer (write_buffer, nullptr , write_len);
447
+ }
448
+ } else
420
449
#endif
421
450
{
422
451
for (size_t i = 0 ; i < write_len; i++) {
0 commit comments