/**************************************************************************** Title : C file for the I2C FUNCTIONS library (i2c.c) Author: Chris efstathiou hendrix@otenet.gr Date: 13/Jul/2002 Software: AVR-GCC with AVR-AS Target: any AVR device Comments: This software is FREE. *****************************************************************************/ #include #include "i2c.h" #ifndef CONCAT1 #define CONCAT1(a, b) CONCAT2(a, b) #endif #ifndef CONCAT2 #define CONCAT2(a, b) a ## b #endif /* Conversion of microseconds to the right value for the delay function */ #define I2C_DELAY ( (I2C_DELAY_TIME*(F_CPU/60000))/100 ) #define I2C_TIMEOUT ( (I2C_TIMEOUT_TIME*(F_CPU/60000))/100 ) /* Register name forming */ #define I2C_SDA_OUT_REG CONCAT1(PORT, I2C_SDA_PORT) #define I2C_SCL_OUT_REG CONCAT1(PORT, I2C_SCL_PORT) #define I2C_SDA_DDR_REG CONCAT1(DDR, I2C_SDA_PORT) #define I2C_SCL_DDR_REG CONCAT1(DDR, I2C_SCL_PORT) #define I2C_SDA_PIN_REG CONCAT1(PIN, I2C_SDA_PORT) #define I2C_SCL_PIN_REG CONCAT1(PIN, I2C_SCL_PORT) /* Conversion of microseconds to the right value for the delay function */ #define I2C_DELAY ( (I2C_DELAY_TIME*(F_CPU/60000))/100 ) #define I2C_TIMEOUT ( (I2C_TIMEOUT_TIME*(F_CPU/60000))/100 ) /* Pin states */ /* #define SCL_1() cbi(I2C_SCL_DDR_REG, SCL_PIN) #define SCL_0() sbi(I2C_SCL_DDR_REG, SCL_PIN) #define SDA_1() cbi(I2C_SDA_DDR_REG, SDA_PIN) #define SDA_0() sbi(I2C_SDA_DDR_REG, SDA_PIN) */ #define SCL_1() I2C_SCL_DDR_REG &= ~(1<