Обновление платы на V2
This commit is contained in:
parent
e9ea34e2e5
commit
d48eedf91f
23
CanUds.c
23
CanUds.c
|
|
@ -237,6 +237,17 @@ void SendUpdatePendingCrc(void *env) {
|
|||
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
|
||||
}
|
||||
|
||||
void SendUpdatePendingFlashClear(void *env) {
|
||||
|
||||
tCanUds *envUds = env;
|
||||
|
||||
if (SystemGetMs() > envUds->timeoutPendingClear) {
|
||||
setResponseErrorPending(env, UDS_RoutineControl, UDS_error_requestCorrectlyReceived_ResponsePending);
|
||||
envUds->timeoutPendingClear = SystemGetMs() + 200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void setDefaultSecurityAccess(tCanUds *env) {
|
||||
env->SA.requestSequenceRequestSeed = false;
|
||||
env->SA.stateSecurityAccess = false;
|
||||
|
|
@ -748,6 +759,8 @@ static uint16_t ECUReset_11(tCanUds *env) {
|
|||
return setResponseError(env, UDS_ECUResetService, UDS_error_conditionsNotCorrect);
|
||||
}
|
||||
|
||||
env->isEcuReset = true;
|
||||
|
||||
env->dataResponse[0] = UDS_ECUResetService | 0b1000000;;
|
||||
env->dataResponse[1] = env->data->data[1] & 0b01111111; // sub-function
|
||||
|
||||
|
|
@ -1031,11 +1044,13 @@ static uint16_t vUDS_routine_Erase_Memory(tCanUds *env, eUdsRoutineControlType u
|
|||
|
||||
|
||||
if (env->udsBlock == UDS_BlockMain) {
|
||||
result = env->clear_flash_func(ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain);
|
||||
env->timeoutPendingClear = SystemGetMs() + 200;
|
||||
result = env->clear_flash_func(ADR_HEX_Mapped_BlockMain, SIZE_HEX_BlockMain, SendUpdatePendingFlashClear, env);
|
||||
}
|
||||
|
||||
if (env->udsBlock == UDS_BlockCalib) {
|
||||
result = env->clear_flash_func(ADR_HEX_Mapped_BlockCalib, SIZE_HEX_BlockCalib);
|
||||
env->timeoutPendingClear = SystemGetMs() + 200;
|
||||
result = env->clear_flash_func(ADR_HEX_Mapped_BlockCalib, SIZE_HEX_BlockCalib, SendUpdatePendingFlashClear, env);
|
||||
}
|
||||
|
||||
// bool result = FLASHDRIVER_FlashEraseBlock(FLASH_BLOCK_SELECT1);
|
||||
|
|
@ -1851,6 +1866,10 @@ void ReceivedTP_func(void *arg, tCanTP_data *data) {
|
|||
asm("nop");
|
||||
}
|
||||
|
||||
if (env->isEcuReset) {
|
||||
SystemDelayMs(100);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
6
CanUds.h
6
CanUds.h
|
|
@ -158,7 +158,8 @@ typedef struct {
|
|||
uint8_t *data;
|
||||
} tUdsServiceCommand;
|
||||
|
||||
typedef bool (uds_clear_flash_func)(uint32_t firstPageAddr, uint32_t totalSize);
|
||||
typedef bool (uds_clear_flash_func)(uint32_t firstPageAddr, uint32_t totalSize, void *wdTriggerFct,
|
||||
void *wdTriggerFct_env);
|
||||
|
||||
typedef bool (uds_write_flash_func)(uint32_t beginPageAddr, void *sourceRamAddr, uint32_t size);
|
||||
|
||||
|
|
@ -212,6 +213,9 @@ typedef struct {
|
|||
uint32_t CurrentBlockAdr;
|
||||
uint32_t CurrentBlockSize;
|
||||
|
||||
bool isEcuReset;
|
||||
|
||||
uint32_t timeoutPendingClear;
|
||||
|
||||
eUdsServices stateDownload;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue