1 #ifndef EAGLE_EBOARD_HELPLIB_SPI 2 #define EAGLE_EBOARD_HELPLIB_SPI 6 #define SPI_CLOCK_DIV4 0x00 7 #define SPI_CLOCK_DIV16 0x01 9 #define SPI_CLOCK_DIV64 0x02 11 #define SPI_CLOCK_DIV128 0x03 13 #define SPI_CLOCK_DIV2 0x04 15 #define SPI_CLOCK_DIV8 0x05 17 #define SPI_CLOCK_DIV32 0x06 21 #define SPI_MODE0 0x00 22 #define SPI_MODE1 0x04 24 #define SPI_MODE2 0x08 26 #define SPI_MODE3 0x0C 30 #define SPI_MODE_MASK 0x0C 31 #define SPI_CLOCK_MASK 0x03 33 #define SPI_2XCLOCK_MASK 0x01 55 inline static byte
transfer(byte _data);
67 static void begin(
void);
71 inline static void end(
void);
90 byte SPIClass::transfer(byte _data) {
92 while (!(SPSR & _BV(SPIF)));
96 void SPIClass::attachInterrupt() { SPCR |= _BV(SPIE);}
98 void SPIClass::detachInterrupt() { SPCR &= ~_BV(SPIE);}
100 void SPIClass::begin() {
101 digitalWrite(SS, HIGH);
105 pinMode(SCK, OUTPUT);
106 pinMode(MOSI, OUTPUT);
109 void SPIClass::end() {SPCR &= ~_BV(SPE);}
111 void SPIClass::setBitOrder(uint8_t bitOrder) {
112 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
113 else SPCR &= ~(_BV(DORD));
116 void SPIClass::setDataMode(uint8_t mode) { SPCR = (SPCR & ~
SPI_MODE_MASK) | mode; }
118 void SPIClass::setClockDivider(uint8_t rate) {
static void detachInterrupt(void)
disables the interrupt feature
[SPI] This is used to avoid path resolving issues and defines the common known Arduino SPI interface ...
static void end(void)
this will end the SPI connection
this namespace contains all the Don't use manually classes ;)
static void attachInterrupt(void)
enables the interrupt feature
static void begin(void)
this will setup everything for SPI connection
static void setDataMode(uint8_t mode)
this will set the Data transfer mode
static void setClockDivider(uint8_t rate)
this will change the clock devider the
static byte transfer(byte _data)
this will send a single bite via the SPI connection
static void setBitOrder(uint8_t bitOrder)
this will set the BitOrder