mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/i2c_api.c
- Revision:
- 247:135e3186a638
- Parent:
- 235:685d5f11838f
- Child:
- 305:1f0269907d8b
diff -r c22b0f22a58f -r 135e3186a638 targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/i2c_api.c --- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/i2c_api.c Tue Jul 01 06:15:07 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F411RE/i2c_api.c Tue Jul 01 15:00:09 2014 +0100 @@ -162,8 +162,6 @@ int count; int value; - if (length == 0) return 0; - i2c_start(obj); // Wait until SB flag is set @@ -171,7 +169,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_SB) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } @@ -183,7 +181,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_ADDR) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } __HAL_I2C_CLEAR_ADDRFLAG(&I2cHandle); @@ -214,7 +212,6 @@ int timeout; int count; - if (length == 0) return 0; i2c_start(obj); // Wait until SB flag is set @@ -222,7 +219,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_SB) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } @@ -234,7 +231,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_ADDR) == RESET) { timeout--; if (timeout == 0) { - return 0; + return -1; } } __HAL_I2C_CLEAR_ADDRFLAG(&I2cHandle); @@ -242,7 +239,7 @@ for (count = 0; count < length; count++) { if (i2c_byte_write(obj, data[count]) != 1) { i2c_stop(obj); - return 0; + return -1; } } @@ -271,7 +268,7 @@ timeout = FLAG_TIMEOUT; while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_RXNE) == RESET) { if ((timeout--) == 0) { - return 0; + return -1; } } @@ -368,7 +365,6 @@ { uint32_t Timeout; int size = 0; - if (length == 0) return 0; I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); @@ -379,7 +375,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_RXNE) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -401,7 +397,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_STOPF) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -413,7 +409,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY) == SET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -424,7 +420,6 @@ { uint32_t Timeout; int size = 0; - if (length == 0) return 0; I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c); @@ -434,7 +429,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_TXE) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -457,7 +452,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_AF) == RESET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } } @@ -471,7 +466,7 @@ while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY) == SET) { Timeout--; if (Timeout == 0) { - return 0; + return -1; } }