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

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

?? managednandflash.c

?? IAR5.2下 AT91SAM9260 ARM 對 MCP2515 控制源化碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to allocate.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_AllocateBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    trace_LOG(INFO, "ManagedNandFlash_AllocateBlock(%d)\n\r", block);

    // Check that block is FREE
    if (managed->blockStatuses[block].status != NandBlockStatus_FREE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_AllocateBlock: Block must be FREE\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Change block status to LIVE
    managed->blockStatuses[block].status = NandBlockStatus_LIVE;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Releases a LIVE block of a nandflash and marks it as DIRTY.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_WRONGSTATUS if
/// the block is not LIVE, or a RawNandFlash_WritePage error.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to release.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_ReleaseBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    trace_LOG(INFO, "ManagedNandFlash_ReleaseBlock(%d)\n\r", block);

    // Check that block is LIVE
    if (managed->blockStatuses[block].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_ReleaseBlock: Block must be LIVE\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Change block status to DIRTY
    managed->blockStatuses[block].status = NandBlockStatus_DIRTY;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Erases a DIRTY block of a managed NandFlash.
/// Returns the RawNandFlash_EraseBlock code or NandCommon_ERROR_WRONGSTATUS.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to erase.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_EraseBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    unsigned char error;

    trace_LOG(INFO, "ManagedNandFlash_EraseBlock(%d)\n\r", block);

    // Check block status
    if (managed->blockStatuses[block].status != NandBlockStatus_DIRTY) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_EraseBlock: Block must be DIRTY\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Erase block
    error = RawNandFlash_EraseBlock(RAW(managed), block);
    if (error) {

        return error;
    }

    // Update block status
    managed->blockStatuses[block].status = NandBlockStatus_FREE;
    managed->blockStatuses[block].eraseCount++;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Reads the data and/or the spare area of a page on a managed nandflash. If
/// the data pointer is not 0, then the block MUST be LIVE.
/// Returns NandCommon_ERROR_WRONGSTATUS if the block is not LIVE and the data
/// pointer is not null; Otherwise, returns EccNandFlash_ReadPage().
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to read page from.
/// \param page  Number of page to read inside the given block.
/// \param data  Data area buffer, can be 0.
/// \param spare  Spare area buffer, can be 0.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_ReadPage(
    const struct ManagedNandFlash *managed,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    // Check that the block is LIVE if data is requested
    if ((managed->blockStatuses[block].status != NandBlockStatus_LIVE)
        && (managed->blockStatuses[block].status != NandBlockStatus_DIRTY)) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_ReadPage: Block must be LIVE or DIRTY.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Read data with ECC verification
    return EccNandFlash_ReadPage(ECC(managed), block, page, data, spare);
}

//------------------------------------------------------------------------------
/// Writes the data and/or spare area of a LIVE page on a managed NandFlash.
/// Returns NandCommon_ERROR_WRONGSTATUS if the page is not LIVE; otherwise,
/// returns EccNandFlash_WritePage().
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of the block to write.
/// \param page  Number of the page to write inside the given block.
/// \param data  Data area buffer.
/// \param spare  Spare area buffer.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_WritePage(
    const struct ManagedNandFlash *managed,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    // Check that the block is LIVE
    if (managed->blockStatuses[block].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_WritePage: Block must be LIVE.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Write data with ECC calculation
    return EccNandFlash_WritePage(ECC(managed), block, page, data, spare);
}

//------------------------------------------------------------------------------
/// Copy the data & spare area of one page to another page. The source block
/// can be either LIVE or DIRTY, and the destination block must be LIVE; they
/// must both have the same parity.
/// Returns 0 if successful; NandCommon_ERROR_WRONGSTATUS if one or more page
/// is not live; otherwise returns an NandCommon_ERROR_xxx code.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param sourcePage  Number of source page inside the source block.
/// \param destBlock  Destination block number.
/// \param destPage  Number of destination page inside the dest block.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_CopyPage(
    const struct ManagedNandFlash *managed,
    unsigned short sourceBlock,
    unsigned short sourcePage,
    unsigned short destBlock,
    unsigned short destPage)
{
    unsigned char error;

    ASSERT((sourcePage & 1) == (destPage & 1),
           "ManagedNandFlash_CopyPage: source & dest pages must have the same parity\n\r");

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

    // Check block statuses
    if ((managed->blockStatuses[sourceBlock].status != NandBlockStatus_LIVE)
         && (managed->blockStatuses[sourceBlock].status != NandBlockStatus_DIRTY)) {

        trace_LOG(trace_ERROR,
                  "ManagedNandFlash_CopyPage: Source block must be LIVE or DIRTY.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }
    if (managed->blockStatuses[destBlock].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR,
                  "ManagedNandFlash_CopyPage: Destination block must be LIVE.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // If destination page is page #0, block status information must not be
    // overwritten
    if (destPage == 0) {

        unsigned char data[NandCommon_MAXPAGEDATASIZE];
        unsigned char spare[NandCommon_MAXPAGESPARESIZE];

        // Read data & spare to copy
        error = EccNandFlash_ReadPage(ECC(managed), sourceBlock, sourcePage, data, spare);
        if (error) {

            return error;
        }

        // Write destination block status information in spare
        NandSpareScheme_WriteExtra(NandFlashModel_GetScheme(MODEL(managed)),
                                   spare,
                                   &(managed->blockStatuses[destBlock]),
                                   4,
                                   0);

        // Write page
        error = RawNandFlash_WritePage(RAW(managed), destBlock, destPage, data, spare);
        if (error) {

            return error;
        }
    }
    // Otherwise, a normal copy can be done
    else {

        return RawNandFlash_CopyPage(RAW(managed),
                                     sourceBlock,
                                     sourcePage,
                                     destBlock,
                                     destPage);
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Copies the data from a whole block to another block on a nandflash. Both
/// blocks must be LIVE.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_WRONGSTATUS if
/// at least one of the blocks is not free, or a NandCommon_ERROR_xxx code.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param destBlock  Destination block number.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_CopyBlock(
    const struct ManagedNandFlash *managed,
    unsigned short sourceBlock,
    unsigned short destBlock)
{
    unsigned short numPages = NandFlashModel_GetBlockSizeInPages(MODEL(managed));
    unsigned char error;
    unsigned short page;

    ASSERT(sourceBlock != destBlock,
           "ManagedNandFlash_CopyBlock: Source block must be different from dest. block\n\r");

    trace_LOG(INFO, "ManagedNandFlash_CopyBlock(B#%d->B#%d)\n\r",
              sourceBlock, destBlock);

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

        error = ManagedNandFlash_CopyPage(managed,
                                          sourceBlock,
                                          page,
                                          destBlock,
                                          page);
        if (error) {

            trace_LOG(trace_ERROR,
                      "ManagedNandFlash_CopyPage: Failed to copy page %d\n\r",
                      page);
            return error;
        }
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Erases all the blocks which are currently marked as DIRTY.
/// Returns 0 if successful; otherwise, returns a NandCommon_ERROR code.
/// \param managed  Pointer to a ManagedNandFlash instance.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_EraseDirtyBlocks(
    struct ManagedNandFlash *managed)
{
    unsigned int i;
    unsigned char error;

    // Erase all dirty blocks
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        if (managed->blockStatuses[i].status == NandBlockStatus_DIRTY) {

            error = ManagedNandFlash_EraseBlock(managed, i);
            if (error) {

                return error;
            }
        }
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Looks for the youngest block having the desired status among the blocks
/// of a managed nandflash. If a block is found, its index is stored inside
/// the provided variable (if pointer is not 0).
/// Returns 0 if a block has been found; otherwise returns either
/// NandCommon_ERROR_NOBLOCKFOUND if there are no blocks having the desired
/// status.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Pointer to the block number variable.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_FindYoungestBlock(
    const struct ManagedNandFlash *managed,
    unsigned char status,
    unsigned short *block)
{
    unsigned char found = 0;
    unsigned short bestBlock = 0;
    unsigned int i;

    // Go through the block array
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        // Check status
        if (managed->blockStatuses[i].status == status) {

            // If no block was found, i becomes the best block
            if (!found) {

                found = 1;
                bestBlock = i;
            }
            // Compare the erase counts otherwise
            else if (managed->blockStatuses[i].eraseCount
                     < managed->blockStatuses[bestBlock].eraseCount) {

                bestBlock = i;
            }
        }
    }

    if (found) {

        if (block) {

            *block = bestBlock;
        }
        return 0;
    }
    else {

        return NandCommon_ERROR_NOBLOCKFOUND;
    }
}

//------------------------------------------------------------------------------
/// Counts and returns the number of blocks having the given status in a
/// managed nandflash.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param status  Desired block status.
//------------------------------------------------------------------------------
unsigned short ManagedNandFlash_CountBlocks(
    const struct ManagedNandFlash *managed,
    unsigned char status)
{
    unsigned int i;
    unsigned short count = 0;

    // Examine each block
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        if (managed->blockStatuses[i].status == status) {

            count++;
        }
    }

    return count;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国模大尺度视频| 欧洲在线/亚洲| 五月婷婷综合激情| 亚洲欧美日韩国产手机在线 | 久久久久久亚洲综合| 欧洲国产伦久久久久久久| 国产91精品一区二区| 国产电影精品久久禁18| 精品系列免费在线观看| 男人的j进女人的j一区| 亚洲成人综合在线| 青青草视频一区| 国内精品自线一区二区三区视频| 蜜桃久久精品一区二区| 免费观看日韩av| 国产在线播放一区| 99视频热这里只有精品免费| 成人av在线电影| 色就色 综合激情| 欧美一区二区三区在线电影| 日韩一区二区精品葵司在线 | 粉嫩一区二区三区在线看| 国产麻豆午夜三级精品| 粉嫩欧美一区二区三区高清影视| 成人激情午夜影院| 欧美最新大片在线看| 6080日韩午夜伦伦午夜伦| 日韩视频在线永久播放| 久久色在线观看| 亚洲欧美综合另类在线卡通| 国产精品成人午夜| 首页亚洲欧美制服丝腿| 国产一区二区三区久久久| 91亚洲精品久久久蜜桃| 日韩一区二区三区高清免费看看| 久久精品亚洲精品国产欧美| 亚洲精品乱码久久久久久黑人| 舔着乳尖日韩一区| 国产成人在线电影| 欧美日韩国产综合草草| 国产欧美日韩亚州综合 | 精品理论电影在线观看| 日韩亚洲欧美综合| 国产精品乱码一区二三区小蝌蚪| 亚洲成a人v欧美综合天堂下载| 高清beeg欧美| 欧美日韩美少妇| 国产视频一区不卡| 三级精品在线观看| 99久久精品国产麻豆演员表| 91精品中文字幕一区二区三区| 中文成人综合网| 国产综合久久久久久鬼色| 91尤物视频在线观看| ww久久中文字幕| 天堂一区二区在线| 在线观看一区二区精品视频| 国产精品网曝门| 国产在线一区观看| 欧美精品亚洲一区二区在线播放| 国产精品国产三级国产专播品爱网| 久久91精品久久久久久秒播| 欧美性大战久久久| 综合欧美一区二区三区| 成人精品视频一区二区三区| 26uuu国产一区二区三区| 久久国产夜色精品鲁鲁99| 欧美色视频在线观看| 亚洲在线一区二区三区| 99国产精品久久久| 日韩理论在线观看| 国产成人亚洲精品青草天美| 久久这里只有精品6| 欧美a级理论片| 制服.丝袜.亚洲.另类.中文| 亚洲电影视频在线| 欧美日韩免费一区二区三区 | 日韩精品中文字幕一区| 亚洲bt欧美bt精品777| 精品视频999| 午夜精品福利一区二区三区av| 欧美日韩国产高清一区二区三区| 一区二区日韩av| 欧美日高清视频| 日韩电影一区二区三区四区| 欧美一区二区三区爱爱| 久草热8精品视频在线观看| 精品久久久久久久久久久久包黑料| 日韩av一二三| 久久久久久久久岛国免费| 国产综合一区二区| 国产精品国产三级国产aⅴ中文| www.一区二区| 亚洲高清久久久| 日韩一区二区三区三四区视频在线观看 | 色婷婷一区二区| 亚洲午夜精品在线| 精品少妇一区二区三区免费观看| 国内外成人在线| 亚洲少妇中出一区| 欧美男生操女生| 狠狠色狠狠色合久久伊人| 一区在线播放视频| 欧美图区在线视频| 国产一区二区三区在线观看免费 | 亚洲欧美偷拍三级| 欧美影视一区在线| 精品一区二区三区在线播放视频 | 在线精品视频小说1| 久久电影国产免费久久电影| 国产精品视频观看| 欧美精品 国产精品| 国产风韵犹存在线视精品| 亚洲午夜私人影院| 欧美精品一区二区三区四区| 99这里都是精品| 精品一区二区在线观看| 亚洲女同一区二区| 精品国产99国产精品| 欧美揉bbbbb揉bbbbb| 成人午夜看片网址| 蜜芽一区二区三区| 亚洲精品亚洲人成人网在线播放| 久久久综合网站| 欧美一区2区视频在线观看| 97se亚洲国产综合自在线观| 欧美96一区二区免费视频| 一区二区三区在线视频观看| 久久精品一区四区| 欧美一区二区在线播放| 一本大道av一区二区在线播放| 国内精品写真在线观看| 日韩激情av在线| 一区二区国产盗摄色噜噜| 中文字幕精品一区二区三区精品| 精品久久久久久久久久久久久久久| 欧美日韩国产大片| 欧美亚洲综合色| 色婷婷综合久久久中文字幕| 成人激情免费电影网址| 国产一区二区女| 狠狠色丁香婷婷综合| 琪琪久久久久日韩精品| 天天做天天摸天天爽国产一区| 一区二区三区久久久| 亚洲精品乱码久久久久久久久| 国产精品国产三级国产aⅴ入口 | 亚洲精品国产精华液| 国产精品免费看片| 国产人伦精品一区二区| 久久久久99精品一区| 久久久亚洲高清| 国产天堂亚洲国产碰碰| 国产日韩亚洲欧美综合| 国产精品网站一区| 亚洲免费观看高清完整版在线| 亚洲欧洲综合另类在线| 国产精品理伦片| 中文字幕亚洲电影| 亚洲人成小说网站色在线| 亚洲视频一区二区在线| 亚洲欧美一区二区三区孕妇| 一区二区成人在线观看| 午夜在线电影亚洲一区| 日韩电影在线观看电影| 蜜桃久久精品一区二区| 精品亚洲免费视频| 夫妻av一区二区| 欧美午夜精品一区二区蜜桃| 7777女厕盗摄久久久| 亚洲精品在线免费观看视频| 国产日韩欧美制服另类| 亚洲日本成人在线观看| 亚洲成人手机在线| 极品少妇xxxx精品少妇偷拍| 大白屁股一区二区视频| 在线免费观看日本欧美| 日韩一区二区免费视频| 久久综合久色欧美综合狠狠| 国产精品久久毛片av大全日韩| 亚洲男女毛片无遮挡| 午夜一区二区三区在线观看| 精品一区二区三区免费播放| www.欧美亚洲| 欧美群妇大交群中文字幕| 欧美成人一区二区三区| 国产精品久久久久久久久免费相片 | 国产三级精品在线| 亚洲人亚洲人成电影网站色| 日韩影院在线观看| 国产成人8x视频一区二区| 一本久久a久久精品亚洲 | 国产成人av一区二区三区在线 | 欧美人与z0zoxxxx视频| 久久在线观看免费| 亚洲一区中文在线| 国产精一区二区三区| 91美女蜜桃在线| 久久精品免视看| 天天操天天色综合|