Xmega Application Note


twi_slave_driver.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00059 #ifndef TWI_DRIVER_H
00060 #define TWI_DRIVER_H
00061 
00062 #include "avr_compiler.h"
00063 
00064 
00065 /* Transaction status defines.*/
00066 #define TWIS_STATUS_READY                0
00067 #define TWIS_STATUS_BUSY                 1
00068 
00069 /* Transaction result enumeration */
00070 typedef enum TWIS_RESULT_enum {
00071         TWIS_RESULT_UNKNOWN            = (0x00<<0),
00072         TWIS_RESULT_OK                 = (0x01<<0),
00073         TWIS_RESULT_BUFFER_OVERFLOW    = (0x02<<0),
00074         TWIS_RESULT_TRANSMIT_COLLISION = (0x03<<0),
00075         TWIS_RESULT_BUS_ERROR          = (0x04<<0),
00076         TWIS_RESULT_FAIL               = (0x05<<0),
00077         TWIS_RESULT_ABORTED            = (0x06<<0),
00078 } TWIS_RESULT_t;
00079 
00080 /* Buffer size defines. */
00081 #define TWIS_RECEIVE_BUFFER_SIZE         8
00082 #define TWIS_SEND_BUFFER_SIZE            8
00083 
00084 
00085 
00091 typedef struct TWI_Slave {
00092         TWI_t *interface;                               
00093         void (*Process_Data) (void);                    
00094         register8_t receivedData[TWIS_RECEIVE_BUFFER_SIZE]; 
00095         register8_t sendData[TWIS_SEND_BUFFER_SIZE];        
00096         register8_t bytesReceived;                          
00097         register8_t bytesSent;                              
00098         register8_t status;                                 
00099         register8_t result;                                 
00100         bool abort;                                     
00101 } TWI_Slave_t;
00102 
00103 
00104 
00105 void TWI_SlaveInitializeDriver(TWI_Slave_t *twi,
00106                                TWI_t *module,
00107                                void (*processDataFunction) (void));
00108 
00109 void TWI_SlaveInitializeModule(TWI_Slave_t *twi,
00110                                uint8_t address,
00111                                TWI_SLAVE_INTLVL_t intLevel);
00112 
00113 void TWI_SlaveInterruptHandler(TWI_Slave_t *twi);
00114 void TWI_SlaveAddressMatchHandler(TWI_Slave_t *twi);
00115 void TWI_SlaveStopHandler(TWI_Slave_t *twi);
00116 void TWI_SlaveDataHandler(TWI_Slave_t *twi);
00117 void TWI_SlaveReadHandler(TWI_Slave_t *twi);
00118 void TWI_SlaveWriteHandler(TWI_Slave_t *twi);
00119 void TWI_SlaveTransactionFinished(TWI_Slave_t *twi, uint8_t result);
00120 
00121 
00135 #endif /* TWI_DRIVER_H */
@DOC_TITLE@
Generated on Tue Aug 11 12:42:12 2009 for AVR1308 Using the XMEGA TWI by doxygen 1.5.9