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

📄 mx29lv640bt.c.bak

📁 移植好的Ibm405ep bsp板极支持包
💻 BAK
📖 第 1 页 / 共 2 页
字号:
/* mx29lv640bt.c */ /* Copyright 2003--2005 zzvcom *//* here are Software Programmer Drivers for SST39VF016   modification history   ------------------------   2005-8-22 16:21, hzk	write.    *//***************************************************************************Name                    Function----------------------------------------------------------------------------mx29lv640bt_Probe       Check manufacturer and device IDmx29lv640bt_Erase_Entire_Chip       Erase the contents of the entire chipmx29lv640bt_Erase_One_Block         Erase a block of 64KBytemx29lv640bt_Program_One_Byte        Alter data in one bytemx29lv640bt_Program_One_Block       Alter data in 64KByte blockmx29lv640bt_Toggle_Ready      End of internal program or erase detection using                           Toggle bitmx29lv640bt_Data_Polling      End of internal program or erase detection using                           Data# polling****************************************************************************/#include <vxworks.h>#include <stdio.h>#include "mx29lv640bt.h"/*MX29LV640_MD FLASH厂家IDAM29LV640_ID 芯片ID*/#define MX29LV640_MD 0xC2#define MX29LV640_ID 0xDD#undef MX29LV640_DEBUGstatic void mx29lv640bt_Toggle_Ready (unsigned char  *Dst);static void mx29lv640bt_Delay_150_Nano_Seconds(void);static void mx29lv640bt_Delay_25_Milli_Seconds(void);static void mx29lv640bt_Probe_Data_Polling (unsigned char *Dst, unsigned char TrueData);/* *Function: mx29lv640bt_Probe *Description : This procedure decides whether a physical hardware device                 has a am29lv320 32 Mbit Multi-Purpose Flash installed or not. *                    *Parameters : flash_base_addr - base addr of a flash. *Returns : TRUE-- installed  *           FALSE-- unstalled */ int mx29lv640bt_Probe(void *flash_base_addr){        unsigned char *Temp;        unsigned char mx29lv640bt_id1;        unsigned char *Temp1;        unsigned char mx29lv640bt_id2;        int  ReturnStatus;        /*  Issue the Software Product ID code to mx29lv640bt   */        Temp1 	= (unsigned char *)((unsigned char *)flash_base_addr+0xaaa);   /* set up address to be aaah  */        *Temp1	= 0xAA;                                     /* write data 0xAA to the address */        Temp1 	= (unsigned char *)((unsigned char *)flash_base_addr+0x555);   /* set up address to be 555h  */        *Temp1	= 0x55;                                     /* write data 0x55 to the address */        Temp1 	= (unsigned char *)((unsigned char *)flash_base_addr+0xaaa);   /* set up address to be aaah  */        *Temp1	= 0x90;                                     /* write data 0x90 to the address */        mx29lv640bt_Delay_150_Nano_Seconds();		      /* Delay time = Tida */        /* Read the product ID from am29lv320 */        Temp  	= (unsigned char *)((unsigned char *)flash_base_addr+0x0);      /* set up address to be 0000h */        mx29lv640bt_id1 =  *Temp;                             /* get first ID byte*/        Temp1 	= (unsigned char *)((unsigned char *)flash_base_addr+0x2);      /* set up address to be 0001h  */        mx29lv640bt_id2 =  *Temp1;                            /* get second ID byte*/        /* Determine whether there is a am29lv320 installed or not */        if ((mx29lv640bt_id1 == MX29LV640_MD) && (mx29lv640bt_id1 ==MX29LV640_ID))                ReturnStatus = TRUE;        else{                ReturnStatus = FALSE;                printf("Not match flash %x %x\n",mx29lv640bt_id1,mx29lv640bt_id2);        }        /* Issue the Soffware Product ID Exit code thus returning the am29lv320 */        /* to the read operating mode                                         */        Temp1  = (unsigned char *)((unsigned char *)flash_base_addr+0x5555);    /* set up address to be 5555h   */        *Temp1 = 0xAA;                                       /* write data 0xAA to the address  */        Temp1  = (unsigned char *)((unsigned char *)flash_base_addr+0x2AAA);    /* set up address to be 2AAAh   */        *Temp1 = 0x55;                                       /* write data 0x55 to the address  */        Temp1  = (unsigned char *)((unsigned char *)flash_base_addr+0x5555);    /* set up address to be 5555h   */        *Temp1 = 0xF0;                                       /* write data 0xF0 to the address  */        mx29lv640bt_Delay_150_Nano_Seconds();		      /* Delay time = Tida */        return(ReturnStatus);}/* *Function: am29lv320_Erase_One_Block  *Description : This procedure can be used to erase a total of 64K bytes. *                    *Parameters : flash_base_addr - base addr of a flash. *             Dst- destination address where the erase operation starts  *Returns : NONE */ void mx29lv640bt_Erase_One_Block (void *flash_base_addr,unsigned char *Dst){        unsigned char *Temp;        int i;        /*  Issue the Sector Erase command to am29lv320  */        Temp  = (unsigned char *)((unsigned char *)flash_base_addr+0xaaa);     /* set up address to be aaah  */        *Temp = 0xaa;                                       /* write data 0xaa to the address */        Temp  = (unsigned char *)((unsigned char *)flash_base_addr+0x555);     /* set up address to be 555h  */        *Temp = 0x55;                                       /* write data 0x55 to the address */        Temp  = (unsigned char *)((unsigned char *)flash_base_addr+0xaaa);     /* set up address to be aaah  */        *Temp = 0x80;                                       /* write data 0x80 to the address */        Temp  = (unsigned char *)((unsigned char *)flash_base_addr+0xaaa);     /* set up address to be aaah  */        *Temp = 0xaa;                                       /* write data 0xAA to the address */        Temp  = (unsigned char *)((unsigned char *)flash_base_addr+0x555);     /* set up address to be 555h  */        *Temp = 0x55;                                       /* write data 0x55 to the address */        Temp  = Dst;                                  /* set up starting address to be erased */        *Temp = 0x30;                                 /* write data 0x50 to the address */        #if 0        for(i=0;i<30;i++){/*等待0.7s*/        	mx29lv640bt_Delay_25_Milli_Seconds();                  /* Delay time = Tbe                 */	        }        #else        mx29lv640bt_Probe_Data_Polling (Dst,(unsigned char)0xff);        #endif}/* *Function: mx29lv640bt_Erase_One_Sector *Description : This procedure can be used to erase a total of 8192 bytes- a sector. * *Parameters : flash_base_addr - base addr of a flash. *             Dst- destination address where the erase operation starts  *Returns : NONE */ void mx29lv640bt_Erase_One_Sector(void *flash_base_addr,unsigned char  *Dst){        return mx29lv640bt_Erase_One_Block(flash_base_addr,Dst);}/* *Function: mx29lv640bt_Program_One_Byte *Description : This procedure can be used to program ONE byte of data to the         *              mx29lv640bt.                                                                                                                                   *NOTE:  It is necessary to first erase the sector containing the       *        byte to be programmed.        			 * *Parameters : flash_base_addr - base addr of a flash. *             SrcByte - The BYTE which will be written to the 39VF016 *             Dst - destination address which will be written with the  *                   data passed in from SrcByte        *Returns : NONE */ void mx29lv640bt_Program_One_Byte (void *flash_base_addr, unsigned char SrcByte,unsigned char *Dst){        unsigned char *Temp;        unsigned char *DestBuf;        DestBuf = Dst;        Temp =  (unsigned char *)((unsigned char *)flash_base_addr + 0xaaa);        *Temp = 0xaa;                   /* write data 0xaa  to the address  */        Temp =  (unsigned char *)((unsigned char *)flash_base_addr + 0x555);        *Temp = 0x55;                   /* write data 0x55  to the address  */        Temp =  (unsigned char *)((unsigned char *)flash_base_addr + 0xaaa);        *Temp = 0xa0;                   /* write data 0xa0  to the address  */        *DestBuf = SrcByte;             /* transfer the byte to destination */        mx29lv640bt_Toggle_Ready(DestBuf);    /* wait for TOGGLE bit to get ready */}

⌨️ 快捷键说明

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