twi_lib.h

Go to the documentation of this file.
00001 
00016 #ifndef _TWI_LIB_H_
00017 #define _TWI_LIB_H_
00018 
00019 #include "twi_drv.h"
00020 
00021 /*_____ C O N F I G U R A T I O N _________________________________________*/
00022 #define TWI_NB_SLAVE_DATA   100
00023 #define TWI_MASTER
00024 #define TWI_SLAVE
00025 
00026 #ifdef TWI_BIG_FRAME
00027 typedef unsigned int    Length_TWI_frame;
00028 #else
00029 typedef unsigned char   Length_TWI_frame;
00030 #endif
00031 
00032 /*_____ D E F I N I T I O N S ______________________________________________*/
00033 typedef struct{ unsigned char       address;
00034                 unsigned char       rw;
00035                 Length_TWI_frame    nbbytes;
00036                 unsigned char*      buf;
00037               } TWI_message;
00038 
00039 
00040 /*_____ D E C L A R A T I O N ______________________________________________*/
00041 extern volatile TWI_message xdata   twi_message;        // The TWI message to be sent in Master Mode
00042 extern volatile bit                 twi_busy;
00043 extern volatile unsigned char       twi_err;
00044 extern volatile unsigned char xdata twi_slave_data[TWI_NB_SLAVE_DATA];  //The slave data buffer when TWI ask in slave
00045 
00046 /*_____ M A C R O S ________________________________________________________*/
00047 
00052 #define TWI_OK                  0
00053 #define TWI_BUS_ERROR           1
00054 #define TWI_HOST_ADR_NACK       2
00055 #define TWI_HOST_DATA_NACK      3
00056 #define TWI_ARBITRATION_LOST    4
00057 #define TWI_UNKNOWN             5
00058 #define TWI_NOT_FREE            6
00059 
00060 
00065 #define TWI_READ  1
00066 
00070 #define TWI_WRITE 0
00071 
00072 #ifndef TWI_CONFIG
00073 #define TWI_CONFIG     MSK_TWCR_TWEN
00074 #endif
00075 
00076 /*_____ P R O T O T Y P E S ____________________________________________________________*/
00077 
00104 unsigned char twi_send_message_polling  ( unsigned char slave_addr,bit rw, Length_TWI_frame nbytes, Uchar *info );
00105 
00132 unsigned char twi_send_message_interrupt( unsigned char slave_addr,bit rw, Length_TWI_frame nbytes, Uchar *info);
00149 unsigned char twi_slave_polling         (void);
00150 
00167 void          twi_slave_interrupt       (void);
00168 
00173 void    twi_lib_init                    (void);
00174 
00193 Byte    twi_putchar(Byte addr,Byte b);
00203 Uint16  twi_getchar (Byte addr);
00204 
00205 
00206 
00207 /*_____ C O N F I G U R A T I O N _________________________________________*/
00208 
00209 
00210 #endif /* _TWI_H_ */
00211 

Generated on Mon Dec 1 11:12:21 2008 for AVR498 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.4