📄 lld.c
字号:
if(status != LLD_OK)
return(status);
/* Issue Autoselect Command Sequence */
for(; ; )
/* dummy loop for "break" */
{
status = HalWrite(base_addr + ulock_addr1, NOR_UNLOCK_DATA1,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + ulock_addr2, NOR_UNLOCK_DATA2,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + offset + ulock_addr1,
NOR_AUTOSELECT_CMD, err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* drop through */
break;
}
return(status);
}
/******************************************************************************
*
* lld_AutoselectExitCmd - Writes Autoselect Exit Command Sequence to Flash
*
* This function resets the device out of Autoselect mode.
* This is a "wrapper function" to provide "Enter/Exit" symmetry in
* higher software layers.
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_AutoselectExitCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
status = lld_ResetCmd(base_addr, offset, data_cfg, err_code_ptr, err_buf);
return(status);
}
/******************************************************************************
*
* lld_SecSiSecEnterCmd - Writes SecSi Sector Entry Command Sequence to Flash
*
* This function issues the Secsi Sector Entry Command Sequence to device.
* Use this function to Enable the SecSi Sector.
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_SecSiSecEnterCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
DWORD ulock_addr1;
DWORD ulock_addr2;
/*
* Reserved for Future Use.
* Trivial assignment to avoid compiler warnings
*/
offset = offset;
status = UnlockAddrsInit(&ulock_addr1, &ulock_addr2, data_cfg,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* Issue SecSi Sector Entry Command Sequence */
for(; ; )
/* dummy loop for "break" */
{
status = HalWrite(base_addr + ulock_addr1, NOR_UNLOCK_DATA1,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + ulock_addr2, NOR_UNLOCK_DATA2,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + ulock_addr1, NOR_SECSI_SECTOR_ENTRY_CMD,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* drop through */
break;
}
return(status);
}
/******************************************************************************
*
* lld_SecSiSecExitCmd - Writes SecSi Sector Exit Command Sequence to Flash
*
* This function issues the Secsi Sector Exit Command Sequence to device.
* Use this function to Exit the SecSi Sector.
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_SecSiSecExitCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
DWORD ulock_addr1;
DWORD ulock_addr2;
status = UnlockAddrsInit(&ulock_addr1, &ulock_addr2, data_cfg,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* Issue SecSi Sector Exit Command Sequence */
for(; ; )
/* dummy loop for "break" */
{
status = HalWrite(base_addr + ulock_addr1, NOR_UNLOCK_DATA1,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + ulock_addr2, NOR_UNLOCK_DATA2,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* First Secsi Sector Reset Command */
status = HalWrite(base_addr + ulock_addr1, NOR_SECSI_SECTOR_EXIT_SETUP_CMD,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
/* Second Secsi Sector Reset Command */
status = HalWrite(base_addr + offset, NOR_SECSI_SECTOR_EXIT_CMD,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
/* drop through */
break;
}
return(status);
}
/******************************************************************************
*
* lld_WrtToBufCmd - Writes "Write to Buffer Pgm" Command sequence to Flash
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_WrtToBufCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
DWORD ulock_addr1;
DWORD ulock_addr2;
status = UnlockAddrsInit(&ulock_addr1, &ulock_addr2, data_cfg,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* Issue Write To Buffer Command Sequence */
for(; ; )
/* dummy loop for "break" */
{
status = HalWrite(base_addr + ulock_addr1, NOR_UNLOCK_DATA1,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
status = HalWrite(base_addr + ulock_addr2, NOR_UNLOCK_DATA2,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
/* Write Write Buffer Load Command */
status = HalWrite(base_addr + offset, NOR_WRITE_BUFFER_LOAD_CMD,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
/* drop through */
break;
}
return(status);
}
/******************************************************************************
*
* lld_PgmBufToFlashCmd - Writes "Pgm Buffer To Flash" Cmd sequence to Flash
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_PgmBufToFlashCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
/*
* Reserved for Future Use.
* Trivial assignment to avoid compiler warnings
*/
data_cfg = data_cfg;
/* Transfer Buffer to Flash Command */
status = HalWrite(base_addr + offset, NOR_WRITE_BUFFER_PGM_CONFIRM_CMD,
err_code_ptr, err_buf);
#ifdef MIRRORBIT_DEVICE
/* Make sure we are not program suspended (E1) */
status = lld_ProgramResumeCmd(base_addr, offset, data_cfg, err_code_ptr, err_buf);
#endif
return(status);
}
/******************************************************************************
*
* lld_WrtToBufAbortResetCmd - Writes "Write To Buffer Abort" Reset to Flash
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors from UnlockAddrsInit
* errors generated by HAL functions
*/
int lld_WrtToBufAbortResetCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
DWORD ulock_addr1;
DWORD ulock_addr2;
/*
* Reserved for Future Use.
* Trivial assignment to avoid compiler warnings
*/
offset = offset;
status = UnlockAddrsInit(&ulock_addr1, &ulock_addr2, data_cfg,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* Issue Write Buffer Abort Reset Command Sequence */
for(; ; )
/* dummy loop for "break" */
{
status = HalWrite(base_addr + ulock_addr1, NOR_UNLOCK_DATA1,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
status = HalWrite(base_addr + ulock_addr2, NOR_UNLOCK_DATA2,
err_code_ptr, err_buf);
if(status != LLD_OK)
return(status);
/* Write to Buffer Abort Reset Command */
status = HalWrite(base_addr + ulock_addr1, NOR_WRITE_BUFFER_ABORT_RESET_CMD,
err_code_ptr, err_buf);
if(status != LLD_OK)
break;
/* drop through */
break;
}
return(status);
}
/******************************************************************************
*
* lld_ProgramSuspendCmd - Writes Suspend Command to Flash
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors generated by HAL functions
*/
int lld_ProgramSuspendCmd
(
ADDRESS base_addr, /* device base address in system */
DWORD offset, /* address offset from base address */
PARAM data_cfg, /* flash data width and # of devices */
PARAM *err_code_ptr, /* variable to store error code */
char *err_buf /* buffer to store error text */
)
{
int status = LLD_OK;
/*
* Reserved for Future Use.
* Trivial assignment to prevent compiler warnings
*/
data_cfg = data_cfg;
/* Write Suspend Command */
status = HalWrite(base_addr + offset, NOR_SUSPEND_CMD, err_code_ptr,
err_buf);
return(status);
}
/******************************************************************************
*
* lld_EraseSuspendCmd - Writes Suspend Command to Flash
*
*
* RETURNS: LLD_OK, or LLD_ERROR
*
* ERRNO:
* errors generated by HAL functions
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -