ArduinoCore-API icon indicating copy to clipboard operation
ArduinoCore-API copied to clipboard

SPI API add void transfer(const void *tx_buffer, void *rx_buffer, size_t count);

Open ag88 opened this issue 1 year ago • 0 comments

API component

SPI API

Description

SPI API add

virtual void transfer(const void *tx_buffer, void *rx_buffer, size_t count);

Expand SPI API and Functionality for High Speed Devices

Is this a breaking change?

Unlikely

Additional information

This is really a missing API method, it doesn't make sense to have only a single buffer for both transmit and receive, as DMA hardware normally works in 2 buffers. The plain old https://github.com/arduino/ArduinoCore-API/blob/master/api/HardwareSPI.h#L112

  virtual void transfer(void *buf, size_t count) = 0;

forces hacks such as:

  • allocate a temporary buffer
  • do the DMA transfers receiving into the temporary buffer
  • copy that temporary buffer data back into the address pointed by buf wasting both memory and cpu cycles

ag88 avatar Jan 10 '25 13:01 ag88