Skip to content

Commit 42cfb84

Browse files
committed
M467: I2C: Fix potential role switch failure
Fix in i2c_do_trsn(), interrupt doesn't change back to enabled due to premature return.
1 parent e8dd9f4 commit 42cfb84

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

targets/TARGET_NUVOTON/TARGET_M460/i2c_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,13 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
444444
case 0x08: // Start
445445
case 0x10: // Master Repeat Start
446446
if (i2c_ctl & I2C_CTL0_STA_Msk) {
447-
return 0;
447+
goto cleanup;
448448
} else {
449449
break;
450450
}
451451
case 0xF8: // Bus Released
452452
if ((i2c_ctl & (I2C_CTL0_STA_Msk | I2C_CTL0_STO_Msk)) == I2C_CTL0_STO_Msk) {
453-
return 0;
453+
goto cleanup;
454454
} else {
455455
break;
456456
}
@@ -461,6 +461,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
461461
}
462462
}
463463

464+
cleanup:
465+
464466
i2c_enable_int(obj);
465467

466468
return err;

0 commit comments

Comments
 (0)