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

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

?? rawnandflash.c

?? at91sam9263操作NAND FLASH代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
    unsigned short destPage)
{
    unsigned short numPages = NandFlashModel_GetBlockSizeInPages(MODEL(raw));
    unsigned int sourceRow = sourceBlock * numPages + sourcePage;
    unsigned int destRow = destBlock * numPages + destPage;
    unsigned char error = 0;

    ASSERT((sourcePage & 1) == (destPage & 1),
           "CopyPage: Source and destination page must have the same parity.\n\r");

    trace_LOG(DEBUG, "CopyPage(B#%d:P#%d -> B#%d:P#%d)\n\r",
              sourceBlock, sourcePage, destBlock, destPage);

    // Use the copy-back facility if available
    if (NandFlashModel_SupportsCopyBack(MODEL(raw))) {

        // Start operation
        ENABLE_CE(raw);

        // Start copy-back read
        WRITE_COMMAND(raw, COMMAND_COPYBACK_READ_1);
        WriteColumnAddress(raw, 0);
        WriteRowAddress(raw, sourceRow);
        WRITE_COMMAND(raw, COMMAND_COPYBACK_READ_2);
        WaitReady(raw);

        // Start copy-back write
        WRITE_COMMAND(raw, COMMAND_COPYBACK_PROGRAM_1);
        WriteColumnAddress(raw, 0);
        WriteRowAddress(raw, destRow);
        WRITE_COMMAND(raw, COMMAND_COPYBACK_PROGRAM_2);
        WaitReady(raw);

        // Check status
        if (!IsOperationComplete(raw)) {
            trace_LOG(trace_ERROR, "CopyPage: Failed to copy page.\n\r");
            error = NandCommon_ERROR_CANNOTCOPY;
        }

        // Finish operation
        DISABLE_CE(raw);
    }
    else {

        // Software copy
        unsigned char data[NandCommon_MAXPAGEDATASIZE];
        unsigned char spare[NandCommon_MAXPAGESPARESIZE];
        if (RawNandFlash_ReadPage(raw, sourceBlock, sourcePage, data, spare)) {

            trace_LOG(trace_ERROR, "CopyPage: Failed to read page to copy\n\r");
            error = NandCommon_ERROR_CANNOTREAD;
        }
        else if (RawNandFlash_WritePage(raw, destBlock, destPage, data, spare)) {

            trace_LOG(trace_ERROR, "CopyPage: Failed to write dest. page\n\r");
            error = NandCommon_ERROR_CANNOTWRITE;
        }
    }

    return error;
}

//------------------------------------------------------------------------------
//         Exported functions
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
/// Initializes a RawNandFlash instance based on the given model and physical
/// interface. If no model is provided, then the function tries to autodetect
/// it.
/// Returns 0 if initialization is successful; otherwise returns
/// NandCommon_ERROR_UNKNOWNMODEL.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param model  Pointer to the underlying nand chip model. Can be 0.
/// \param commandAddress  Address at which commands are sent.
/// \param addressAddress  Address at which addresses are sent.
/// \param dataAddress  Address at which data is sent.
/// \param pinChipEnable  Pin controlling the CE signal of the NandFlash.
/// \param pinReadyBusy  Pin used to monitor the ready/busy signal of the Nand.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_Initialize(
    struct RawNandFlash *raw,
    const struct NandFlashModel *model,
    unsigned int commandAddress,
    unsigned int addressAddress,
    unsigned int dataAddress,
    const Pin pinChipEnable,
    const Pin pinReadyBusy)
{
    trace_LOG(DEBUG, "RawNandFlash_Initialize()\r\n");

    // Initialize fields
    raw->commandAddress = commandAddress;
    raw->addressAddress = addressAddress;
    raw->dataAddress = dataAddress;
    raw->pinChipEnable = pinChipEnable;
    raw->pinReadyBusy = pinReadyBusy;

    // Reset
    RawNandFlash_Reset(raw);

    // If model is not provided, autodetect it
    if (!model) {

        trace_LOG(DEBUG, "No model provided, trying autodetection ...\n\r");
        if (NandFlashModel_Find(nandFlashModelList,
                                NandFlashModelList_SIZE,
                                RawNandFlash_ReadId(raw),
                                &(raw->model))) {

            trace_LOG(trace_ERROR,
                      "RawNandFlash_Initialize: Could not autodetect chip.\n\r");
            return NandCommon_ERROR_UNKNOWNMODEL;
        }
    }
    else {

        // Copy provided model
        raw->model = *model;
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Resets a NandFlash device.
/// \param raw  Pointer to a RawNandFlash instance.
//------------------------------------------------------------------------------
void RawNandFlash_Reset(const struct RawNandFlash *raw)
{
    trace_LOG(DEBUG, "RawNandFlash_Reset()\n\r");

    ENABLE_CE(raw);
    WRITE_COMMAND(raw, COMMAND_RESET);
    WaitReady(raw);
    DISABLE_CE(raw);
}

//------------------------------------------------------------------------------
/// Reads and returns the identifiers of a NandFlash chip.
/// \param raw  Pointer to a RawNandFlash instance.
/// \return id1|(id2<<8)|(id3<<16)|(id4<<24)
//------------------------------------------------------------------------------
unsigned int RawNandFlash_ReadId(const struct RawNandFlash *raw)
{
    unsigned int chipId;

    trace_LOG(DEBUG, "RawNandFlash_ReadId()\n\r");

    ENABLE_CE(raw);
    WRITE_COMMAND(raw, COMMAND_READID);
    WRITE_ADDRESS(raw, 0);
    chipId  = READ_DATA8(raw);
    chipId |= READ_DATA8(raw) << 8;
    chipId |= READ_DATA8(raw) << 16;
    chipId |= READ_DATA8(raw) << 24;
    DISABLE_CE(raw);

    return chipId;
}

//------------------------------------------------------------------------------
/// Erases the specified block of the device, retrying several time if it fails.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_BADBLOCK.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param block  Number of the physical block to erase.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_EraseBlock(
    const struct RawNandFlash *raw,
    unsigned short block)
{
    unsigned char numTries = NUMERASETRIES;

    trace_LOG(DEBUG, "RawNandFlash_EraseBlock(B#%d)\n\r", block);

    while (numTries > 0) {

        if (!EraseBlock(raw, block)) {

            return 0;
        }
        numTries--;
    }

    trace_LOG(trace_ERROR, "RawNandFlash_EraseBlock: Failed to erase block after %d tries\n\r", NUMERASETRIES);
    return NandCommon_ERROR_BADBLOCK;
}

//------------------------------------------------------------------------------
/// Reads the data and/or the spare areas of a page of a NandFlash into the
/// provided buffers. If a buffer pointer is 0, the corresponding area is not
/// read.
/// Returns 0 if the operation has been successful; otherwise returns 1.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param block  Number of the block where the page to read resides.
/// \param page  Number of the page to read inside the given block.
/// \param data  Buffer where the data area will be stored.
/// \param spare  Buffer where the spare area will be stored.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_ReadPage(
    const struct RawNandFlash *raw,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    unsigned char hasSmallBlocks = NandFlashModel_HasSmallBlocks(MODEL(raw));
    unsigned int pageDataSize = NandFlashModel_GetPageDataSize(MODEL(raw));
    unsigned int pageSpareSize = NandFlashModel_GetPageSpareSize(MODEL(raw));
    unsigned int rowAddress;

    ASSERT(data || spare, "RawNandFlash_ReadPage: At least one area must be read\n\r");
    trace_LOG(DEBUG, "RawNandFlash_ReadPage(B#%d:P#%d)\r\n", block, page);

    // Calculate actual address of the page
    rowAddress = block * NandFlashModel_GetBlockSizeInPages(MODEL(raw)) + page;

    // Start operation
    ENABLE_CE(raw);

    // Use either small blocks or large blocks data area read
    if (hasSmallBlocks) {

        WRITE_COMMAND(raw, COMMAND_READ_A);
        WriteColumnAddress(raw, 0);
        WriteRowAddress(raw, rowAddress);
    }
    else {
    
        WRITE_COMMAND(raw, COMMAND_READ_1);
        WriteColumnAddress(raw, 0);
        WriteRowAddress(raw, rowAddress);
        WRITE_COMMAND(raw, COMMAND_READ_2);
    }

    // Wait for the nand to be ready
    WaitReady(raw);

    // Read data area if needed
    if (data) {
        WRITE_COMMAND(raw, COMMAND_READ_1);
        ReadData(raw, (unsigned char *) data, pageDataSize);
    }

    // Use either small/large blocks spare area read
    if (hasSmallBlocks) {

        WRITE_COMMAND(raw, COMMAND_READ_C);
        WriteColumnAddress(raw, 0);
        WriteRowAddress(raw, rowAddress);
        WaitReady(raw);
    }
    else {

        WRITE_COMMAND(raw, COMMAND_RANDOM_OUT);
        WriteColumnAddress(raw, pageDataSize);
        WRITE_COMMAND(raw, COMMAND_RANDOM_OUT_2);
    }
    WaitReady(raw);

    // Read spare area if needed
    if (spare) {
        WRITE_COMMAND(raw, COMMAND_READ_1);
        ReadData(raw, (unsigned char *) spare, pageSpareSize);
    }

    // Disable CE
    DISABLE_CE(raw);

    return 0;
}

//------------------------------------------------------------------------------
/// Writes the data and/or the spare area of a page on a NandFlash chip. If one
/// of the buffer pointer is 0, the corresponding area is not written. Retries
/// several time if there is an error.
/// Returns 0 if the write operation is successful; otherwise returns
/// NandCommon_ERROR_BADBLOCK.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param block  Number of the block where the page to write resides.
/// \param page  Number of the page to write inside the given block.
/// \param data  Buffer containing the data area.
/// \param spare  Buffer containing the spare area.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_WritePage(
    const struct RawNandFlash *raw,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    unsigned char numTries = NUMWRITETRIES;

    trace_LOG(DEBUG, "RawNandFlash_WritePage(B#%d:P#%d)\r\n", block, page);

    while (numTries > 0) {

        if (!WritePage(raw, block, page, data, spare)) {

            return 0;
        }
        numTries--;
    }

    trace_LOG(trace_ERROR, "RawNandFlash_WritePage: Failed to write page after %d tries\n\r", NUMWRITETRIES);
    return NandCommon_ERROR_BADBLOCK;
}

//------------------------------------------------------------------------------
/// Copy the data in a page of the NandFlash device to an other page on that
/// same chip. Both pages must have be even or odd; it is not possible to copy
/// and even page to an odd page and vice-versa. Several retries are attempted
/// if errors are encountered.
/// Returns 0 if the operation is successful; otherwise returns
/// NandCommon_ERROR_BADBLOCK indicating that the destination block is bad.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param sourcePage  Source page number inside the source block.
/// \param destBlock  Destination block number.
/// \param destPage  Destination page number inside the destination block.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_CopyPage(
    const struct RawNandFlash *raw,
    unsigned short sourceBlock,
    unsigned short sourcePage,
    unsigned short destBlock,
    unsigned short destPage)
{
    unsigned char numTries = NUMCOPYTRIES;

    trace_LOG(DEBUG, "RawNandFlash_CopyPage(B#%d:P#%d -> B#%d:P#%d)\n\r",
              sourceBlock, sourcePage, destBlock, destPage);

    while (numTries) {

        if (!CopyPage(raw, sourceBlock, sourcePage, destBlock, destPage)) {

            return 0;
        }
        numTries--;
    }

    trace_LOG(trace_ERROR, "RawNandFlash_CopyPage: Failed to copy page after %d tries\n\r", NUMCOPYTRIES);
    return NandCommon_ERROR_BADBLOCK;
}

//------------------------------------------------------------------------------
/// Copies the data of one whole block of a NandFlash device to another block.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_BADBLOCK.
/// \param raw  Pointer to a RawNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param destBlock  Destination block number.
//------------------------------------------------------------------------------
unsigned char RawNandFlash_CopyBlock(
    const struct RawNandFlash *raw,
    unsigned short sourceBlock,
    unsigned short destBlock)
{
    unsigned short numPages = NandFlashModel_GetBlockSizeInPages(MODEL(raw));
    unsigned int i;

    ASSERT(sourceBlock != destBlock,
           "RawNandFlash_CopyBlock: Source block must be different from dest block\n\r");
    trace_LOG(DEBUG, "RawNandFlash_CopyBlock(B#%d->B#%d)\n\r",
              sourceBlock, destBlock);

    // Copy all pages
    for (i=0; i < numPages; i++) {

        if (RawNandFlash_CopyPage(raw, sourceBlock, i, destBlock, i)) {

            trace_LOG(trace_ERROR,
                      "RawNandFlash_CopyBlock: Failed to copy page %d\n\r",
                      i);
            return NandCommon_ERROR_BADBLOCK;
        }
    }

    return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美揉bbbbb揉bbbbb| 亚洲欧美日韩久久精品| 欧美三级乱人伦电影| 福利91精品一区二区三区| 国产亚洲欧美日韩俺去了| 国产成人免费视频一区| 国产精品欧美一区二区三区| heyzo一本久久综合| 亚洲福中文字幕伊人影院| 日韩三级精品电影久久久| 国产乱子轮精品视频| 欧美一卡二卡在线| 国产成人小视频| 成人午夜视频在线| 天堂资源在线中文精品| 91极品视觉盛宴| 久久精品国产99国产精品| 国产精品天干天干在线综合| 中文一区二区完整视频在线观看| 精品视频在线看| 欧美一区二区三区免费大片 | 亚洲一区二区欧美日韩| 欧美高清视频在线高清观看mv色露露十八 | 亚洲成av人片在线观看无码| 久久看人人爽人人| 欧美唯美清纯偷拍| 国产盗摄精品一区二区三区在线| 国产成人在线网站| 色综合天天综合狠狠| 韩国欧美国产一区| 亚洲成人精品影院| 精品一区二区久久| 婷婷久久综合九色综合伊人色| 美女看a上一区| 午夜久久福利影院| 国产乱妇无码大片在线观看| 99久久国产综合精品色伊| 日本在线观看不卡视频| 一区二区三区欧美亚洲| 国产精品天美传媒| 日韩av中文字幕一区二区三区| 黑人巨大精品欧美一区| 91黄视频在线观看| 精品国产91洋老外米糕| 欧美人xxxx| 欧美日韩国产高清一区二区| 欧美精品一区男女天堂| 一区二区三区鲁丝不卡| 国产成人精品三级麻豆| 欧美疯狂性受xxxxx喷水图片| 国产日韩精品一区二区浪潮av| 精品国产网站在线观看| 一区二区三区在线播放| 国产精品18久久久久久久久| 欧美日韩在线播放三区四区| 久久久www成人免费无遮挡大片| 亚洲综合色网站| 成人av免费网站| 91啪亚洲精品| 91视频在线观看| 国产日产欧美一区二区视频| 亚洲123区在线观看| 91电影在线观看| 亚洲视频资源在线| 一区二区三区加勒比av| 成人免费看视频| 久久久av毛片精品| 国产一区在线观看视频| 欧美成人乱码一区二区三区| 欧美激情在线观看视频免费| 久久精品72免费观看| 日韩精品一区二区三区swag| 国产亚洲福利社区一区| 激情文学综合插| 久久影视一区二区| 日韩理论片一区二区| 国产成人高清在线| 国产亚洲人成网站| 成人av影视在线观看| 国产精品日产欧美久久久久| 成人美女在线视频| 一区在线播放视频| 免费成人性网站| 波多野结衣精品在线| 国产精品欧美一级免费| 91香蕉视频黄| 一区二区在线观看视频在线观看| 免费人成黄页网站在线一区二区| 欧美视频在线一区| 日本成人中文字幕| 久久综合久久99| 东方欧美亚洲色图在线| 亚洲视频在线观看三级| 精品视频在线视频| 另类欧美日韩国产在线| 国产女主播视频一区二区| 99久久久无码国产精品| 亚洲乱码日产精品bd| 欧美精品久久99久久在免费线 | 亚洲激情中文1区| 欧美色涩在线第一页| 日韩二区在线观看| 国产亚洲精久久久久久| 在线视频你懂得一区| 国产三级久久久| 色综合久久88色综合天天| 国产亚洲美州欧州综合国| 99久久国产综合精品麻豆| 天天综合网天天综合色| 精品毛片乱码1区2区3区| 成人97人人超碰人人99| 亚洲国产va精品久久久不卡综合| 日韩欧美中文字幕制服| 99这里只有久久精品视频| 视频一区二区三区中文字幕| 欧美精品一区二区三区很污很色的 | 国产综合色产在线精品| 自拍偷拍亚洲综合| 91精品国产色综合久久久蜜香臀| 国产高清视频一区| 午夜精品视频一区| 中文字幕一区二区三区av| 日韩一区二区三区在线| 99视频一区二区三区| 亚洲1区2区3区视频| 国产精品乱人伦| 日韩欧美第一区| 91精彩视频在线观看| 成人性生交大片| 美女一区二区久久| 亚洲第一av色| 亚洲欧美日韩电影| 国产清纯在线一区二区www| 在线观看91精品国产麻豆| 99re成人精品视频| 风间由美中文字幕在线看视频国产欧美| 三级亚洲高清视频| 亚洲无线码一区二区三区| 2021久久国产精品不只是精品| 欧美精品亚洲二区| 欧美优质美女网站| 99精品久久久久久| 成人蜜臀av电影| 成人激情免费网站| 国产一区二区三区观看| 久久 天天综合| 久久97超碰国产精品超碰| 日本麻豆一区二区三区视频| 日韩极品在线观看| 天堂av在线一区| 日韩国产精品91| 麻豆久久久久久久| 九九精品一区二区| 国产一级精品在线| 国产成人精品免费在线| 国产69精品久久久久毛片| 狠狠久久亚洲欧美| 国产精品夜夜嗨| 高清视频一区二区| 99久久免费精品| 欧洲精品在线观看| 欧美色网站导航| 欧美精三区欧美精三区| 日韩一区二区免费电影| 日韩欧美色电影| 久久久精品蜜桃| 中文字幕日韩av资源站| 亚洲午夜精品网| 日本aⅴ亚洲精品中文乱码| 麻豆91精品91久久久的内涵| 久久99精品国产麻豆婷婷洗澡| 国产毛片精品视频| a美女胸又www黄视频久久| 色欲综合视频天天天| 欧美日韩一区中文字幕| 日韩精品一区二区三区四区| 国产午夜精品久久| 一区二区三区毛片| 日本视频免费一区| 国产不卡一区视频| 色婷婷香蕉在线一区二区| 欧美日本在线一区| 精品国产1区2区3区| 国产精品久久久久久久久图文区 | 精品一区二区三区免费播放| 国产麻豆精品视频| 日本韩国欧美在线| 精品对白一区国产伦| 亚洲天堂2016| 青青草国产成人av片免费| 成人免费视频国产在线观看| 欧美天堂亚洲电影院在线播放| 久久综合中文字幕| 夜夜夜精品看看| 国产另类ts人妖一区二区| 色综合久久久久综合体桃花网| 91精品国产aⅴ一区二区| 国产精品毛片久久久久久| 喷白浆一区二区| 91精品福利视频|