mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Moving SPI pin definitions into core (from SPI library): SS, MISO, MOSI, and SCK.
This commit is contained in:
parent
94045e292a
commit
0aec45afbc
@ -49,6 +49,18 @@
|
||||
#define TIMER5B 15
|
||||
#define TIMER5C 16
|
||||
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
const static uint8_t SS = 53;
|
||||
const static uint8_t MOSI = 51;
|
||||
const static uint8_t MISO = 50;
|
||||
const static uint8_t SCK = 52;
|
||||
#else
|
||||
const static uint8_t SS = 10;
|
||||
const static uint8_t MOSI = 11;
|
||||
const static uint8_t MISO = 12;
|
||||
const static uint8_t SCK = 13;
|
||||
#endif
|
||||
|
||||
// On the ATmega1280, the addresses of some of the port registers are
|
||||
// greater than 255, so we can't store them in uint8_t's.
|
||||
extern const uint16_t PROGMEM port_to_mode_PGM[];
|
||||
|
@ -8,34 +8,27 @@
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "SPI.h"
|
||||
|
||||
SPIClass SPI;
|
||||
|
||||
SPIClass::SPIClass()
|
||||
{
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
// PBx
|
||||
const static byte SS = 0;
|
||||
const static byte MOSI = 2;
|
||||
const static byte MISO = 3;
|
||||
const static byte SCK = 1;
|
||||
#else
|
||||
// PBx
|
||||
const static byte SS = 2;
|
||||
const static byte MOSI = 3;
|
||||
const static byte MISO = 4;
|
||||
const static byte SCK = 5;
|
||||
#endif
|
||||
|
||||
// Set direction register for SCK and MOSI pin.
|
||||
// MISO pin automatically overrides to INPUT.
|
||||
// When the SS pin is set as OUTPUT, it can be used as
|
||||
// a general purpose output port (it doesn't influence
|
||||
// SPI operations).
|
||||
|
||||
DDRB |= _BV(SCK) | _BV(MOSI) | _BV(SS);
|
||||
PORTB &= ~(_BV(SCK) | _BV(MOSI) | _BV(SS));
|
||||
pinMode(SCK, OUTPUT);
|
||||
pinMode(MOSI, OUTPUT);
|
||||
pinMode(SS, OUTPUT);
|
||||
|
||||
digitalWrite(SCK, LOW);
|
||||
digitalWrite(MOSI, LOW);
|
||||
digitalWrite(SS, LOW);
|
||||
|
||||
SPCR = _BV(SPE) | _BV(MSTR);
|
||||
|
||||
// Warning: if the SS pin ever becomes a LOW INPUT then SPI
|
||||
|
Loading…
x
Reference in New Issue
Block a user