Atmel AVR156: TWI Master bit bang driver  100
TWI_master.h
Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00051 #ifndef TWI_MASTER_H_
00052 #define TWI_MASTER_H_
00053 
00054 #include "ioavr.h"
00055 #include "inavr.h"
00056 
00058 #define SCL PC1
00059 
00061 #define SDA PC4
00062 
00064 #define PORT_SCL PORTC
00065 
00066 #define DDR_SCL     DDRC
00067 
00068 #define PIN_SCL PINC
00069 
00070 #define PORT_SDA PORTC
00071 
00072 #define DDR_SDA     DDRC
00073 
00074 #define PIN_SDA PINC
00075 
00077 #define SLAVE_ADDRESS 0xA0
00078 
00079 #define READ_SDA() (PIN_SDA & (1 << SDA))
00080 #define SET_SDA_OUT() DDR_SDA |= (1 << SDA)
00081 #define SET_SDA_IN() DDR_SDA &= ~(1 << SDA)
00082 #define READ_SCL() (PIN_SCL & (1 << SCL))?1:0
00083 
00084 #define WRITE 0x0
00085 #define READ 0x1
00086 
00088 #define DELAY 2
00089 
00091 #define SCL_SDA_DELAY 1
00092 
00093 void twi_disable();
00094 void twi_init();
00095 void toggle_scl();
00096 void write_scl(char x);
00097 char twi_start_cond(void);
00098 char send_slave_address(unsigned char read);
00099 char write_data(unsigned char* data, char bytes);
00100 char i2c_write_byte(unsigned char byte);
00101 char read_bytes(unsigned char* data, char bytes);
00102 char i2c_read_byte(unsigned char* data, unsigned char bytes, unsigned char index);
00103 void write_sda( char x);
00104 
00105 
00106 
00107 #endif /* TWI_MASTER_H_ */