SPI.transfer(buffer, size) is missing in Particle Core lib


#1

The Particle Core does not support the SPI.transfer(buffer, size) from the Arduino SPI reference:
https://www.arduino.cc/en/Reference/SPITransfer

If I’m looking in the correct place, this is the current implementation:
https://github.com/particle-iot/device-os/blob/1b1805fb4afcb93b0e92fbecfd28c082d6310285/wiring/src/spark_wiring_spi.cpp and the method isn’t in there.

This will cause a current and future incompatibility with any library that uses this method. The most important one of these will be the Adafruit BusIO library: https://github.com/adafruit/Adafruit_BusIO It looks like Adafruit created this library in March to alleviate SPI and I2C problems like this. In this case it actually highlights that Particle boards will not be able to use Adafruit code in the future unless this is fixes as it looks like Adafruit is adding this to several code bases.

The Adafruit code is missing a define for the SPARK, but that’s a simple pull request. So - before I submit this as an issue on https://github.com/particle-iot/device-os/ - is this on purpose or just something that got lost?

I can work my way around this, but this will be a showstopper for many when they get the error: “error: no matching function for call to ‘Adafruit_SPIDevice::transfer(uint8_t*&, size_t&)’”


#2

As it seems the online reference docs for Spark Core SPI have vanished almost entirely - currently only SPI.begin() is documented at all.
However, you can use SPI.transfer(void* tx_buffer, void* rx_buffer, size_t length, wiring_spi_dma_transfercomplete_callback_t user_callback);.
And if you need the exact same syntax you can add a #define that wraps that function for your use-case.

However, a PR to add another overload which wraps the DMA version wouldn’t be a bad idea.