Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuvoton: I2C: Fix potential role switch failure #15333

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M2354/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL0_STA_Msk) {
return 0;
goto cleanup;
} else {
break;
}
case 0xF8: // Bus Released
if ((i2c_ctl & (I2C_CTL0_STA_Msk | I2C_CTL0_STO_Msk)) == I2C_CTL0_STO_Msk) {
return 0;
goto cleanup;
} else {
break;
}
Expand All @@ -458,6 +458,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
Expand Down
6 changes: 4 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M251/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,13 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL0_STA_Msk) {
return 0;
goto cleanup;
} else {
break;
}
case 0xF8: // Bus Released
if ((i2c_ctl & (I2C_CTL0_STA_Msk | I2C_CTL0_STO_Msk)) == I2C_CTL0_STO_Msk) {
return 0;
goto cleanup;
} else {
break;
}
Expand All @@ -442,6 +442,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
Expand Down
6 changes: 4 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M261/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL0_STA_Msk) {
return 0;
goto cleanup;
} else {
break;
}
case 0xF8: // Bus Released
if ((i2c_ctl & (I2C_CTL0_STA_Msk | I2C_CTL0_STO_Msk)) == I2C_CTL0_STO_Msk) {
return 0;
goto cleanup;
} else {
break;
}
Expand All @@ -447,6 +447,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
Expand Down
8 changes: 5 additions & 3 deletions targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,14 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL_STA_Msk) {
return 0;
goto cleanup;
}
else {
break;
}
case 0xF8: // Bus Released
if (i2c_ctl & (I2C_CTL_STA_Msk | I2C_CTL_STO_Msk) == I2C_CTL_STO_Msk) {
return 0;
goto cleanup;
}
else {
break;
Expand All @@ -472,8 +472,10 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
}

Expand Down
6 changes: 4 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,13 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL0_STA_Msk) {
return 0;
goto cleanup;
} else {
break;
}
case 0xF8: // Bus Released
if ((i2c_ctl & (I2C_CTL0_STA_Msk | I2C_CTL0_STO_Msk)) == I2C_CTL0_STO_Msk) {
return 0;
goto cleanup;
} else {
break;
}
Expand All @@ -449,6 +449,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
Expand Down
8 changes: 5 additions & 3 deletions targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CON_START_Msk) {
return 0;
goto cleanup;
}
else {
break;
}
case 0xF8: // Bus Released
if ((i2c_ctl & (I2C_CON_START_Msk | I2C_CON_STOP_Msk)) == I2C_CON_STOP_Msk) {
return 0;
goto cleanup;
}
else {
break;
Expand All @@ -492,8 +492,10 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
}

Expand Down
8 changes: 5 additions & 3 deletions targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
case 0x08: // Start
case 0x10: // Master Repeat Start
if (i2c_ctl & I2C_CTL_STA_Msk) {
return 0;
goto cleanup;
}
else {
break;
}
case 0xF8: // Bus Released
if (i2c_ctl & (I2C_CTL_STA_Msk | I2C_CTL_STO_Msk) == I2C_CTL_STO_Msk) {
return 0;
goto cleanup;
}
else {
break;
Expand All @@ -489,8 +489,10 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync)
}
}

cleanup:

i2c_enable_int(obj);

return err;
}

Expand Down