?? sst39vf640x_driver.c
字號:
// Issue the SecID Entry code to 39VF640X *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0088; // write data 0x0088 to device addr 0x5555 Delay_150_Nano_Seconds(); // insert delay time = Tida // Perform all Security ID operations here: // SST programmed segment is from address 000000H--000007H, // User programmed segment is from address 000010H--000017H. for (WORD index = 0x0000; index <= 0x0007; index++) { *SST_SecID = *sysAddress(index); ++SST_SecID; *User_SecID = *sysAddress(index+0x0010); ++User_SecID; // Security query data is stored in user-defined memory space. } // Issue the Sec ID Exit code thus returning the 39VF640X // to the read operating mode *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x00F0; // write data 0x00F0 to device addr 0x5555 Delay_150_Nano_Seconds(); // insert delay time = Tida}/************************************************************************//* PROCEDURE: Erase_One_Sector *//* *//* This procedure can be used to erase a total of 2048 words. *//* *//* Input: *//* Dst DESTINATION address where the erase operation starts *//* *//* Output: *//* return TRUE: indicates success in sector-erase *//* return FALSE: indicates failure in sector-erase *//************************************************************************/int Erase_One_Sector(Uint32 Dst){ Uint32 DestBuf = Dst; int ReturnStatus; // Issue the Sector Erase command to 39VF640X *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0080; // write data 0x0080 to device addr 0x5555 *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(DestBuf) = 0x0030; // write data 0x0030 to device sector addr ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready return ReturnStatus;}/************************************************************************//* PROCEDURE: Erase_One_Block *//* *//* This procedure can be used to erase a total of 32K words. *//* *//* Input: *//* Dst DESTINATION address where the erase operation starts *//* *//* Output: *//* return TRUE: indicates success in block-erase *//* return FALSE: indicates failure in block-erase *//************************************************************************/int Erase_One_Block (Uint32 Dst){ Uint32 DestBuf = Dst; int ReturnStatus; // Issue the Block Erase command to 39VF640X *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0080; // write data 0x0080 to device addr 0x5555 *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(DestBuf) = 0x0050; // write data 0x0050 to device sector addr ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready return ReturnStatus;}/************************************************************************//* PROCEDURE: Erase_Entire_Chip *//* *//* This procedure can be used to erase the entire chip. *//* *//* Input: *//* NONE *//* *//* Output: *//* NONE *//************************************************************************/void Erase_Entire_Chip(void){ // Issue the Chip Erase command to 39VF640X *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0080; // write data 0x0080 to device addr 0x5555 *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0010; // write data 0x0010 to device addr 0x5555 Delay_50_Milli_Seconds(); // Delay Tsce time}/************************************************************************//* PROCEDURE: Program_One_Word *//* *//* This procedure can be used to program ONE word of data to the *//* 39VF640X. *//* *//* NOTE: It is necessary to first erase the sector containing the *//* word to be programmed. *//* *//* Input: *//* SrcWord The WORD which will be written to the 39VF640X *//* Dst DESTINATION address which will be written with the *//* data passed in from Src *//* *//* Output: *//* return TRUE: indicates success in word-program *//* return FALSE: indicates failure in word-program *//************************************************************************/int Program_One_Word (WORD *SrcWord, Uint32 Dst){ Uint32 DestBuf = Dst; WORD *SourceBuf = SrcWord; int ReturnStatus; *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x00A0; // write data 0x00A0 to device addr 0x5555 *sysAddress(DestBuf) = *SourceBuf; // transfer the WORD to destination ReturnStatus = Check_Toggle_Ready(DestBuf); // wait for TOGGLE bit ready return ReturnStatus;}/************************************************************************//* PROCEDURE: Program_One_Sector *//* *//* This procedure can be used to program a total of 2048 words of data *//* to the SST39VF640X. *//* *//* NOTES: 1. It is necessary to first erase the sector before the *//* programming. *//* 2. This sample code assumes the destination address passed *//* from the calling function is the starting address of the *//* sector. *//* *//* Input: *//* Src SOURCE address containing the data which will be *//* written to the 39VF640X *//* Dst DESTINATION address which will be written with the *//* data passed in from Src *//* *//* Output: *//* return TRUE: indicates success in sector-program *//* return FALSE: indicates failure in sector-program *//************************************************************************/int Program_One_Sector (WORD *Src, Uint32 Dst){ WORD *SourceBuf; Uint32 DestBuf; int Index, ReturnStatus; SourceBuf = Src; DestBuf = Dst; ReturnStatus = Erase_One_Sector(DestBuf); // erase the sector first if (!ReturnStatus) return ReturnStatus; for (Index = 0; Index < SECTOR_SIZE; Index++) { // transfer data from source to destination ReturnStatus = Program_One_Word( SourceBuf, DestBuf); ++DestBuf; ++SourceBuf; if (!ReturnStatus) return ReturnStatus; } return ReturnStatus;}/************************************************************************//* PROCEDURE: Program_One_Block *//* *//* This procedure can be used to program a total of 32k words of data *//* to the SST39VF640X. *//* *//* NOTES: 1. It is necessary to first erase the block before the *//* programming. *//* 2. This sample code assumes the destination address passed *//* from the calling function is the starting address of the *//* block. *//* *//* Input: *//* Src SOURCE address containing the data which will be *//* written to the 39VF640X *//* Dst DESTINATION address which will be written with the *//* data passed in from Src *//* *//* Output: *//* return TRUE: indicates success in block-program *//* return FALSE: indicates failure in block-program *//************************************************************************/int Program_One_Block (WORD *Src, Uint32 Dst){ WORD *SourceBuf; Uint32 DestBuf; int Index, ReturnStatus; SourceBuf = Src; DestBuf = Dst; ReturnStatus = Erase_One_Block(DestBuf); // erase the block first if (!ReturnStatus) return ReturnStatus; for (Index = 0; Index < BLOCK_SIZE; Index++) { // transfer data from source to destination ReturnStatus = Program_One_Word( SourceBuf, DestBuf); ++DestBuf; ++SourceBuf;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -