evmdm642_flash_write.c

来自「dm642 最重要的片上库evmdm642bsl.lib的编译源码 在ccs环境」· C语言 代码 · 共 46 行

C
46
字号
/*
 *  Copyright 2003 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 */

/*
 *  ======== evmdm642_flash_write.c ========
 *  EVMDM642_FLASH_write() implementation
 */

#include <std.h>
#include <csl.h>

#include <evmdm642.h>
#include <evmdm642_flash.h>

/* Write data to a data range in Flash */
void EVMDM642_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
{
    Uint8 *psrc, *pdst;
    Uint32 i;

    /* Establish source and destination */
    psrc = (Uint8 *)src;
    pdst = (Uint8 *)dst; 
    for (i = 0; i < length; i++)
    {
        // Program one 8-bit word
        *((Uint8 *)EVMDM642_FLASH_BASE) = 0xaa;
        *((Uint8 *)EVMDM642_FLASH_BASE) = 0x55;
        *((Uint8 *)EVMDM642_FLASH_BASE) = 0xa0;
        *pdst = *psrc;
        
        // Wait for operation to complete
        while(1)
            if (*pdst == *psrc)
                break;
                
        pdst++;
        psrc++;
    }
    
    /* Put back in read mode */
    *((Uint16 *)EVMDM642_FLASH_BASE) = 0xf0;    
}

⌨️ 快捷键说明

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