Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

spi.h

00001 #ifndef _DEV_SPI_H_
00002 #define _DEV_SPI_H_
00003 
00004 #include <sys/device.h>
00013 /*
00014  * Unique device number
00015  */
00016 #define SPI             10
00017 
00021 #define BUFOR_SIZE      300     
00022 
00023 /*
00024  * Uniqu SPI device number
00025  */
00026 #define SPI_FLASH_1 1
00027 
00028 /*
00029  * Uniqu SPI device number
00030  */
00031 #define SPI_FLASH_2 2
00032 
00033 /*
00034  * Uniqu SPI device number
00035  */
00036 #define SPI_RTC 3
00037 
00038 /*
00039  * SPI control line
00040  */
00041 #define     SPI_SCK            PORT1                      
00042 
00043 /*
00044  * SPI control line
00045  */
00046 #define     SPI_MOSI           PORT2
00047 
00048 /*
00049  * SPI control line
00050  */
00051 #define     SPI_MISO           PORT3
00052 
00053 /*
00054  * SPI control line
00055  */
00056 #define     SPI_PORT           PORTB
00057 
00058 /*
00059  * SPI control line
00060  */
00061 #define     SPI_PORT_DIR       DDRB
00062 
00067 typedef struct _SPIICB SPIICB;
00072 typedef struct _SPIDCB SPIDCB;
00073 
00078 struct _SPIICB {
00082     u_char*     read_buf;          
00083 
00087     u_char      write_buf[BUFOR_SIZE];
00088 
00092     u_int       size;   
00093 
00097     u_int       index;
00098 
00102     u_char      writeFlag;
00103 
00107     volatile    u_char ready;      
00111     volatile    u_char finishRead;
00112 };
00113 
00118 struct _SPIDCB {
00123     HANDLE rdy;
00124 
00128     HANDLE readRdy;
00129 
00133     volatile u_char deviceId;
00134     
00139     HANDLE deviceRdy;
00140 };
00141 
00142 
00146 extern NUTDEVICE devSpi0;
00147 
00156 extern int SpiInit(NUTDEVICE *dev);
00157 
00158 
00169 extern int SpiInput(NUTDEVICE *dev, u_char* buf, u_int size);
00170 
00181 extern int SpiOutput(NUTDEVICE *dev, u_char* buf, u_int size);
00182 
00194 extern void LockSpi(NUTDEVICE* dev, u_char deviceId);
00195 
00196 
00207 extern void UnlockSpi(NUTDEVICE* dev, u_char deviceId);
00208 
00209 #endif

Generated on Thu Jan 30 22:30:52 2003 for EduNet by doxygen1.2.18