Skip to content

Commit 67bd6e7

Browse files
Add a hack to work around the differences between the Adafruit SAMD core and the official Arduino SAMD core.
1 parent 7f66a34 commit 67bd6e7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Adafruit_SPIDevice.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,14 @@ bool Adafruit_SPIDevice::write(uint8_t *buffer, size_t len,
310310
_spi->transferBytes(buffer, nullptr, len);
311311
}
312312
} else
313-
#elif defined(ARDUINO_ARCH_SAMD)
313+
#elif defined(ARDUINO_ARCH_SAMD) && defined(_ADAFRUIT_ZERODMA_H_)
314+
// The variant of transfer() used below currently only exists in the Adafruit core.
315+
// It causes a build failure when building against the main Arduino SAMD core.
316+
// Unfortunately there doesn't seem to be a supported #define that this code
317+
// can use to tell which core it's building against. This hack
318+
// (checking for the include guard that gets defined when the Adafruit core's
319+
// SPI.h includes Adafruit_ZeroDMA.h) works for now, but it should be improved
320+
// when possible.
314321
if (_spi) {
315322
if (prefix_len > 0) {
316323
_spi->transfer(prefix_buffer, nullptr, prefix_len);
@@ -423,7 +430,14 @@ bool Adafruit_SPIDevice::write_then_read(uint8_t *write_buffer,
423430
_spi->transferBytes(write_buffer, nullptr, write_len);
424431
}
425432
} else
426-
#elif defined(ARDUINO_ARCH_SAMD)
433+
#elif defined(ARDUINO_ARCH_SAMD) && defined(_ADAFRUIT_ZERODMA_H_)
434+
// The variant of transfer() used below currently only exists in the Adafruit core.
435+
// It causes a build failure when building against the main Arduino SAMD core.
436+
// Unfortunately there doesn't seem to be a supported #define that this code
437+
// can use to tell which core it's building against. This hack
438+
// (checking for the include guard that gets defined when the Adafruit core's
439+
// SPI.h includes Adafruit_ZeroDMA.h) works for now, but it should be improved
440+
// when possible.
427441
if (_spi) {
428442
if (write_len > 0) {
429443
_spi->transfer(write_buffer, nullptr, write_len);

0 commit comments

Comments
 (0)