diff --git a/CanUds.c b/CanUds.c index 89bcb63..8fa17bc 100644 --- a/CanUds.c +++ b/CanUds.c @@ -1040,22 +1040,25 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending); - bool result = false; + bool result1 = false; + bool result2 = false; if (env->udsBlock == UDS_BlockMain) { env->timeoutPendingClear = SystemGetMs() + 200; - result = env->clear_flash_func(ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain, SendUpdatePendingFlashClear, env); + result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockMain, (SIZE_HEX_BlockMain / 2), SendUpdatePendingFlashClear, env); + setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending); + result2 = env->clear_flash_func(ADR_HEX_Mapped_BlockMain + (SIZE_HEX_BlockMain / 2), (SIZE_HEX_BlockMain / 2), SendUpdatePendingFlashClear, env); } if (env->udsBlock == UDS_BlockCalib) { env->timeoutPendingClear = SystemGetMs() + 200; - result = env->clear_flash_func(ADR_HEX_Mapped_BlockCalib, SIZE_HEX_BlockCalib, SendUpdatePendingFlashClear, env); + result1 = env->clear_flash_func(ADR_HEX_Mapped_BlockCalib, SIZE_HEX_BlockCalib, SendUpdatePendingFlashClear, env); } // bool result = FLASHDRIVER_FlashEraseBlock(FLASH_BLOCK_SELECT1); - if (result) { + if ((result1) || (result2)) { env->dataResponse[4] = UDS_routine_RoutineStartStopSuccess; } else {