* that provides two lines: SCL (clock) and SDA (data).
*/
+/**
+ * Delay between output state changes
+ *
+ * Max rated i2c speed (for the basic i2c protocol) is 100kbps,
+ * i.e. 200k clock transitions per second.
+ */
+static void i2c_delay ( void ) {
+ udelay ( I2C_UDELAY );
+}
+
/**
* Set state of I2C SCL line
*
* @v basher Bit-bashing interface
* @v state New state of SCL
*/
-static inline __attribute__ (( always_inline )) void
-setscl ( struct bit_basher *basher, int state ) {
+static void setscl ( struct bit_basher *basher, int state ) {
write_bit ( basher, I2C_BIT_SCL, state );
+ i2c_delay();
}
/**
* @v basher Bit-bashing interface
* @v state New state of SDA
*/
-static inline __attribute__ (( always_inline )) void
-setsda ( struct bit_basher *basher, int state ) {
+static void setsda ( struct bit_basher *basher, int state ) {
write_bit ( basher, I2C_BIT_SDA, state );
+ i2c_delay();
}
/**
* @v basher Bit-bashing interface
* @ret state State of SDA
*/
-static inline __attribute__ (( always_inline )) int
-getsda ( struct bit_basher *basher ) {
+static int getsda ( struct bit_basher *basher ) {
return read_bit ( basher, I2C_BIT_SDA );
}
assert ( basher->write != NULL );
i2cbit->i2c.read = i2c_bit_read;
i2cbit->i2c.write = i2c_bit_write;
- basher->udelay = I2C_UDELAY;
i2c_stop ( basher );
}
* @ret non-zero Input is a logic 1
*/
int ( * read ) ( struct bit_basher *basher, unsigned int bit_id );
- /** Delay between subsequent calls to write(), in microseconds */
- unsigned int udelay;
};
extern void write_bit ( struct bit_basher *basher, unsigned int bit_id,