00001 /* This file has been prepared for Doxygen automatic documentation generation.*/ 00029 #ifndef USI_H 00030 #define USI_H 00031 00032 //****************************************************************************** 00033 // USI port and pin definitions 00034 //****************************************************************************** 00035 #define USI_OUT_REG PORTB 00036 #define USI_IN_REG PINB 00037 #define USI_DIR_REG DDRB 00038 #define USI_CLOCK_PIN PB2 00039 #define USI_DATAIN_PIN PB0 00040 #define USI_DATAOUT_PIN PB1 00041 00042 00043 //****************************************************************************** 00044 // USI/SPI states 00045 //****************************************************************************** 00046 enum { 00047 ST_CMD = 1, 00048 ST_ADDR, 00049 ST_DATA 00050 }; 00051 00052 00053 //****************************************************************************** 00054 // Struct declarations 00055 //****************************************************************************** 00057 struct SPI_Status_struct 00058 { 00059 unsigned char Data : 8; 00060 unsigned char Address : 8; 00061 unsigned char Count : 6; 00062 unsigned char State : 2; 00063 00064 00065 00067 unsigned char Read : 1; 00068 00070 unsigned char EEPROM : 1; 00071 00073 unsigned char XferComplete : 1; 00074 00076 unsigned char WriteCollision : 1; 00077 }; 00078 typedef struct SPI_Status_struct SPI_Status_t; 00079 00080 00081 //****************************************************************************** 00082 // Function prototypes 00083 //****************************************************************************** 00084 #pragma vector = USI_OVF_vect 00085 __interrupt void USI_OVF_ISR(void); 00086 00087 void SPI_Init(unsigned char spi_mode); 00088 unsigned char SPI_Put(unsigned char val); 00089 unsigned char SPI_Get(void); 00090 void SPI_Wait(void); 00091 00092 #endif // USI_H