⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sst39vf400a.c

📁 外设存储器接口程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************************************\

The C code in the document contain the following routines,
in this order:

Name                    Function
------------------------------------------------------------------
Check_SST_39VF400A      Check manufacturer and device ID
CFI_Query               CFI Query Entry/Exit command sequence
Erase_One_Sector        Erase a sector of 2048 words
Erase_One_Block         Erase a block of 32K words
Erase_Entire_Chip       Erase the contents of the entire chip
Program_One_Word        Alter data in one word
Program_One_Sector      Alter data in 2048 word sector
Program_One_Block       Alter data in 32K word block
Check_Toggle_Ready      End of internal program or erase detection using
                        Toggle bit
Check_Data_Polling      End of internal program or erase detection using
                        Data# polling


"C" LANGUAGE DRIVERS
*****************************************************************************************************/

/***********************************************************************/
/* Copyright Silicon Storage Technology, Inc. (SST), 1994-2001         */
/* Example "C" language Driver of 39VF400A 4 Mbit Multi-Purpose Flash  */
/* Nelson Wang, Silicon Storage Technology, Inc.                       */
/*                                                                     */
/* Revision 1.0, Sept. 12, 2001                                        */
/*                                                                     */
/* This file requires these external "timing"  routines:               */
/*                                                                     */
/*      1.)  Delay_150_Nano_Seconds                                    */
/*      2.)  Delay_25_Milli_Seconds                                    */
/*      3.)  Delay_100_Milli_Seconds                                   */
/***********************************************************************/

#define FALSE                   0
#define TRUE                    1

#define SECTOR_SIZE             2048    /* Must be 2048 words for 39VF400A */
#define BLOCK_SIZE              32768   /* Must be 32K words for 39VF400A  */

#define SST_ID                  0x00BF  /* SST Manufacturer's ID code   */
#define SST_39VF400A            0x2780  /* SST39VF400A device code      */
                                        /* same device code as SST39VF400 */

/* Regard to data space flash located , take word address */

#define Addr5555	(WORD  *)0x205555	/* typedef unsigned int  WORD */
#define Addr2AAA	(WORD  *)0x202AAA
#define Addr0000	(WORD  *)0x200000
#define Addr0001	(WORD  *)0x200001

typedef unsigned char           BYTE;
typedef unsigned int            WORD;		

/* -------------------------------------------------------------------- */
/*                       EXTERNAL ROUTINES                              */
/* -------------------------------------------------------------------- */

void     Delay_150_Nano_Seconds();
void     Delay_25_Milli_Seconds();
void     Delay_100_Milli_Seconds();
void 	 Check_Toggle_Ready();
void     Check_Data_Polling();

/************************************************************************/
/* PROCEDURE:   Check_SST_39VF400A                                      */
/*                                                                      */
/* This procedure decides whether a physical hardware device has a      */
/* SST39VF400A 4 Mbit Multi-Purpose Flash installed or not.             */
/*                                                                      */
/* Input:                                                               */
/*          None                                                        */
/*                                                                      */
/* Output:                                                              */
/*          return TRUE:  indicates a SST39VF400A                       */
/*          return FALSE: indicates not a SST39VF400A                   */
/************************************************************************/

extern int Check_SST_39VF400A(void)              /* same device code as SST39VF400 */
{
        WORD  * Temp;
        WORD SST_id1;
        WORD  * Temp1;
        WORD SST_id2;
        int  ReturnStatus;

        /*  Issue the Software Product ID code to 39VF400A   */

        Temp1 = Addr5555; /* set up address to be C000:5555h  */
      
      	*Temp1= 0xAAAA;   /* write data 0xAAAA to the address */
        
        Temp1 = Addr2AAA; /* set up address to be C000:2AAAh  */
        *Temp1= 0x5555;   /* write data 0x5555 to the address */
        Temp1 = Addr5555; /* set up address to be C000:5555h  */
        *Temp1= 0x9090;   /* write data 0x9090 to the address */

        Delay_150_Nano_Seconds();       /* insert delay time = Tida         */

        /* Read the product ID from 39VF400A */

        Temp  = Addr0000; 				/* set up address to be C000:0000h */
        SST_id1  =  *Temp;              /* get first ID word               */
        SST_id1  =  SST_id1 & 0xFF;     /* mask of higher byte             */
        Temp1 = Addr0001; 				/* set up address to be C000:0001h */
        SST_id2  =  *Temp1;             /* get second ID word              */

        /* Determine whether there is a SST39VF400A installed or not */

        if ((SST_id1 == SST_ID) && (SST_id2 ==SST_39VF400A))
                ReturnStatus = TRUE;
        else
                ReturnStatus = FALSE;

        /* Issue the Soffware Product ID Exit code thus returning the 39VF400A*/
        /* to the read operating mode                                         */

        Temp1  = Addr5555; 				 /* set up address to be C000:5555h   */
        *Temp1 = 0xAAAA;                 /* write data 0xAAAA to the address  */
        Temp1  = Addr2AAA; 				 /* set up address to be C000:2AAAh   */
        *Temp1 = 0x5555;                 /* write data 0x5555 to the address  */
        Temp1  = Addr5555; 				 /* set up address to be C000:5555h   */
        *Temp1 = 0xF0F0;                 /* write data 0xF0F0 to the address  */

        Delay_150_Nano_Seconds();        /* insert delay time = Tida          */

        return(ReturnStatus);
}


/************************************************************************/
/* PROCEDURE:   CFI_Query                                               */
/*                                                                      */
/* This procedure should be used to query for CFI information           */
/*                                                                      */
/* Input:                                                               */
/*          None                                                        */
/*                                                                      */
/* Output:                                                              */
/*          None                                                        */
/************************************************************************/

extern void CFI_Query(void)
{
        WORD * Temp1;

        /*  Issue the Software Product ID code to 39VF400A   */

        Temp1 = Addr5555; 				/* set up address to be C000:5555h    */
        *Temp1= 0xAAAA;                 /* write data 0xAAAA to the address   */
        Temp1 = Addr2AAA; 				/* set up address to be C000:2AAAh    */
        *Temp1= 0x5555;                 /* write data 0x5555 to the address   */
        Temp1 = Addr5555; 				/* set up address to be C000:5555h    */
        *Temp1= 0x9898;                 /* write data 0x9898 to the address   */

        Delay_150_Nano_Seconds();       /* insert delay time = Tida           */

        /* --------------------------------- */
        /*  Perform all CFI operations here  */
        /*  NOTE:  no sample code provided   */
        /* --------------------------------- */


        /* Issue the CFI Exit code thus returning the 39VF400A */
        /* to the read operating mode                          */

        Temp1  = Addr5555; 				 /* set up address to be C000:5555h   */
        *Temp1 = 0xAAAA;                 /* write data 0xAAAA to the address  */
        Temp1  = Addr2AAA; 				 /* set up address to be C000:2AAAh   */
        *Temp1 = 0x5555;                 /* write data 0x5555 to the address  */
        Temp1  = Addr5555; 				 /* set up address to be C000:5555h   */
        *Temp1 = 0xF0F0;                 /* write data 0xF0F0 to the address  */

        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:                                                              */
/*      NONE                                                            */
/************************************************************************/

extern void Erase_One_Sector (WORD * Dst)	//SAX for Sector-Erase; uses AMS-A11 address lines

{
        WORD * Temp;

        /*  Issue the Sector Erase command to 39VF400A  */

        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0xAAAA;                 /* write data 0xAAAA to the address */
        Temp  = Addr2AAA; 				/* set up address to be C000:2AAAh  */
        *Temp = 0x5555;                 /* write data 0x5555 to the address */
        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0x8080;                 /* write data 0x8080 to the address */
        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0xAAAA;                 /* write data 0xAAAA to the address */
        Temp  = Addr2AAA; 				/* set up address to be C000:2AAAh  */
        *Temp = 0x5555;                 /* write data 0x5555 to the address */

        Temp  = Dst;                  	/* set up starting address to be erased */
        *Temp = 0x3030;                 /* write data 0x3030 to the address */
        Delay_25_Milli_Seconds();       /* Delay time = Tse                 */
}


/************************************************************************/
/* 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:                                                              */
/*      NONE                                                            */
/************************************************************************/

extern void Erase_One_Block (WORD * Dst)	//BAX for Block-Erase; uses AMS-A15 address lines
{
        WORD * Temp;

        /*  Issue the Sector Erase command to 39VF400A  */

        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0xAAAA;                 /* write data 0xAAAA to the address */
        Temp  = Addr2AAA; 				/* set up address to be C000:2AAAh  */
        *Temp = 0x5555;                 /* write data 0x5555 to the address */
        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0x8080;                 /* write data 0x8080 to the address */
        Temp  = Addr5555; 				/* set up address to be C000:5555h  */
        *Temp = 0xAAAA;                 /* write data 0xAAAA to the address */
        Temp  = Addr2AAA; 				/* set up address to be C000:2AAAh  */
        *Temp = 0x5555;                 /* write data 0x5555 to the address */

        Temp  = Dst;                  	/* set up starting address to be erased */
        *Temp = 0x5050;                 /* write data 0x5050 to the address */
        Delay_25_Milli_Seconds();       /* Delay time = Tbe                 */
}


/************************************************************************/
/* PROCEDURE:   Erase_Entire_Chip                                       */
/*                                                                      */
/* This procedure can be used to erase the entire chip.                 */
/*                                                                      */
/* Input:                                                               */
/*      NONE                                                            */
/*                                                                      */
/* Output:                                                              */
/*      NONE                                                            */
/************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -