1 #ifndef EAGLE_EBOARD_HELPLIB_SPI 2 #define EAGLE_EBOARD_HELPLIB_SPI 18 #define SPI_CLOCK_DIV4 0x00 19 #define SPI_CLOCK_DIV16 0x01 21 #define SPI_CLOCK_DIV64 0x02 23 #define SPI_CLOCK_DIV128 0x03 25 #define SPI_CLOCK_DIV2 0x04 27 #define SPI_CLOCK_DIV8 0x05 29 #define SPI_CLOCK_DIV32 0x06 33 #define SPI_MODE0 0x00 34 #define SPI_MODE1 0x04 36 #define SPI_MODE2 0x08 38 #define SPI_MODE3 0x0C 42 #define SPI_MODE_MASK 0x0C 43 #define SPI_CLOCK_MASK 0x03 45 #define SPI_2XCLOCK_MASK 0x01 77 inline static byte
transfer(byte data);
89 static void begin(
void);
93 inline static void end(
void);
117 byte SPIClass::transfer(byte data) {
119 while (!(SPSR & _BV(SPIF)));
123 void SPIClass::attachInterrupt() { SPCR |= _BV(SPIE);}
125 void SPIClass::detachInterrupt() { SPCR &= ~_BV(SPIE);}
129 void SPIClass::end() { SPCR &= ~_BV(SPE); }
131 void SPIClass::setBitOrder(uint8_t bitOrder) {
132 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
133 else SPCR &= ~(_BV(DORD));
136 void SPIClass::setDataMode(uint8_t mode) { SPCR = (SPCR & ~
SPI_MODE_MASK) | mode; }
138 void SPIClass::setClockDivider(uint8_t rate) {
143 void SPIClass::begin() {
144 digitalWrite(SS, HIGH);
148 pinMode(SCK, OUTPUT);
149 pinMode(MOSI, OUTPUT);
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 byte transfer(byte data)
this will send a single bite via the SPI connection
static void setClockDivider(uint8_t rate)
this will change the clock devider the
static void setBitOrder(uint8_t bitOrder)
this will set the BitOrder