SPI library does not have functions for sending or receiving data blocks
SPI library does not have functions for sending or receiving data blocks. SPI.transfer has disadvantages.
- If I need to read from SPI a large block of data I often need to fill an array with a constant, f.e. 0xff
- If I need to send data block to SPI several times I must fill this array again after each sending because it is filled with data read (that I don't need anyway)
I suggest to add functions like SPI.send(void* data, size_t len, unsigned char outbyte = 0xff) and SPI.receive(void* data, size_t len)
If this is implemented, I hope the API will look like an overload of SPI.transfer(const void *wr, void *rd, size_t length) which has been discussed before, where NULL is supported for the 2nd input. When SPI.h supports this, SPI_HAS_TRANSFER_BUF should be defined.
For example, the Ethernet library already has support for using this, with cores having a SPI library with this feature. https://github.com/arduino-libraries/Ethernet/blob/master/src/utility/w5100.cpp#L316
This looks related to item (2): https://github.com/arduino/Arduino/pull/4573
Ok. Transferring can be done. But what should user do when he needs to receive a data block from a device that demands some value to continue data sending? For example device receives 0xff and continues to send data, but if it receives other byte value it stops?