code8825 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Add slave mode support to SPI library #965

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

The SPI class currently has a method attachInterrupt() that simplifies getting 
SPI transfer completes to trigger an interrupt. This does this:

void SPIClass::attachInterrupt() {
  SPCR |= _BV(SPIE);
}

However there is no method to turn SPI into slave mode, which is where these 
interrupts would be useful. Suggest adding:

void SPIClass::setSlaveMode() {
  pinMode(SS, INPUT);
  SPCR |= _BV(SPE);
}

Why?

It seems unbalanced to have a method to do half the job of setting up an SPI 
slave - turning interrupts on. It would be more complete to also be able to go 
into slave mode.

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

There would be no incompatibilities because this method does not currently 
exist.

Original issue reported on code.google.com by n...@gammon.com.au on 24 Jun 2012 at 9:16

GoogleCodeExporter commented 9 years ago
I think this probably requires a bigger conversation about the design of the 
entire API for SPI slave mode.  I'll bring it up on the developers mailing list.

Original comment by dmel...@gmail.com on 29 Jun 2012 at 2:46