mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #1400 from bcostm/fix_i2c_stm32f4
[STM32F4xx] Remove eventual pending stop bit before start on I2Cpull/1389/merge
commit
e7e5893c20
|
@ -100,7 +100,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
|
|||
|
||||
void i2c_frequency(i2c_t *obj, int hz)
|
||||
{
|
||||
MBED_ASSERT((hz != 0) && (hz <= 400000));
|
||||
MBED_ASSERT((hz > 0) && (hz <= 400000));
|
||||
I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c);
|
||||
int timeout;
|
||||
|
||||
|
@ -135,8 +135,8 @@ inline int i2c_start(i2c_t *obj)
|
|||
// Clear Acknowledge failure flag
|
||||
__HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_AF);
|
||||
|
||||
// Generate the START condition
|
||||
i2c->CR1 |= I2C_CR1_START;
|
||||
// Generate the START condition and remove an eventual pending STOP bit
|
||||
i2c->CR1 = ((i2c->CR1 & ~I2C_CR1_STOP) | I2C_CR1_START);
|
||||
|
||||
// Wait the START condition has been correctly sent
|
||||
timeout = FLAG_TIMEOUT;
|
||||
|
|
Loading…
Reference in New Issue