Wiblocks --- SPI

SPI/SPI.h

00001 #ifndef __SPI_H__
00002 #define __SPI_H__
00003 
00004 
00008 
00009 #define SPI_TIMEOUT   10  //milli-seconds
00010 
00011 #define NB1A_MOSI_PIN  11  //PB3
00012 #define NB1A_MISO_PIN  12  //PB4
00013 #define NB1A_SCK_PIN   13  //PB5
00014 
00015 #define NB2A_MOSI_PIN   5  //PB5
00016 #define NB2A_MISO_PIN   6  //PB6
00017 #define NB2A_SCK_PIN    7  //PB7
00018 
00019 #define NB2AS_MOSI_PIN  5  //PB5
00020 #define NB2AS_MISO_PIN  6  //PB6
00021 #define NB2AS_SCK_PIN   7  //PB7
00022 
00026 
00027 class SPI {
00028  private:
00029   unsigned char _timeout; 
00030   unsigned char _mosi_pin;
00031   unsigned char _miso_pin;
00032   unsigned char _sck_pin;
00033  public:
00034   SPI(unsigned char timeout = SPI_TIMEOUT, 
00035       unsigned char mosi_pin = NB1A_MOSI_PIN,
00036       unsigned char miso_pin = NB1A_MISO_PIN,
00037       unsigned char sck_pin  = NB1A_SCK_PIN);
00038   void init(unsigned char spcr, unsigned char spsr);
00039   char write(unsigned char *data, unsigned char num_chars);
00040   char read(unsigned char *data, unsigned char max_num_chars);
00041 };
00042 
00043 extern SPI spi;
00044 
00045 #endif