[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
Bogdan Marinescu 2013-08-07 14:49:11 +03:00
parent 6c05438993
commit 9ee1fc9f55
1 changed files with 8 additions and 0 deletions

View File

@ -89,10 +89,18 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
}
int i2c_start(i2c_t *obj) {
uint8_t temp;
volatile int i;
// if we are in the middle of a transaction
// activate the repeat_start flag
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;
for (i = 0; i < 100; i ++) __NOP();
obj->i2c->F |= temp << 6;
} else {
obj->i2c->C1 |= I2C_C1_MST_MASK;
obj->i2c->C1 |= I2C_C1_TX_MASK;