ASURO Library  2.80
i2c.h
gehe zur Dokumentation dieser Datei
1 
44 /****************************************************************************
45 *
46 * File Name: i2c.h
47 * Project : asuro library
48 *
49 * Description: I2C Functions included:
50 *
51 * void InitI2C(void);
52 * unsigned char WriteI2C(unsigned char byte);
53 * unsigned char ReadI2C(unsigned char nak);
54 * unsigned char StartI2C(unsigned char device);
55 * void StopI2C(void);
56 *
57 *
58 * Ver. Date Author Comments
59 * ------- ---------- -------------- ------------------------------------------
60 * 2.70rc2 17.02.2007 raid_ox new functions:
61 * InitI2C: Initialisation
62 * WriteI2C: Write Data over I2C
63 * ...
64 * ------- ---------- -------------- ------------------------------------------
65 *****************************************************************************/
66 
67 #ifndef I2C_H
68 #define I2C_H
69 
70 #include "myasuro.h"
71 
72 /* I2C Bus Kommandos und Statusmeldungen */
73 #define READ 1
74 #define WRITE 0
75 #define ACK 1
76 #define NAK 0
77 
78 /* I2C Bus Definitionen */
79 
80 #define SDA MY_I2C_SDA
81 #define SCL MY_I2C_SCL
82 
83 #define SDA_DDR DDRC
84 #define SCL_DDR DDRC
85 #define SDA_PIN PINC
86 #define SCL_PIN PINC
87 #define SDA_PORT PORTC
88 #define SCL_PORT PORTC
89 
90 #define NOP asm volatile("nop") /*<! No Operation */
91 #define QDEL NOP; NOP; NOP; NOP; NOP /*<! 1/4 Delay */
92 #define HDEL QDEL; QDEL /*<! 1/2 Delay */
93 
94 #define SDA_HI SDA_PORT |= (1 << SDA)
95 #define SDA_LO SDA_PORT &= ~(1 << SDA)
96 
97 #define SCL_HI SCL_PORT |= (1 << SCL)
98 #define SCL_LO SCL_PORT &= ~(1 << SCL)
99 
100 #define SCL_TOGGLE HDEL; SCL_HI; HDEL; SCL_LO
101 #define I2C_START SDA_LO; QDEL; SCL_LO
102 #define I2C_STOP HDEL; SCL_HI; QDEL; SDA_HI; HDEL
103 
104 /* I2C Bus Funktionsprototypen */
105 
110 void InitI2C(void);
111 
118 unsigned char WriteI2C(unsigned char byte);
119 
126 unsigned char ReadI2C(unsigned char nak);
127 
134 unsigned char StartI2C(unsigned char device);
135 
140 void StopI2C(void);
141 
142 #endif /* I2C_H */