?? sst39vf640x_driver.c
字號:
if (!ReturnStatus) return ReturnStatus; } return ReturnStatus;}/************************************************************************//* PROCEDURE: SecID_Lock_Status *//* *//* This procedure should be used to check the Lock Status of SecID *//* *//* Input: *//* None *//* *//* Output: *//* return TRUE: indicates SecID is Locked *//* return FALSE: indicates SecID is Unlocked *//************************************************************************/int SecID_Lock_Status(void){ WORD SecID_Status; // Issue the Sec ID 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 // Read Lock Status of SecID segment SecID_Status = *sysAddress(0x00FF); SecID_Status &= 0x0008; // Unlocked: DQ3=1; Locked: DQ3=0 // 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 if (!SecID_Status) return TRUE; // SecID segment is Locked return FALSE; // SecID segment is Unlocked}/************************************************************************//* PROCEDURE: User_SecID_Word_Program *//* *//* This procedure can be used to program data into the User SecID *//* segment (from 000010H--000017H) in 39VF640X. *//* *//* NOTE: 1. It's recommended to lock out the SecID segment after the *//* completion of program. *//* 2. There's no way to unlock the SecID segment once it's */ /* locked. *//* *//* Input: *//* SrcWord Source address to fetch data *//* Dst Destination address to write data *//* length number of word needs to be programmed *//* *//* Output: *//* return TRUE: indicates SecID program is successful *//* return FALSE: indicates SecID program is failed or SecID *//* is locked. *//************************************************************************/int User_SecID_Word_Program (WORD *SrcWord, WORD *Dst, int length){ WORD *DestBuf = Dst; WORD *SourceBuf = SrcWord; int test, index=length; test = SecID_Lock_Status (); // check whether the SecID is Locked or not if (test) // TRUE: SecID is Locked return FALSE; while (index--) { *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x00A5; // write data 0x00A5 to device addr 0x5555 *sysAddress(DestBuf) = *SourceBuf; // transfer the WORD to destination ++DestBuf; ++SourceBuf; // Read the toggle bit to detect end-of-write for the Sec ID. // Do Not use Data# Polling for User_SecID_Word_Program. test = Check_Toggle_Ready((Uint32)DestBuf); // wait for TOGGLE bit to get ready if (!test) return FALSE; // SecID Word-Program failed! } return TRUE;}/************************************************************************//* PROCEDURE: User_SecID_Lock_Out *//* *//* This procedure can be used to Lock Out the User Seccurity ID. *//* User Security ID segment, from 000010H--000017H, in 39VF640X. *//* *//* NOTE: 1. Call SecID_Lock_Status() first to verify the SecID is *//* unlocked. *//* 2. SecID segment can't be erased. *//* 3. SecID segment can't be unlocked once it's locked. *//* *//* Input: None *//* *//* Output: None *//************************************************************************/void User_SecID_Lock_Out (void){ *sysAddress(0x5555) = 0x00AA; // write data 0x00AA to device addr 0x5555 *sysAddress(0x2AAA) = 0x0055; // write data 0x0055 to device addr 0x2AAA *sysAddress(0x5555) = 0x0085; // write data 0x0085 to device addr 0x5555 *sysAddress(0x00FF) = 0x0000; // write data 0x0000 to any addr Delay_10_Micro_Seconds(); // Wait for Word-Program timeout, Tbp=10us}/************************************************************************//* PROCEDURE: Erase_Suspend *//* *//* This procedure can be used to temporarily suspend a Sector/Block- *//* Erase operation in 39VF640X. *//* *//* Input: None *//* *//* Output: None *//************************************************************************/void Erase_Suspend (void){ *sysAddress(0x5555) = 0x00B0; // write data 0x00B0 to any addr, i.e. 0x5555 Delay_20_Micro_Seconds(); // The device automatically enters read mode // typically within 20 us after the Erase-Suspend command issued.}/************************************************************************//* PROCEDURE: Erase_Resume *//* *//* This procedure can be used to resume a Sector-Erase or Block-Erase *//* operation that had been suspended in 39VF640X. *//* *//* Input: None *//* *//* Output: None *//************************************************************************/void Erase_Resume (void){ *sysAddress(0x5555) = 0x0030; // write data 0x0030 to any addr, i.e. 0x5555}/************************************************************************//* PROCEDURE: Check_Toggle_Ready *//* *//* 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){ WORD PreData; WORD CurrData; unsigned long TimeOut = 0; PreData = *sysAddress(Dst); PreData = PreData & 0x0040; // read DQ6 while (TimeOut < MAX_TIMEOUT) // MAX_TIMEOUT=0x07FFFFFF { CurrData = *sysAddress(Dst); CurrData = CurrData & 0x0040; // read DQ6 again if (PreData == CurrData) { return TRUE; } PreData = CurrData; TimeOut++; } return FALSE;} /************************************************************************//* PROCEDURE: Check_Data_Polling *//* *//* 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, WORD TrueData){ WORD CurrData; unsigned long int TimeOut = 0; TrueData = TrueData & 0x0080; // read D7 while (TimeOut < MAX_TIMEOUT) // MAX_TIMEOUT=0x07FFFFFF { CurrData = *sysAddress(Dst); CurrData = CurrData & 0x0080; // read DQ7 if (TrueData == CurrData) { return TRUE; } TimeOut++; } return FALSE;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -