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

📄 davincievm_flash_gettotalpages.c

📁 TI的DM6446的硬件平台搭建的相关例子
💻 C
字号:
/*
 *  Copyright 2005 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 *
 *  Not for distribution.
 */

/*
 *  Flash implementation - Compute AMD Flash total pages
 *
 */

#include "davincievm_flash.h"

/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  DAVINCIEVM_FLASH_getTotalPages( number_devices )                        *
 *      Compute the total number of Flash pages                             *
 *                                                                          *
 *      num_flash_device  <- number of Flash device chips                   *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Uint32 DAVINCIEVM_FLASH_getTotalPages( Uint16 number_devices )
{
    Uint32 i;
    Uint16 mfg_id;
    Uint16 dev_id[3];
    Uint16 dev_size_pow2;

    Uint32 total_pages = 0;

    Uint32 flash_base = FLASH_BASE;
    volatile Uint16* flash_ctl055;
    volatile Uint16* flash_ctl555;
    volatile Uint16* flash_ctl2AA;

    /* Flash Mode: Read Array */
    *( volatile Uint16* )( flash_base ) = FLASH_RESET;

    /* Loop through the total number of Flash devices */
    for ( i = 0 ; i < number_devices ; i++ )
    {
        flash_ctl055 = ( Uint16* )( flash_base + 0xAA );
        flash_ctl555 = ( Uint16* )( flash_base + 0xAAA );
        flash_ctl2AA = ( Uint16* )( flash_base + 0x554 );

        /* Flash Mode: CFI */
        *flash_ctl055 = FLASH_CFI_QUERY;
        dev_size_pow2 = *( volatile Uint16* )( flash_base + 0x4E );

        /* Flash Mode: Read Array */
        *( volatile Uint16* )flash_base = FLASH_RESET;

        /* Flash Mode: Autoselect */
        *flash_ctl555 = FLASH_CMD_AA;
        *flash_ctl2AA = FLASH_CMD_55;
        *flash_ctl555 = FLASH_ID;

        /* Read MFG_ID */
        mfg_id = *( volatile Uint16* )( flash_base );

        /* Read DEV_ID */
        dev_id[0] = *( volatile Uint16* )( flash_base + 0x02 );
        dev_id[1] = *( volatile Uint16* )( flash_base + 0x1C );
        dev_id[2] = *( volatile Uint16* )( flash_base + 0x1E );

        /* Flash Mode: Read Array */
        *( volatile Uint16* )( flash_base ) = FLASH_RESET;

        /* AMD Flash */
        if ( ( mfg_id == MFG_AMD )
            && ( dev_id[0] == DEV_AM29LV256M_1 )
            && ( dev_id[1] == DEV_AM29LV256M_2 )
            && ( dev_id[2] == DEV_AM29LV256M_3 ) )
                total_pages += 1 << ( dev_size_pow2 - FLASH_PAGESIZE_POW2 );

        /* Set the current page addr to take into account the new sizes */
        flash_base += total_pages * FLASH_PAGESIZE;
    }

    /* Return total pages of Flash */
    return total_pages / 2;
}

⌨️ 快捷键说明

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