//this is an implemention //of using two free chooseable //pins of an avr as i2c-signals, //not using the i2c-feature of the atmega //if you will not use the default //PORTC0,1 sigs, you have to define //SCLSIGPORT,SCLSIGDIRPORT,SCLSIGREADPORT //SDASIGPORT,SDASIGDIRPORT,SDASIGREADPORT //before include this. // #ifndef __I2CSIG_H #define __I2CSIG_H #include "global.h" #include "utils.h" #ifndef SCLSIGPORT #define SCLSIGPORT PORTC // i2csig clock port write #endif #ifndef SDASIGPORT #define SDASIGPORT PORTC // i2csig data port write #endif #ifndef SCLSIGDIRPORT #define SCLSIGDIRPORT DDRC // i2csig clock port direction #endif #ifndef SDASIGDIRPORT #define SDASIGDIRPORT DDRC // i2csig data port direction #endif #ifndef SCLSIGREADPORT #define SCLSIGREADPORT PINC // i2csig clock port read #endif #ifndef SDASIGREADPORT #define SDASIGREADPORT PINC // i2csig data port read #endif #define SCLSIG 0 // i2csig clock pin #define SDASIG 1 // i2csig data pin #define I2CSIGQDEL Delay1us(6) // i2csig quarter-bit delay #define I2CSIG_SDA_LO cbi( SDASIGPORT, SDASIG) #define I2CSIG_SDA_HI sbi( SDASIGPORT, SDASIG) #define I2CSIG_SCL_LO cbi( SCLSIGPORT, SCLSIG) #define I2CSIG_SCL_HI sbi( SCLSIGPORT, SCLSIG) #define I2C_SUCCESSFUL 0x00 #define I2C_NO_ACKNOWLEDGE 0xFE #define I2C_NOT_IMPLEMENTED 0xFF extern void i2csig_init(void); extern BYTE i2csig_send(BYTE dev, BYTE sub, WORD length, BYTE *data); extern BYTE i2csig_receive(BYTE dev, BYTE sub, WORD length, BYTE *data); #endif