stspearnet.c
来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 64 行
C
64 行
//-----------------------------------------------------------------------------
// SPEArNet DMA transfer example
//-----------------------------------------------------------------------------
#include "hal_map.h"
#include "hal_type.h"
#include "hal_dma.h"
#include "hal_ic.h"
#include "hal_gpio.h"
//-----------------------------------------------------------------------------
volatile void delay(int time)
{
unsigned short i, j;
for(j=0; j<time; j++){
for(i=0; i<0xFFFF; i++);
}
}
//-----------------------------------------------------------------------------
//name: MAIN_Dma()
//funcionality: Demonstrates the DMA data transfers. In this example a simple
//memory to memory transfer is demonstrated.
//-----------------------------------------------------------------------------
void MAIN_Dma(void){
u32 addressSrc = 0x10000000;
u32 addressDst = 0x10000020;
//Clear Src and Dest addreses
*(u32 *)addressSrc = 0x0;*(u32 *)(addressSrc+4) = 0x0;
*(u32 *)addressDst = 0x0;*(u32 *)(addressDst+4) = 0x0;
//Values for test purposes in external SDRAM
*(u32 *)addressSrc = 0x12345678;
*(u32 *)(addressSrc+4) = 0x89ABCDEF;
//DMA controller settings
DMA_SetSrcAddress(DMA_CH3,addressSrc);
DMA_SetDstAddress(DMA_CH3,addressDst);
DMA_Init(DMA_CH3, 2); //you can limit number of units to be copied only during the burst mode
DMA_EnableInterrupt(DMA_CH3);
GPIO_Init(GPIO_ALL_AS_OUTs);
//Global interrupts
IC_Clear ();
IC_Global_OnOff (IC_IRQ,ENABLE);
IC_Global_OnOff (IC_FIQ,DISABLE);
IC_Int_Config (IC_DMA,IC_HIGH_LEVEL);
IC_Int_OnOff (IC_DMA,ENABLE);
DMA_Start(DMA_CH3); //Start the Mem to Mem transfer
}
//-----------------------------------------------------------------------------
int main()
{
MAIN_Dma();//
}
//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?