I2C: don't clear ADDR after select

to check if the slave has successfully been selected to read or
write and the master is in the corresponding receive or transmit
state, SR2 was checked.
but reading SR2 also cleared the ADDR bit, starting the read/write
transaction.
the check is done in the read/write methods anyway.
This commit is contained in:
King Kévin 2019-03-26 18:07:22 +01:00
parent ef4685a9a3
commit efbd228f8a
1 changed files with 1 additions and 10 deletions

View File

@ -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;
}