From 60706521976e9322aea488c4a59c65475c74c2bc Mon Sep 17 00:00:00 2001 From: Mahadevan Mahesh Date: Fri, 16 Dec 2016 13:16:03 -0600 Subject: [PATCH] KSDK I2C: Update the return value to match the API documentation change Signed-off-by: Mahadevan Mahesh --- .../TARGET_KSDK2_MCUS/api/i2c_api.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api/i2c_api.c b/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api/i2c_api.c index 7b00d29b28..8cd50ca21c 100644 --- a/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api/i2c_api.c +++ b/targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api/i2c_api.c @@ -179,16 +179,20 @@ int i2c_byte_read(i2c_t *obj, int last) int i2c_byte_write(i2c_t *obj, int data) { + status_t ret_value; #if FSL_I2C_DRIVER_VERSION > MAKE_VERSION(2, 0, 1) - if (I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1, kI2C_TransferNoStopFlag) == kStatus_Success) { - return 1; - } + ret_value = I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1, kI2C_TransferNoStopFlag); #else - if (I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1) == kStatus_Success) { - return 1; - } + ret_value = I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1); #endif - return 0; + + if (ret_value == kStatus_Success) { + return 1; + } else if (ret_value == kStatus_I2C_Nak) { + return 0; + } else { + return 2; + } }