亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? flashpic32.c

?? 《嵌入式固件開發》一書的源碼
?? C
字號:
/* flashpic32.c: * This file contains the 32-bit flash-support code that is relocated to * RAM prior to execution. */#include "config.h"#if INCLUDE_FLASH#include "stddefs.h"#include "cpu.h"#include "flashdev.h"#include "flash.h"#include "flash32.h"extern struct flashinfo Fdev;extern int FlashProtectWindow;/* Flasherase(): * Based on the 'snum' value, erase the appropriate sector(s). * Return 0 if success, else -1. */intFlasherase29LV800B_32(fdev,snum)struct  flashinfo *fdev;int snum;{    ftype   val;    ulong   add;    int     ret, sector;    ret = 0;    add = (ulong)(fdev->base);    /* Erase the request sector(s): */    for (sector=0;sector<fdev->sectorcnt;sector++) {        if ((!FlashProtectWindow) &&            (fdev->sectors[sector].protected)) {                add += fdev->sectors[sector].size;            continue;        }        if ((snum == ALL_SECTORS) || (snum == sector)) {            int             noterased;            register ulong  *lp, *lp1;                /* See if the sector is already erased: */            noterased = 0;            lp = (ulong *)fdev->sectors[sector].begin;             lp1 = (ulong *)((char *)lp + fdev->sectors[sector].size);             while(lp < lp1) {                if (*lp++ != 0xffffffff) {                    noterased = 1;                    break;                }            }            if (noterased) {                /* Issue the sector erase command sequence: */                Write_aa_to_555();                Write_55_to_2aa();                Write_80_to_555();                Write_aa_to_555();                Write_55_to_2aa();                Write_30_to_(add);                        /* Wait for sector erase to complete or timeout..                 * DQ7 polling: wait for D7 to be 1.                 * DQ5 timeout: if DQ7 is 0, and DQ5 == 1, timeout.                 */                for (;;) {                    val = *(ftype *)add;                    if ((val & 0x00800080) == 0x00800080) {                        break;                    }                        /* Check for D5 timeout in upper flash if it's not done */                    if (((val & 0x00800000) != 0x00800000) &&                        ((val & 0x00200000) != 0)) {                                /* Check D7 again since D7 and D5 are asynchronous */                        val = *(ftype *)add;                        if ((val & 0x00800000) != 0x00800000) {                            ret = -1;                            break;                        }                    }                        /* Check for D5 timeout in lower flash if it's not done */                    if (((val & 0x00000080) != 0x00000080) &&                        ((val & 0x00000020) != 0)) {                                /* Check D7 again since D7 and D5 are asynchronous */                        val = *(ftype *)add;                        if ((val & 0x00000080) != 0x00000080) {                            ret = -1;                            break;                        }                    }                }             }        }        add += fdev->sectors[sector].size;    }    /* If the erase failed for some reason, then issue the read/reset     * command sequence prior to returning...     */    if (ret == -1) {        Write_f0_to_555();        val = Read_555();    }    return(ret);}/* EndFlasherase(): * Function place holder to determine the "end" of the * sectorerase() function. */voidEndFlasherase29LV800B_32(){}union alignedsrc {    ftype   val;    uchar   buf[sizeof(ftype)];};/* Flashwrite(): * Return 0 if successful, else -1. */intFlashwrite29LV800B_32(fdev,dest,src,cnt)struct  flashinfo *fdev;uchar   *src;register uchar *dest;long    cnt;{    union alignedsrc    asrc;    register ftype      tmp, d7test;    unsigned long   prefetch;    int         bidx;    int         timeout = 0;    prefetch = (unsigned long) dest & 3;    dest = (uchar *) ((unsigned long) dest & ~3ul);    /* Unlock Bypass Command: */    Write_aa_to_555();    Write_55_to_2aa();    Write_20_to_555();    while (timeout == 0 && cnt > 0) {        /* First fill the aligned source buffer from the source.  If the         * destination is not 4-byte aligned, also grab bytes from the         * flash prior to the destination to allow all 32 bits to be         * written at once.  If the source length is too short to fill all         * 4 bytes, grab bytes from the flash following the destination to         * allow all 32 bits to be written at once.         */        bidx = 0;        while (prefetch) {            asrc.buf[bidx] = dest[bidx];            bidx++;            prefetch--;        }        while (bidx < 4) {            if (cnt > 0) {                asrc.buf[bidx] = *src++;                cnt--;            }            else {                asrc.buf[bidx] = dest[bidx];            }            bidx++;        }            /* Now asrc.val has the 4-bytes to write to the flash. */            /* Bypass Program command */        Write_a0_to_555();            /* Write the value */        Fwrite(dest, &asrc.val);        d7test = asrc.val & 0x00800080;            /* Wait for flash write to complete (each device might complete         * at a different time).         */        for (;;) {            tmp = *(ftype *)dest;            if ((tmp & 0x00800080) == d7test) {                break;            }                /* Check for D5 timeout in upper flash if it's not done */            if ((tmp & 0x00800000) != (d7test & 0x00800000) &&                (tmp & 0x00200000) != 0) {                    /* Check D7 once more since D7 and D5 are asynchronous */                tmp = *(ftype *)dest;                if ((tmp & 0x00800000) != (d7test & 0x00800000)) {                    timeout = -1;                    break;                }            }                /* Check for D5 timeout in lower flash if it's not done */            if ((tmp & 0x00000080) != (d7test & 0x00000080) &&                (tmp & 0x00000020) != 0) {                    /* Check D7 once more since D7 and D5 are asynchronous */                tmp = *(ftype *)dest;                if ((tmp & 0x00000080) != (d7test & 0x00000080)) {                    timeout = -1;                    break;                }            }        }        /* Finished that 4-byte write, go on to the next (per cnt) */        dest += 4;    }   /* End while cnt > 0 */    /* Unlock Bypass Reset command: */    Write_90_to_555();    Write_00_to_555();    tmp = Read_555();    return(timeout);}/* EndFlashwrite(): *  Function place holder to determine the "end" of the *  Flashwrite() function. */voidEndFlashwrite29LV800B_32(){}/* Ewrite(): * Erase all sectors that are part of the address space to be written, * then write the data to that address space.  This is basically a * concatenation of flasherase and flashwrite done in one step.  This is * necessary primarily for re-writing the bootcode; because after the boot * code is erased, there is nowhere to return so the re-write must be done * while executing out of ram also. * * Note that this routine is restricted to writing full words only.*/intFlashewrite29LV800B_32(fdev,dest,src,bytecnt)struct  flashinfo *fdev;ftype   *src, *dest;int bytecnt;{    int     i;    ulong   add;    void    (*reset)();    ftype   val, d7test, *src1, *dest1;    if (bytecnt <= 0) {     /* sanity check */        return -1;    }    add = (ulong)(fdev->base);    src1 = src;    dest1 = dest;    /* For each sector, if it overlaps any of the destination space     * then erase that sector.     */    for (i=0;i<fdev->sectorcnt;i++) {        if ((((uchar *)dest) > (fdev->sectors[i].end)) ||            (((uchar *)dest+(bytecnt-1)) < (fdev->sectors[i].begin))) {                add += fdev->sectors[i].size;            continue;        }        /* Sector erase command: */        Write_aa_to_555();        Write_55_to_2aa();        Write_80_to_555();        Write_aa_to_555();        Write_55_to_2aa();        Write_30_to_(add);        /* Wait for sector erase to complete or timeout..         * DQ7 polling: wait for D7 to be 1.         * DQ5 timeout: if DQ7 is 0, and DQ5 = 1, timeout.         */        for (;;) {            val = *(ftype *)add;            if ((val & 0x00800080) == 0x00800080) {                break;            }                /* Check for D5 timeout in upper flash if it's not done             * In this case, there is nothing to return to             * because the flash was just erased, so just break.             */            if (((val & 0x00800000) != 0x00800000) &&                ((val & 0x00200000) != 0)) {                    /* Check D7 once more since D7 and D5 are asynchronous */                val = *(ftype *)add;                if ((val & 0x00800000) != 0x00800000) {                    reset = RESETFUNC();                    reset();                }            }                /* Check for D5 timeout in lower flash if it's not done             * In this case, there is nothing to return to             * because the flash was just erased, so just break.             */            if (((val & 0x00000080) != 0x00000080) &&                ((val & 0x00000020) != 0)) {                /* Check D7 once more since D7 and D5 are asynchronous */                val = *(ftype *)add;                if ((val & 0x00000080) != 0x00000080) {                    reset = RESETFUNC();                    reset();                }            }            }        add += fdev->sectors[i].size;    }    /* Read/reset command: */    Write_f0_to_555();    val = Read_555();    for(i=0;i<bytecnt;i+=fdev->width) {        /* Write command: */        Write_aa_to_555();        Write_55_to_2aa();        Write_a0_to_555();        Fwrite(dest,src);        d7test = *src & 0x00800080;        /* Wait for flash write to complete (each device might complete         * at a different time).         */        for (;;) {            val = *(ftype *)dest;            if ((val & 0x00800080) == d7test) {                break;            }            /* Check for D5 timeout in upper flash if it's not done             * In this case, there is nothing to return to             * because the flash was just erased, so just break.             */            if ((val & 0x00800000) != (d7test & 0x00800000)                && (val & 0x00200000) != 0) {                    /* Check D7 once more since D7 and D5 are asynchronous */                val = *(ftype *)dest;                if ((val & 0x00800000) != (d7test & 0x00800000)) {                    reset = RESETFUNC();                    reset();                }            }            /* Check for D5 timeout in lower flash if it's not done             * In this case, there is nothing to return to             * because the flash was just erased, so just break.             */            if ((val & 0x00000080) != (d7test & 0x00000080) &&                (val & 0x00000020) != 0) {                    /* Check D7 once more since D7 and D5 are asynchronous */                val = *(ftype *)dest;                if ((val & 0x00000080) != (d7test & 0x00000080)) {                    reset = RESETFUNC();                    reset();                }            }        }        dest++;         src++;    }    /* Issue the read/reset command sequence: */    Write_f0_to_555();    val = Read_555();    /* Wait till flash is readable, or timeout: */    for(i=0;i<FLASH_TIMEOUT;i++) {        if (Is_Equal(dest1,src1)) {            break;        }    }    /* Now that the re-programming of flash is complete, reset: */    reset = RESETFUNC();    reset();    return(0);  /* won't get here */}/* EndFlashewrite(): *  Function place holder to determine the "end" of the *  FlashEraseAndWrite() function. */voidEndFlashewrite29LV800B_32(){}/* Flashtype(): *  Use the AUTOSELECT command sequence to determine the type of device. *  This code is checking a device type for either a set of 29LV800BB *  or 29LV800BT devices.  It starts by assuming that the devices (2 *  16-bit devices in parallel) are the same (gang is set to GANG). *  If after reading the device id, it is determined that the devices are *  not the same, then we return the long value containing the parallel *  device ids.  The goal is to catch the case where manufacturing *  folks may have installed a 29LV800BB and 29LV800BT in one bank.*/intFlashtype29LV800B_32(struct flashinfo *fdev){    ftype   val;    ulong   man, dev, gang;    ulong   id;    val = Read_000();    /* Issue the autoselect command sequence: */    Write_aa_to_555();    Write_55_to_2aa();    Write_90_to_555();    gang = GANG;        /* Assume two identical parts */    val = Read_000();    man = val & 0xff;   /* manufacturer ID lower device */    if (man != (val & 0x00ff0000) >> 16)        gang = 0;    /* Read device id.  If upper and lower 16-bit id values do not match,     * return the value read now.  This allows the calling function to     * analyze the return value and attempt to draw a conclusion about the     * mismatched set of devices.     */    val = Read_001();    dev = val & 0xffff; /* device ID lower device */    if (dev != (val & 0xffff0000) >> 16) {        fdev->id = val;        return(val);    }    id = gang;    id |= man << 16;    id |= dev;    fdev->id = id;    /* Issue the read/reset command sequence: */    Write_f0_to_555();    val = Read_000();    return((int)(fdev->id));}/* EndFlashtype(): *  Function place holder to determine the "end" of the *  Flashtype() function.*/voidEndFlashtype29LV800B_32(void){}#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色狠狠av一区二区三区| 在线免费不卡电影| 9人人澡人人爽人人精品| 91天堂素人约啪| 日韩一区二区三区免费看| 久久亚洲捆绑美女| 亚洲一区二区欧美激情| 亚洲高清免费视频| 日韩黄色免费网站| 波多野结衣精品在线| 欧美电影一区二区| 中文字幕在线观看不卡视频| 奇米一区二区三区av| 国产精品99久久久久久有的能看| 91玉足脚交白嫩脚丫在线播放| 欧美一区二区三区免费| 国产欧美日韩综合| 免费高清不卡av| av成人免费在线观看| 欧美zozozo| 亚洲高清视频的网址| 不卡电影一区二区三区| 精品国产一区二区三区忘忧草 | 亚洲综合久久av| 国产最新精品精品你懂的| 欧日韩精品视频| 国产精品福利电影一区二区三区四区| 老司机精品视频导航| 在线一区二区视频| 国产精品嫩草影院com| 激情久久五月天| 欧美精品久久天天躁| 一区二区三国产精华液| 国产精品1区二区.| 久久―日本道色综合久久| 日韩电影在线免费观看| 在线不卡免费av| 亚洲国产欧美在线| 99热国产精品| 国产精品看片你懂得| 国产伦精一区二区三区| 欧美日韩mp4| 午夜日韩在线电影| 国产一区福利在线| 欧美成人在线直播| 久久精品av麻豆的观看方式| 制服丝袜中文字幕一区| 一区二区欧美在线观看| 91黄色在线观看| 夜夜嗨av一区二区三区中文字幕| 国产乱国产乱300精品| 精品对白一区国产伦| 激情伊人五月天久久综合| 欧美一区二区三区电影| 美洲天堂一区二卡三卡四卡视频| 欧美一区二区三区在线观看视频| 日本美女一区二区| 欧美一级久久久| 国产一区二区在线看| 久久精品人人爽人人爽| 高清在线成人网| 国产精品乱码一区二区三区软件| 粉嫩aⅴ一区二区三区四区五区| 国产日韩欧美电影| 91丨porny丨蝌蚪视频| 亚洲精品国产一区二区精华液| 精品1区2区3区| 奇米影视一区二区三区| 久久久久国产免费免费 | 亚洲男人电影天堂| 91丝袜美女网| 亚洲第一成年网| 日韩欧美视频在线| 国产成+人+日韩+欧美+亚洲| 国产精品你懂的在线| 成人动漫在线一区| 亚洲一线二线三线久久久| 欧美精品 国产精品| 国产最新精品精品你懂的| 亚洲欧洲日韩综合一区二区| 丁香啪啪综合成人亚洲小说 | 久久精品国产99| 精品成人在线观看| av资源站一区| 青青草国产精品亚洲专区无| 国产欧美久久久精品影院| 国产成人亚洲综合a∨婷婷| 亚洲激情综合网| 欧美成人r级一区二区三区| 国产精品亚洲人在线观看| 亚洲愉拍自拍另类高清精品| 精品国产不卡一区二区三区| 成人自拍视频在线| 午夜精品福利久久久| 国产日产欧美一区二区视频| 欧美体内she精视频| 国产不卡免费视频| 爽好久久久欧美精品| 亚洲日本成人在线观看| 精品日产卡一卡二卡麻豆| a4yy欧美一区二区三区| 久久国产夜色精品鲁鲁99| 亚洲精品高清在线观看| 久久综合九色综合欧美就去吻| 亚洲国产精品自拍| 欧美日韩国产天堂| 日本道精品一区二区三区 | www.成人网.com| 国产成人精品亚洲777人妖| 日本 国产 欧美色综合| 日精品一区二区三区| 天天综合色天天| 免费在线观看精品| 麻豆精品国产传媒mv男同 | 久久精品免费在线观看| 337p日本欧洲亚洲大胆色噜噜| 欧美一区二区三区在线视频| 日韩欧美激情四射| 精品国产第一区二区三区观看体验| 欧美videossexotv100| 精品国免费一区二区三区| 久久这里都是精品| 国产女人aaa级久久久级| 中文字幕第一区综合| 亚洲私人黄色宅男| 亚洲一区二区在线免费观看视频| 亚洲一区二区av电影| 三级亚洲高清视频| 精品中文字幕一区二区| 国产成人免费xxxxxxxx| 国产a区久久久| 在线免费观看日本欧美| 欧美精品第1页| 久久精品视频网| 亚洲美女屁股眼交3| 亚洲午夜在线视频| 精品无码三级在线观看视频| 懂色av一区二区三区蜜臀| 色婷婷av一区二区三区之一色屋| 91.com视频| 国产婷婷一区二区| 亚洲一区免费视频| 久久99国产乱子伦精品免费| 99在线精品视频| 日韩一区二区三区四区五区六区| 久久色中文字幕| 亚洲与欧洲av电影| 国产综合成人久久大片91| 91蝌蚪国产九色| 欧美videos中文字幕| 尤物av一区二区| 国内精品国产成人| 欧美色图免费看| 久久久久久久久久久久久女国产乱 | 亚洲丝袜另类动漫二区| 日精品一区二区三区| www.亚洲人| 日韩欧美国产三级电影视频| 亚洲欧洲综合另类| 久久99精品国产.久久久久| 在线观看亚洲专区| 国产亚洲女人久久久久毛片| 亚洲小说欧美激情另类| 国产不卡视频一区| 欧美成人官网二区| 五月天一区二区| av成人免费在线观看| 久久奇米777| 日韩电影在线一区二区三区| 一本到高清视频免费精品| 国产无遮挡一区二区三区毛片日本| 亚洲国产日韩a在线播放性色| 懂色一区二区三区免费观看| 欧美精品一二三区| 一区二区三区四区国产精品| 成人性生交大片免费看视频在线 | 国产91露脸合集magnet| 88在线观看91蜜桃国自产| 亚洲色图在线播放| 成人毛片在线观看| 国产日韩精品久久久| 国产一区三区三区| 精品国产伦一区二区三区免费| 日韩成人免费看| 欧美色大人视频| 亚洲一二三级电影| 91丝袜美腿高跟国产极品老师| 国产日韩三级在线| 国产成人综合在线| 久久久久久久久免费| 国产精品自拍在线| 久久这里只精品最新地址| 国内久久精品视频| 久久久不卡网国产精品一区| 国产自产v一区二区三区c| 久久久综合精品| 丁香婷婷综合五月| 亚洲视频一区在线| 色八戒一区二区三区| 亚洲一区二区在线播放相泽|