From 1989d85b915c75d2b414fa143e372954ea6b3347 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 11 Apr 2022 09:52:00 +0200 Subject: [PATCH] software/libbase/i2c/i2c_poll: Also test for write when polling since some I2C devices do not respond to read or require a specific protocol. --- litex/soc/software/libbase/i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litex/soc/software/libbase/i2c.c b/litex/soc/software/libbase/i2c.c index a36e986c5..b4ad80444 100644 --- a/litex/soc/software/libbase/i2c.c +++ b/litex/soc/software/libbase/i2c.c @@ -261,7 +261,8 @@ bool i2c_poll(unsigned char slave_addr) bool result; i2c_start(); - result = i2c_transmit_byte(I2C_ADDR_RD(slave_addr)); + result = i2c_transmit_byte(I2C_ADDR_WR(slave_addr)); + result |= i2c_transmit_byte(I2C_ADDR_RD(slave_addr)); i2c_stop(); return result;