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