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

Created flexible SPI transfer functions

Open oclyke opened this issue 7 years ago • 3 comments

This is a small update for the core SPI library for AVRs (only one SPI peripheral). The concepts can be applied to other cores so that ultimately these functions could be ubiquitous.

Added:

  • transferIn(void *bufIn, size_t count, uint8_t junk)
  • transferOut(void *bufOut, size_t count)

transferIn allows reading data with a known output to the MOSI line without needing to pre-define the entire buffer.

transferOut preserves the content of a buffer when sending it, discarding what comes in through the MISO line. This is useful in using hardware SPI for control of addressable LEDs, OLED panels, etc...

Also had to update the surrounding directory for compatibility with Arduino IDE 1.8.5

oclyke avatar Jul 10 '18 20:07 oclyke

Hi @oclyke , thanks for the proposal! We'll surely evaluate it (and it looks promising compared to the other proposals). Just some stuff that needs to be fixed:

  • https://github.com/arduino/ArduinoCore-avr/pull/19/commits/d7428ff520959a90fd2ada2e8d2d07c389976edb is reverting all the changed applied from 1.6.20, so it should be removed from this commit history
  • remove the comments in the actual functions body, or add another comment saying why you commented them :slightly_smiling_face:

facchinm avatar Jul 11 '18 07:07 facchinm

Hi @facchinm! Thanks a lot for taking a look. I went ahead and removed the commented lines and reverted d7428ff

oclyke avatar Jul 11 '18 15:07 oclyke

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 09 '21 16:04 CLAassistant