📄 1601driver.h
字号:
{ U16 SecID_Status; // Issue the Sec ID Entry code to 39VF160X *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 39VF160X // 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_U16_Program *//* *//* This procedure can be used to program data into the User SecID *//* segment (from 000010H--000017H) in 39VF160X. *//* *//* 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: *//* SrcU16 Source address to fetch data *//* Dst Destination address to write data *//* length number of U16 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_U16_Program (U16 *SrcU16, U16 *Dst, int length){ U16 *DestBuf = Dst; U16 *SourceBuf = SrcU16; U32 DestAddr; 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 DestAddr=(system_base + (U32)DestBuf)<<1;// transfer the U16 to destination *((volatile U16 *)DestAddr)= *SourceBuf; ++DestBuf; ++SourceBuf; // Read the toggle bit to detect end-of-write for the Sec ID. // Do Not use Data# Polling for User_SecID_U16_Program. test = Check_Toggle_Ready((U32)DestBuf); // wait for TOGGLE bit to get ready if (!test) return FALSE; // SecID U16-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 39VF160X. *//* *//* 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 U16-Program timeout, Tbp=10us}/************************************************************************//* PROCEDURE: Erase_Suspend *//* *//* This procedure can be used to temporarily suspend a Sector/Block- *//* Erase operation in 39VF160X. *//* *//* 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 39VF160X. *//* *//* 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 (U32 Dst){ U16 PreData; U16 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 U8 loaded during the page/U8-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 (U32 Dst, U16 TrueData){ U16 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;} #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -