📄 dma_config.c
字号:
/******************************************************************************/
//
// Name: BF533 EZ-KIT DMA Setup
//
/******************************************************************************
(C) Copyright 2003 - Analog Devices, Inc. All rights reserved.
File Name: SDRAM_Config.c
Date Modified: 10/25/04 TL Rev 0.2
Software: VisualDSP++3.1
Hardware: ADSP-BF533 EZ-KIT Board
Special Connections: None
Purpose: The file sets up the DMA transfer
*********************************************************************************/
#include <services/services.h>
#include <cdefBF533.h>
#include "ezkitutilities.h"
#define Line_Length 720
#define Frame_Length 525
//#define BUFFERS 1 // number of descriptors in the chain (limited only by memory)
#define DMA_PPI_ID ADI_DMA_DMA0
//#define SourcePeripheralID ADI_DMA_MDMA_S0
//#define DestPeripheralID ADI_DMA_MDMA_D0
// storage for interrupt manager data
static u8 IntMgrData[(ADI_INT_SECONDARY_MEMORY)];
static ADI_DMA_DESCRIPTOR_LARGE SourceBuffers;
#define SDRAM_DATA_START 0x00000000 // We use SDRAM data starting at this address
#define SOURCE_DATA_START SDRAM_DATA_START
#define DESTINATION_DATA_START (SDRAM_DATA_START + (BUFFERS * ELEMENTS * BYTES_PER_ELEMENT))
// DMA Manager data (base memory + memory for 2 DMA channel)
static u8 DMAMgrData[ADI_DMA_BASE_MEMORY + (ADI_DMA_CHANNEL_MEMORY * 2)];
#define StartAddr_1 ((volatile unsigned short *)0x00000000)
extern int TransFlag=1;
volatile unsigned short pStartAddr_1=StartAddr_1;
//#include "flashsetup.h"
/*
void Init_DMA(void)
{
//Target address of the DMA
*pDMA0_START_ADDR = 0x0;
//Line_Length 16bit transfers will be executed
*pDMA0_X_COUNT = Line_Length;
//The modifier is set to 2 because of the 16bit transfers
*pDMA0_X_MODIFY = 0x2;
//Frame_Length 16bit transfers will be executed
*pDMA0_Y_COUNT = Frame_Length;
//The modifier is set to 2 because of the 16bit transfers
*pDMA0_Y_MODIFY = 0x2;
//PPI Peripheral is used
*pDMA0_PERIPHERAL_MAP = 0x0;
//DMA Config: Enable DMA | Memory write DMA | 2-D DMA | Discard DMA FIFO before start | enable assertation of interrupt | NDSIZE for stop mode | Enable STOP DMA
*pDMA0_CONFIG = DMAEN | DI_EN | WNR | WDSIZE_16| DMA2D | RESTART | DI_EN;
}//end Init_DMA
void Init_ADV(void)
{
unsigned char tempReg;
//De-assert the ADV7183 reset and link the ADV7183 Clock "LLC1" to the Blackfin PPI
//clock input.
tempReg = *pFlashA_PortA_Out;
*pFlashA_PortA_Out = tempReg | RST_7183 | PPICLK_ADV7183_SELECT;
//Setup the Blackfin PF registers
if ( ((*pDSPID) & 0xFFFF) < 0x2 ) { // Workaround for anomaly ID# 05000079 for rev 0.1
tempReg = *pFIO_INEN;
*pFIO_INEN = tempReg | ADV7183_OE;
}
//Blackfin PF2 pin must be set as output
tempReg = *pFIO_DIR;
*pFIO_DIR = tempReg | ADV7183_OE;
//Set the Blackfin pin PF2 to output enable the ADV7183 data bus
tempReg = *pFIO_FLAG_C;
*pFIO_FLAG_C = tempReg | ADV7183_OE;
}//end Init_ADV
*/
void DMA0_PPI_ISR(void) // <--|declaration in exception.h -->
{
int nBytes;
int i = 1;
int j=2;
volatile unsigned short * p; // |declaration with _pragma(interrupt) the ISR Startaddress
//disable the interrupt request
*pDMA0_IRQ_STATUS = 0x1;
*pSIC_IMASK=0x00000000;
printf( "\nThe DMA0 PPI Interrupt has been entered!\n" );
nBytes=720*525;
// p=StartAddr_1;
// Trans_Ram(pStartAddr_1,nBytes,TransFlag);
// printf( "\nThe DMA0 PPI Interrupt has been finished!\n" );
*pSIC_IMASK=0x00080000;
} //end DMA0_PPI_ISR
void Init_DMA(void)
{
u32 ResponseCount;
u16 Count;
ADI_DMA_CONFIG_REG DMA_ConfigReg;
ADI_DMA_CONFIG_REG DestConfigReg;
ADI_DMA_MANAGER_HANDLE DMAHandle;
ADI_DMA_CHANNEL_HANDLE ChanHandlePPI;
ADI_DMA_CHANNEL_HANDLE ChanHandleDest;
ezErrorCheck(adi_dma_Init(DMAMgrData, sizeof(DMAMgrData), &ResponseCount, &DMAHandle, NULL));
ezErrorCheck(adi_dma_Open(DMAHandle, DMA_PPI_ID, NULL, &ChanHandlePPI, ADI_DMA_MODE_SINGLE, NULL,DMA0_PPI_ISR));
DMA_ConfigReg.b_DI_EN=1; //interrupt
DMA_ConfigReg.b_WNR=1; //direction =1 write into memory
DMA_ConfigReg.b_DMA2D =1; //2D
// DMA_ConfigReg.b_RESTART=1;
DMA_ConfigReg.b_RESTART=1;
SourceBuffers.StartAddress=SOURCE_DATA_START;
// SourceBuffers[i].StartAddress = (void *)(SOURCE_DATA_START * i * ELEMENTS * BYTES_PER_ELEMENT); //SDRAM
SourceBuffers.Config = DMA_ConfigReg; // the config register we set up earlier
SourceBuffers.XCount = Line_Length;
SourceBuffers.XModify = 0x2; //16bits transfer
SourceBuffers.YCount = Frame_Length; // this is for 2-dimensional DMA only
SourceBuffers.YModify = 0x2; // this is for 2-dimensional DMA only
ezErrorCheck(adi_dma_Buffer (ChanHandlePPI,SourceBuffers.StartAddress,SourceBuffers.Config,SourceBuffers.XCount,SourceBuffers.XModify,SourceBuffers.YCount,SourceBuffers.YModify ));
ezErrorCheck(adi_dma_Control(ChanHandlePPI, ADI_DMA_CMD_SET_DATAFLOW, (void *)TRUE));
// ezErrorCheck(adi_dma_Open(DMAHandle, DestPeripheralID, NULL, &ChanHandleDest, ADI_DMA_MODE_SINGLE, NULL, NULL));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -