arduino / arduino/ArduinoCore-avr

Add slave mode support to SPI library [imported]

Open
#204 1 comment 0 reactions 1 assignee Claimed by @cmaglie View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

This is [Issue 965](http://code.google.com/p/arduino/issues/detail?id=965) moved from a Google Code project.
Added by 2012-06-24T21:16:49.000Z by [n...@gammon.com.au](http://code.google.com/u/111479721553138312180/).
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Medium, Component-SPI
### Original description

**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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.