mbed library sources
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c
- Revision:
- 247:135e3186a638
- Parent:
- 227:7bd0639b8911
- Child:
- 305:1f0269907d8b
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c Tue Jul 01 06:15:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/i2c_api.c Tue Jul 01 15:00:09 2014 +0100 @@ -155,8 +155,6 @@ int count; int value; - if (length == 0) return 0; - i2c_start(obj); // Wait until SB flag is set @@ -164,7 +162,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_SB) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } @@ -176,7 +174,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_ADDR) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } __HAL_I2C_CLEAR_ADDRFLAG(&I2cHandle); @@ -206,7 +204,6 @@ int timeout; int count; - if (length == 0) return 0; i2c_start(obj); // Wait until SB flag is set @@ -214,7 +211,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_SB) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } @@ -226,7 +223,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_ADDR) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } __HAL_I2C_CLEAR_ADDRFLAG(&I2cHandle); @@ -234,7 +231,7 @@ for (count = 0; count < length; count++) { if (i2c_byte_write(obj, data[count]) != 1) { i2c_stop(obj); - return 0; + return -1; } } @@ -262,7 +259,7 @@ timeout = FLAG_TIMEOUT; while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_RXNE) == RESET) { if ((timeout--) == 0) { - return 0; + return -1; } } @@ -353,7 +350,6 @@ int i2c_slave_read(i2c_t *obj, char *data, int length) { uint32_t Timeout; int size = 0; - if (length == 0) return 0; I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); @@ -364,7 +360,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_RXNE) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -386,7 +382,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_STOPF) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -398,7 +394,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY) == SET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -408,7 +404,6 @@ int i2c_slave_write(i2c_t *obj, const char *data, int length) { uint32_t Timeout; int size = 0; - if (length == 0) return 0; I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); @@ -418,7 +413,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_TXE) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -441,7 +436,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_AF) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -455,7 +450,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY) == SET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } }