mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #15333 from OpenNuvoton/nuvoton_fix_i2c_role_switch
Nuvoton: I2C: Fix potential role switch failurepull/15341/head
commit
7bb01c1eb3
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue