dsp281x_memcopy.c

来自「一个DSP2812的源代码」· C语言 代码 · 共 81 行

C
81
字号
//###########################################################################
//
// FILE:	DSP281x_MemCopy.c
//
// TITLE:	Memory Copy Utility
//
// ASSUMPTIONS:
//
//          
//
// DESCRIPTION:
//
//          This function will copy the specified memory contents from
//          one location to another. 
// 
//          Uint16 *SourceAddr        Pointer to the first word to be moved
//                                    SourceAddr < SourceEndAddr
//          Uint16* SourceEndAddr     Pointer to the last word to be moved
//          Uint16* DestAddr          Pointer to the first destination word
//
//          No checks are made for invalid memory locations or that the
//          end address is > then the first start address.
// 
//          
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  1.00| 11 Sep 2003 | L.H. | No changes since previous version (v.58 Alpha)
//
//###########################################################################

#include "DSP281x_Device.h"
#include "FM25L512.h"

void MemReadAndWrite(Uint32 *SourceAddr, Uint32 *SourceEndAddr, Uint32 *DestAddr, Uint32 Length, int16 Flag );


void MemCopy(Uint16 *SourceAddr, Uint16 *SourceEndAddr, Uint16 *DestAddr)
{
    while(SourceAddr < SourceEndAddr)
    { 
       *DestAddr++ = *SourceAddr++;
    }
    return;
}

void MemReadAndWrite(Uint32 *SourceAddr, Uint32 *SourceEndAddr, Uint32 *DestAddr, Uint32 Length, int16 Flag )
{   
    Uint32  i;

	ZONE2_CTRL_CS_L;
    if(Flag == WRITE)
	{
		for(i=0;i<Length;i++)
		{ 
	      if(SourceAddr < SourceEndAddr)
		  {
			*SourceAddr++ = *DestAddr++;
		  }
		  else
		    SourceAddr = ZONE2_BASE;
		}
	}

	if(Flag == READ)
	{
		for(i=0;i<Length;i++)
		{ 
	      if(SourceAddr < SourceEndAddr)
		  {
			*DestAddr++ = *SourceAddr++;
		  }
		  else
		    SourceAddr = ZONE2_BASE;
		}
	}
    ZONE2_CTRL_CS_H;
    return;
}

⌨️ 快捷键说明

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