mirror of https://github.com/ARMmbed/mbed-os.git
[KL25Z] Fix I2C issue related to the silicon errata.
Makes a difference when running the I2C EEPROM test at 400KHz, which has a 100% success rate after this change.pull/23/head
parent
6c05438993
commit
9ee1fc9f55
|
@ -89,10 +89,18 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_start(i2c_t *obj) {
|
int i2c_start(i2c_t *obj) {
|
||||||
|
uint8_t temp;
|
||||||
|
volatile int i;
|
||||||
// if we are in the middle of a transaction
|
// if we are in the middle of a transaction
|
||||||
// activate the repeat_start flag
|
// activate the repeat_start flag
|
||||||
if (obj->i2c->S & I2C_S_BUSY_MASK) {
|
if (obj->i2c->S & I2C_S_BUSY_MASK) {
|
||||||
|
// KL25Z errata sheet: repeat start cannot be generated if the
|
||||||
|
// I2Cx_F[MULT] field is set to a non-zero value
|
||||||
|
temp = obj->i2c->F >> 6;
|
||||||
|
obj->i2c->F &= 0x3F;
|
||||||
obj->i2c->C1 |= 0x04;
|
obj->i2c->C1 |= 0x04;
|
||||||
|
for (i = 0; i < 100; i ++) __NOP();
|
||||||
|
obj->i2c->F |= temp << 6;
|
||||||
} else {
|
} else {
|
||||||
obj->i2c->C1 |= I2C_C1_MST_MASK;
|
obj->i2c->C1 |= I2C_C1_MST_MASK;
|
||||||
obj->i2c->C1 |= I2C_C1_TX_MASK;
|
obj->i2c->C1 |= I2C_C1_TX_MASK;
|
||||||
|
|
Loading…
Reference in New Issue