Skip to content

Commit 20eb127

Browse files
authored
Merge pull request #3460 from NXPmicro/I2C_UpdateReturnValue
KSDK I2C: Update the return value to match the API documentation change
2 parents 1cc1891 + 8ec93ca commit 20eb127

File tree

1 file changed

+10
-6
lines changed
  • targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api

1 file changed

+10
-6
lines changed

targets/TARGET_Freescale/TARGET_KSDK2_MCUS/api/i2c_api.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,20 @@ int i2c_byte_read(i2c_t *obj, int last)
179179

180180
int i2c_byte_write(i2c_t *obj, int data)
181181
{
182+
status_t ret_value;
182183
#if FSL_I2C_DRIVER_VERSION > MAKE_VERSION(2, 0, 1)
183-
if (I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1, kI2C_TransferNoStopFlag) == kStatus_Success) {
184-
return 1;
185-
}
184+
ret_value = I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1, kI2C_TransferNoStopFlag);
186185
#else
187-
if (I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1) == kStatus_Success) {
186+
ret_value = I2C_MasterWriteBlocking(i2c_addrs[obj->instance], (uint8_t *)(&data), 1);
187+
#endif
188+
189+
if (ret_value == kStatus_Success) {
188190
return 1;
191+
} else if (ret_value == kStatus_I2C_Nak) {
192+
return 0;
193+
} else {
194+
return 2;
189195
}
190-
#endif
191-
return 0;
192196
}
193197

194198

0 commit comments

Comments
 (0)