Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions ArduinoAddons/Arduino_1.0.x/libraries/SPI/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,44 @@ SPIClass SPI;

void SPIClass::begin() {

// Set SS to high so a connected chip will be "deselected" by default
/* Set SS to high so a connected chip will be "deselected" by default*/
digitalWrite(SS, HIGH);

// When the SS pin is set as OUTPUT, it can be used as
// a general purpose output port (it doesn't influence
// SPI operations).
/* When the SS pin is set as OUTPUT, it can be used as
a general purpose output port (it doesn't influence
SPI operations).*/
pinMode(SS, OUTPUT);

// Warning: if the SS pin ever becomes a LOW INPUT then SPI
// automatically switches to Slave, so the data direction of
// the SS pin MUST be kept as OUTPUT.
/* Warning: if the SS pin ever becomes a LOW INPUT then SPI
automatically switches to Slave, so the data direction of
the SS pin MUST be kept as OUTPUT.*/
SPCR |= _BV(MSTR);
SPCR |= _BV(SPE);

// Set direction register for SCK and MOSI pin.
// MISO pin automatically overrides to INPUT.
// By doing this AFTER enabling SPI, we avoid accidentally
// clocking in a single bit since the lines go directly
// from "input" to SPI control.
// http://code.google.com/p/arduino/issues/detail?id=888
/* Set direction register for SCK and MOSI pin.
MISO pin automatically overrides to INPUT.
By doing this AFTER enabling SPI, we avoid accidentally
clocking in a single bit since the lines go directly
from "input" to SPI control.
http://code.google.com/p/arduino/issues/detail?id=888*/
pinMode(SCK, OUTPUT);
pinMode(MOSI, OUTPUT);
}


void SPIClass::end() {
void SPIClass::end()
{
SPCR &= ~_BV(SPE);
}

void SPIClass::setBitOrder(uint8_t bitOrder)
{
if(bitOrder == LSBFIRST) {
if(bitOrder == LSBFIRST)
{
SPCR |= _BV(DORD);
} else {
}
else
{
SPCR &= ~(_BV(DORD));
}
}
Expand Down