Skip to content

Commit

Permalink
updated get test date to unlock lock info block
Browse files Browse the repository at this point in the history
  • Loading branch information
EricB-ADI committed Oct 25, 2024
1 parent 8dc43d3 commit 4266b04
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Libraries/PeriphDrivers/Source/SYS/sys_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "gcr_regs.h"
#include "fcr_regs.h"
#include "mcr_regs.h"

#include <stdbool.h>

/**
* @ingroup mxc_sys
Expand All @@ -51,7 +51,7 @@

/* **** Globals **** */
static mxc_sys_package_type_t pkg_type = MXC_SYS_PKG_UNSET;

bool info_block_unlocked = false;
/* **** Functions **** */

/* ************************************************************************** */
Expand All @@ -63,29 +63,24 @@ mxc_sys_package_type_t MXC_SYS_GetPackageType(void)
}

mxc_sys_date_t date;
mxc_sys_date_t date_info;

MXC_FLC_UnlockInfoBlock(MXC_INFO_MEM_BASE);

MXC_SYS_GetTestDate(&date_info);

// Package codes were only introduced when test date was
int err = MXC_SYS_GetTestDate(&date);

if(err != E_NO_ERROR)
{
pkg_type = MXC_SYS_PKG_UNSET;
return MXC_SYS_PKG_UNSET;
}
else
{
const uint8_t maybe_pkg_type = REG8_VAL(PKG_CODE_OFFSET);
int err = MXC_SYS_SetPackageType(maybe_pkg_type);
MXC_ASSERT(err == E_NO_ERROR);
}



MXC_FLC_UnlockInfoBlock(MXC_INFO_MEM_BASE);

const uint8_t maybe_pkg_type = REG8_VAL(PKG_CODE_OFFSET);
int err = MXC_SYS_SetPackageType(maybe_pkg_type);

MXC_FLC_LockInfoBlock(MXC_INFO_MEM_BASE);

MXC_ASSERT(err == E_NO_ERROR);


return pkg_type;
}
Expand All @@ -108,10 +103,15 @@ int MXC_SYS_SetPackageType(mxc_sys_package_type_t new_pkg_type)
int MXC_SYS_GetTestDate(mxc_sys_date_t *date_info)
{
MXC_ASSERT(date_info);



MXC_FLC_UnlockInfoBlock(MXC_INFO_MEM_BASE);

date_info->day = REG8_VAL(DAY_CODE_OFFSET);
date_info->month = REG8_VAL(MONTH_CODE_OFFSET);
date_info->year = REG8_VAL(YEAR_CODE_OFFSET);

MXC_FLC_LockInfoBlock(MXC_INFO_MEM_BASE);

// Flash is cleared if not valid
// Year 2255 is valid
Expand Down

0 comments on commit 4266b04

Please sign in to comment.