diff --git a/lib/i2c_master.c b/lib/i2c_master.c index f5373be..a8ab448 100644 --- a/lib/i2c_master.c +++ b/lib/i2c_master.c @@ -403,16 +403,7 @@ enum i2c_master_rc i2c_master_select_slave(uint32_t i2c, uint16_t slave, bool ad } } } - if (write) { - if (!((I2C_SR2(i2c) & I2C_SR2_TRA))) { // verify we are in transmit mode (and read SR2 to clear ADDR) - return I2C_MASTER_RC_NOT_TRANSMIT; - } - } else { - if ((I2C_SR2(i2c) & I2C_SR2_TRA)) { // verify we are in read mode (and read SR2 to clear ADDR) - return I2C_MASTER_RC_NOT_RECEIVE; - } - } - + // do not check I2C_SR2_TRA to verify if we really are in transmit or receive mode since reading SR2 also clears ADDR and starting the read/write transaction return I2C_MASTER_RC_NONE; }