mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c
- Revision:
- 215:83cf97a28428
- Parent:
- 190:bde2479eef9e
- Child:
- 227:7bd0639b8911
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c Tue May 27 08:15:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/i2c_api.c Tue May 27 08:30:06 2014 +0100 @@ -317,10 +317,9 @@ uint32_t event; I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c); - event = I2C_GetLastEvent( i2c ); - if(event != 0) - { - switch(event){ + event = I2C_GetLastEvent(i2c); + if (event != 0) { + switch (event) { case I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED: retValue = WriteAddressed; break; @@ -335,22 +334,22 @@ break; } - // clear ADDR - if((retValue == WriteAddressed) || (retValue == ReadAddressed)){ + // clear ADDR + if ((retValue == WriteAddressed) || (retValue == ReadAddressed)) { i2c->SR1;// read status register 1 i2c->SR2;// read status register 2 } // clear stopf - if(I2C_GetFlagStatus(i2c, I2C_FLAG_STOPF) == SET) { + if (I2C_GetFlagStatus(i2c, I2C_FLAG_STOPF) == SET) { i2c->SR1;// read status register 1 - I2C_Cmd(i2c, ENABLE); + I2C_Cmd(i2c, ENABLE); } // clear AF - if(I2C_GetFlagStatus(i2c, I2C_FLAG_AF) == SET) { + if (I2C_GetFlagStatus(i2c, I2C_FLAG_AF) == SET) { I2C_ClearFlag(i2c, I2C_FLAG_AF); - } + } } - return(retValue); + return (retValue); } int i2c_slave_read(i2c_t *obj, char *data, int length) {