mirror of https://github.com/ARMmbed/mbed-os.git
Nuvoton: I2C: Fix potential role switch failure
Fix in i2c_do_trsn(), interrupt doesn't change back to enabled due to premature return. Fix targets: - NUMAKER_PFM_NANO130 - NUMAKER_PFM_NUC472 - NUMAKER_PFM_M453 - NUMAKER_PFM_M487/NUMAKER_IOT_M487 - NUMAKER_IOT_M252 - NUMAKER_IOT_M263A - NU_M2354pull/15333/head
parent
807fd79651
commit
dbc0f5b2b3
|
@ -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