Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLafleur committed Nov 24, 2024
1 parent 7dcc0b5 commit 0e94ece
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
25 changes: 21 additions & 4 deletions components/bms_boss/src/UDS.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,32 @@ static void routine_0xf0f0(udsRoutineControlType_E routineControlType, uint8_t *
switch (routineControlType)
{
case UDS_ROUTINE_CONTROL_START:
bool completed = true;
{
uds_sendPositiveResponse(UDS_SID_ROUTINE_CONTROL,
UDS_SUB_FUNCTION_NONE,
(uint8_t*)&completed,
sizeof(completed));
UDS_ROUTINE_CONTROL_START,
payload,
payloadLengthBytes);
lib_nvm_nvmHardReset();
}
break;

case UDS_ROUTINE_CONTROL_GET_RESULT:
{
bool completed = lib_nvm_nvmHardResetGetStatus();
if (completed)
{
uds_sendPositiveResponse(UDS_SID_ROUTINE_CONTROL,
UDS_ROUTINE_CONTROL_GET_RESULT,
(uint8_t*)&completed,
sizeof(completed));
}
else
{
uds_sendNegativeResponse(UDS_SID_ROUTINE_CONTROL, UDS_NRC_CONDITIONS_NOT_CORRECT);
}
}
break;

case UDS_ROUTINE_CONTROL_STOP:
case UDS_ROUTINE_CONTROL_NONE:
default:
Expand Down
9 changes: 9 additions & 0 deletions components/shared/code/libs/LIB_nvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ typedef struct

typedef struct
{
bool hardResetCompleted;
#if FEATURE_IS_ENABLED(NVM_FLASH_BACKED)
uint32_t pageSize;
storage_t* currentPtr;
Expand Down Expand Up @@ -290,10 +291,18 @@ bool lib_nvm_nvmHardReset(void)
lib_nvm_blockHeader_S* currentBlock = (lib_nvm_blockHeader_S*)getBlockBaseAddress((uint32_t)data.currentPtr);
initializeNVMBlock(getNextBlockStart((uint32_t)data.currentPtr));
invalidateBlock(currentBlock);
data.hardResetCompleted = true;

return ret;
}

bool lib_nvm_nvmHardResetGetStatus(void)
{
bool ret = data.hardResetCompleted;
data.hardResetCompleted = false;
return ret;
}

void lib_nvm_requestWrite(lib_nvm_entryId_E entryId)
{
requestWritePrivate(entryId + NVM_ENTRYID_INTERNAL_COUNT);
Expand Down
1 change: 1 addition & 0 deletions components/shared/code/libs/LIB_nvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void lib_nvm_init(void);
void lib_nvm_run(void);

bool lib_nvm_nvmHardReset(void);
bool lib_nvm_nvmHardResetGetStatus(void);
void lib_nvm_requestWrite(lib_nvm_entryId_E entryId);

uint32_t lib_nvm_getTotalRecordWrites(void);
Expand Down

0 comments on commit 0e94ece

Please sign in to comment.