i2c.h

gehe zur Dokumentation dieser Datei
00001 
00044 /****************************************************************************
00045 *
00046 * File Name:   i2c.h
00047 * Project  :   asuro library 
00048 *
00049 * Description: I2C Functions included:
00050 *
00051 * void InitI2C(void);
00052 * unsigned char WriteI2C(unsigned char byte);
00053 * unsigned char ReadI2C(unsigned char nak);
00054 * unsigned char StartI2C(unsigned char device);
00055 * void StopI2C(void);
00056 *
00057 *
00058 * Ver.     Date         Author           Comments
00059 * -------  ----------   --------------   ------------------------------------------
00060 * 2.70rc2  17.02.2007   raid_ox          new functions:
00061 *                                        InitI2C: Initialisation
00062 *                                        WriteI2C: Write Data over I2C
00063 *                                        ...
00064 * -------  ----------   --------------   ------------------------------------------
00065 *****************************************************************************/
00066 
00067 #ifndef I2C_H
00068 #define I2C_H
00069 
00070 /* I2C Bus Kommandos und Statusmeldungen */
00071 #define READ    1
00072 #define WRITE   0
00073 #define ACK     1
00074 #define NAK     0
00075 
00076 /* I2C Bus Definitionen */
00077 
00078 #define SDA     PC3
00079 #define SCL     PC2
00080 #define SDA_DDR   DDRC
00081 #define SCL_DDR   DDRC
00082 #define SDA_PIN   PINC
00083 #define SCL_PIN   PINC
00084 #define SDA_PORT  PORTC
00085 #define SCL_PORT  PORTC
00086 
00087 #define NOP     asm volatile("nop")         /*<! No Operation */
00088 #define QDEL    NOP; NOP; NOP; NOP; NOP     /*<! 1/4 Delay */
00089 #define HDEL    QDEL; QDEL                  /*<! 1/2 Delay */
00090 
00091 #define SDA_HI    SDA_PORT |= (1 << SDA)
00092 #define SDA_LO    SDA_PORT &= ~(1 << SDA)
00093 
00094 #define SCL_HI    SCL_PORT |= (1 << SCL)
00095 #define SCL_LO    SCL_PORT &= ~(1 << SCL)
00096 
00097 #define SCL_TOGGLE  HDEL; SCL_HI; HDEL; SCL_LO
00098 #define I2C_START SDA_LO; QDEL; SCL_LO
00099 #define I2C_STOP  HDEL; SCL_HI; QDEL; SDA_HI; HDEL
00100 
00101 /* I2C Bus Funktionsprototypen */
00102 
00103 void InitI2C(void);
00104 unsigned char WriteI2C(unsigned char byte);
00105 unsigned char ReadI2C(unsigned char nak);
00106 unsigned char StartI2C(unsigned char device);
00107 void StopI2C(void);
00108 
00109 #endif /* I2C_H */

Erzeugt am Sun Nov 18 18:24:52 2007 für ASURO Library von  doxygen 1.5.1-p1