summaryrefslogtreecommitdiff
path: root/commandline/i2c-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'commandline/i2c-util.c')
-rw-r--r--commandline/i2c-util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/commandline/i2c-util.c b/commandline/i2c-util.c
index 3971721..2771a4e 100644
--- a/commandline/i2c-util.c
+++ b/commandline/i2c-util.c
@@ -267,6 +267,24 @@ unsigned char i2c_tx_byte(unsigned char byte)
return ack;
}
+unsigned char i2c_rx_byte()
+{
+ signed char i;
+ unsigned char ret = 0;
+
+ set_sda(1);
+ for (i = 7; i >= -1; i--) {
+ set_scl(1);
+ usleep(10);
+ if ((i >= 0) && ( get_status() & (1 << BIT_SDA)))
+ ret |= (1 << i);
+ set_scl(0);
+ usleep(10);
+ }
+
+ return ret;
+}
+
void i2c_start()
{
set_sda(1);