📄 sst49lf008a.txt
字号:
/* Input: */
/* None */
/* */
/* Output: */
/* return status byte */
/************************************************************************/
BYTE Read_T_MINUS15_LK_Register()
{
return (*(volatile BYTE *)(SST_49LF008A_T_MINUS15_LKReg));
}
/************************************************************************/
/* PROCEDURE: Write_T_MINUS15_LK_Register (FWH mode) */
/* */
/* This sample subroutine writes new status byte to block locking reg. */
/* T_MINUS15_LK_Register of Boot Device(Device #0) of SST49LF008A */
/* */
/* The address of T_MINUS15_LK_Register = FFB00002H */
/* */
/* Input: */
/* Status the new status byte to be written */
/* */
/* Output: */
/* None */
/************************************************************************/
void Write_T_MINUS15_LK_Register(BYTE Status)
{
*(volatile BYTE *)(SST_49LF008A_T_MINUS15_LKReg) = Status;
}
/************************************************************************/
/* PROCEDURE: Erase_Block_T_MINUS15 (FWH Mode) */
/* */
/* This sample subroutine can be used to erase the block of T_MINUS15 */
/* in Boot Device (Devoce #0) of SST49LF008A in FWH mode. */
/* */
/* SST49LF008A has 16 uniform, 64 KByte blocks: T_BLOCK, T_MINUS01 -- */
/* T_MINUS15. */
/* */
/* The block of T_MINUS15 has an address range from FFF0FFFFH -- */
/* FFF00000H in the System of 4Gbytes Memory Map and its block locking */
/* register: T_MINUS15_LK_Register = FFB00002H. */
/* */
/* Before erasing the block, the user needs to unlock the block first. */
/* To unlock the block, the user needs to refer two sample subroutines */
/* Read_T_MINUS15_LK_Register() and Write_T_MINUS15_LK_Register(). */
/* */
/* Input: */
/* Dst DESTINATION address at which the erase operation will */
/* start. */
/* Output: */
/* return TRUE: indicate the erase of T_MINUS15 block is success */
/* return FALSE: indicate the block erase is failed */
/************************************************************************/
int Erase_Block_T_MINUS15()
{
BYTE data1;
/* read the status byte from T_MINUS15_LK_Register */
data1 = Read_T_MINUS15_LK_Register();
data1 &= 0x03; /* mask D[7:2] of status byte */
if (data1 == 0x03)
{ /* 0x03: the Write Lock Bit is lock-down */
return (FALSE); /* return FALSE to indicate Block-erase is failed */
}
if (data1 == 0x01) /* 0x01: the Write Lock Bit is set */
{ /* To unlock the block, write 0x00 to block locking register */
Write_T_MINUS15_LK_Register( 0x00 );
data1 = Read_T_MINUS15_LK_Register(); /* read the status byte */
data1 &= 0x03; /* mask D[7:2] of status */
if (data1 != 0x00)
{ /* unlock the block is failed */
return (FALSE);
}
}
/* point to a valid address of block T_MINUS15 which is range */
/* from FFF0FFFFH -- FFF00000H */
Erase_One_Block(0xFFF00000);
/* Issue the Block Erase command to 49LF008A */
return (TRUE);
}
/************************************************************************/
/* PROCEDURE: Program_One_Byte (FWH/PP Mode) */
/* */
/* This procedure can be used to program ONE byte of data to the */
/* 49LF008A. */
/* */
/* In FWH mode, the block containning the byte to be programmed needs */
/* to be unlocked first. Please refer the sample routine */
/* Erase_Block_T_MINUS15() for a detail of usage. */
/* */
/* NOTE: It is mandatory that the sector containing the byte to be */
/* programmed was ERASED first. */
/* */
/* Input: */
/* Src The BYTE which will be written to the 49LF008A. */
/* Dst device address which will be written */
/* with the data passed in from SrcByte */
/* */
/* Output: */
/* None */
/************************************************************************/
void Program_One_Byte (BYTE *Src, Uint32 Dst)
{
Uint32 DestBuf = Dst;
BYTE *SourceBuf = Src;
sysAddress(0x5555) = 0xAA; /* write data 0xAA to device addr 0x5555*/
sysAddress(0x2AAA) = 0x55; /* write data 0x55 to device addr 0x2AAA*/
sysAddress(0x5555) = 0xA0; /* write data 0x80 to device addr 0x5555*/
sysAddress(DestBuf) = *SourceBuf;/* transfer the byte to destination*/
Check_Toggle_Ready(DestBuf);/* wait for TOGGLE bit to get ready */
}
/************************************************************************/
/* PROCEDURE: Program_One_Sector (FWH/PP Mode) */
/* */
/* This procedure can be used to program a total of 4096 bytes of data */
/* to the SST's 49LF008A. */
/* */
/* In FWH mode, the block to be programmed needs to be unlocked first. */
/* Please refers the sample routine */
/* Erase_Block_T_MINUS15() for a detail of usage. */
/* */
/* Input: */
/* Src source buffer containing the data which will be */
/* written to the 49LF008A. */
/* Dst device address which will be written with the */
/* data passed in from Src */
/* */
/* Output: */
/* None */
/************************************************************************/
void Program_One_Sector ( BYTE *Src, Uint32 Dst)
{
BYTE *SourceBuf;
Uint32 DestBuf;
int Index;
SourceBuf = Src;
DestBuf = Dst;
Erase_One_Sector(DestBuf); /* erase the sector first */
for (Index = 0; Index < SECTOR_SIZE; Index++)
{
sysAddress(0x5555) = 0xAA; /* write data 0xAA to device addr 0x5555*/
sysAddress(0x2AAA) = 0x55; /* write data 0x55 to device addr 0x2AAA*/
sysAddress(0x5555) = 0xA0; /* write data 0x80 to device addr 0x5555*/
sysAddress(DestBuf) = *SourceBuf++;/*transfer the byte to destination*/
DestBuf++;
Check_Toggle_Ready(DestBuf);/* wait for TOGGLE bit to get ready */
}
}
/************************************************************************/
/* PROCEDURE: Program_One_Block (FWH/PP Mode) */
/* */
/* This procedure can be used to program a total of 64 Kbytes of data */
/* to the SST's 49LF008A. */
/* */
/* Input: */
/* Src SOURCE address containing the data which will be */
/* written to the 49LF008A. */
/* Dst DESTINATION device address which will be written */
/* with the data passed in from Src */
/* */
/* Output: */
/* None */
/************************************************************************/
void Program_One_Block (BYTE *Src, Uint32 Dst)
{
BYTE *SourceBuf;
int DestBuf;
long Index;
SourceBuf = Src;
DestBuf = Dst;
Erase_One_Block(Dst); /* erase the block first */
for (Index = 0L; Index < BLOCK_SIZE; Index++)
{
sysAddress(0x5555) = 0xAA; /* write data 0xAA to device addr 0x5555*/
sysAddress(0x2AAA) = 0x55; /* write data 0x55 to device addr 0x2AAA*/
sysAddress(0x5555) = 0xA0; /* write data 0x80 to device addr 0x5555*/
sysAddress(DestBuf) = *SourceBuf++;/* transfer the byte to destination*/
DestBuf++;
Check_Toggle_Ready(DestBuf); /* wait for TOGGLE bit to get ready */
}
}
/************************************************************************/
/* PROCEDURE: Check_Toggle_Ready (FWH/PP Mode) */
/* */
/* During the internal program cycle, any consecutive read operation */
/* on DQ6 will produce alternating 0's and 1's i.e. toggling between */
/* 0 and 1. When the program cycle is completed, DQ6 of the data will */
/* stop toggling. After the DQ6 data bit stops toggling, the device is */
/* ready for next operation. */
/* */
/* Input: */
/* Dst must already be set-up by the caller */
/* */
/* Output: TRUE Data toggling success */
/* FALSE Time out */
/************************************************************************/
int Check_Toggle_Ready (Uint32 Dst)
{
BYTE PreData;
BYTE CurrData;
unsigned long TimeOut = 0;
PreData = sysAddress(Dst);
PreData = PreData & 0x40; /*read DQ6*/
while (TimeOut< 0x07FFFFFF)
{
CurrData = sysAddress(Dst);
CurrData = CurrData & 0x40; /*read DQ6 again*/
if (PreData == CurrData)
return TRUE;
PreData = CurrData;
TimeOut++;
}
return FALSE;
}
/************************************************************************/
/* PROCEDURE: Check_Data_Polling (FWH/PP Mode) */
/* */
/* During the internal program cycle, any attempt to read DQ7 of the */
/* last byte loaded during the page/byte-load cycle will receive the */
/* complement of the true data. Once the program cycle is completed, */
/* DQ7 will show true data. */
/* */
/* Input: */
/* Dst must already be set-up by the caller */
/* TrueData this is the original (true) data */
/* */
/* Output: */
/* TRUE Data polling success */
/* FALSE Time out */
/************************************************************************/
int Check_Data_Polling (Uint32 Dst, BYTE TrueData)
{
BYTE CurrData;
unsigned long int TimeOut = 0;
TrueData = TrueData & 0x80; /*read D7*/
while (TimeOut< 0x07FFFFFF)
{
CurrData = sysAddress(Dst);
CurrData = CurrData & 0x80; /*read DQ7*/
if (TrueData == CurrData)
return TRUE;
TimeOut++;
}
return FALSE;
}
/************************************************************************/
/* PROCEDURE: Read_SST49LF008A_GPI_Rigister (FWH Mode) */
/* */
/* This procedure fetches the content of GPI Reigster of the device, */
/* which is in the address 0xFFBC0100 for boot device. It's recommended */
/* that the GPI[4:0] pins be in the desired state before LFRAME# is */
/* brought low for the beginning of the next bus cycle, and remain in */
/* that state until the end of the cycle. */
/* */
/* Input: */
/* None */
/* Output: */
/* GPI register value */
/************************************************************************/
BYTE Read_SST49LF008_GPI_Rigister()
{
return ((*(volatile BYTE *)(SST_49LF008A_GPI)) & 0x1F);/*mask data[7:5]*/
}
; ======================================================================
; Copyright Silicon Storage Technology, Inc. (SST), 1994-2003
; EXAMPLE x86 Assembly Language Drivers for 49LF008A, 8 Mbit
; Firmware Hub Flash with Top Boot-Block
; Frank Cirimele, Silicon Storage Technology, Inc.
;
; Revision 1.1, March 31, 2003
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -