📄 plx9054_bf533_test.c
字号:
//#include "plx_bf333.h"
//#include "register.h"
#include <cdefBF533.h>
#include "sysreg.h"
#include "ccblkfn.h"
#include <sys\exception.h>
#include <plx9054_bf533_test.h>
#include <signal.h>
//#define PF (*pFIO_FLAG_D)
//static section("myl1_buffer") unsigned short buf[256];
void initEbiu(void);
void initPFLAGS(void);
void Init_Interrupts(void);
void Init_DMA(void);
void Init_SDRAM(void);
void Init_PPI(void);
unsigned short *pAMS0 = (unsigned short*)0x20000000;
unsigned short *pAMS1 = (unsigned short*)0x20100000;
unsigned short *pAMS2 = (unsigned short*)0x20200000;
unsigned short *pAMS3 = (unsigned short*)0x20300000;
//ReadMem AMS1 , 0X2010 0000 -- 0X2010 01FF;
unsigned short *pRead = (unsigned short*)0x20100000;
//WriteMem AMS1 , 0X2010 0000 -- 0X2010 0FFF;
unsigned short *pWrite = (unsigned short*)0x20100000;
unsigned short *pInt9054 = (unsigned short*)0x20000004;
unsigned short *pSDRam = (unsigned short*)0x00000000;
unsigned short *pDspStatus = (unsigned short*)0x20300004;
unsigned short *pPenfaReg = (unsigned short*)0x20200004;
extern Plx_dsp_com dsp2plx;
extern DMA_DESC_PTR_LARGE Dma_desc_ptr_small[3];
section("myl1_buffer") unsigned short Parameter[PARAMETERMAXLENGTH];
section("myl1_buffer1") unsigned short Ppibuf0[PPIBUFFERLENGTH];
section("myl1_buffer2") unsigned short Ppibuf1[PPIBUFFERLENGTH];
section("myl1_buffer3") unsigned short Ppibuf2[PPIBUFFERLENGTH];
void delay(void)
{
unsigned char i ,j;
for( i = 0 ; i < 100 ; i++)
{
// for( j = 0 ; j <100;j++);
;
}
}
void InitVar()
{
unsigned long j ;
unsigned char i;
unsigned short k;
i=0;
for( j = 0 ; j <2048;j++)
{
pWrite[j] = 0;
pSDRam[j] = 0;//(i<<8)|i;
i++;
}
for(;j<1024*1024*16;j++)
{
pSDRam[j] = 0;//(i<<8)|i;
i++;
}
*pDspStatus = 0;
dsp2plx.L1ToSdramBank = 0;
dsp2plx.pSdramToFPGA = (ulong)pSDRam;
dsp2plx.SdramToFPGAOffset = 0;
dsp2plx.SdramToFPGABank = 0;
dsp2plx.pL1ToSdramAddr =0;
dsp2plx.L1ToSdramOffset = 0;
dsp2plx.NumberOfPpibuf = 0;
dsp2plx.NumberCalculationbuf = 0;
dsp2plx.firtPpiInterrupt = 0;
Dma_desc_ptr_small[0].NDPL = (int)&Dma_desc_ptr_small[1]&0xffff;
Dma_desc_ptr_small[0].NDPH = ((int)&Dma_desc_ptr_small[1]&0xffff0000)>>16;
Dma_desc_ptr_small[0].SAL = (int)(&Ppibuf0)&0xffff;
Dma_desc_ptr_small[0].SAH = ((int)&Ppibuf0&0xffff0000)>>16;
Dma_desc_ptr_small[0].DMACFG = (0x7<<12)|(0x9<<8)|WNR | WDSIZE_16 | DI_EN | RESTART|DMA_EN;//stop mode,16-bit transfer,open DMA0 channel
Dma_desc_ptr_small[0].XCNT = 4096;
Dma_desc_ptr_small[0].XMOD = 2;
Dma_desc_ptr_small[0].YCNT = 0;
Dma_desc_ptr_small[0].YMOD = 0;
Dma_desc_ptr_small[1].NDPL = 0xffff&(int)&Dma_desc_ptr_small[2];
Dma_desc_ptr_small[1].NDPH = ((int)&Dma_desc_ptr_small[2]&0xffff0000)>>16;
Dma_desc_ptr_small[1].SAL = (int)&Ppibuf1&0xffff;
Dma_desc_ptr_small[1].SAH = ((int)&Ppibuf1&0xffff0000)>>16;
Dma_desc_ptr_small[1].DMACFG = (0x7<<12)|(0x9<<8)|WNR | WDSIZE_16 | DI_EN | RESTART|DMA_EN;//stop mode,16-bit transfer,open DMA0 channel
Dma_desc_ptr_small[1].XCNT = 4096;
Dma_desc_ptr_small[1].XMOD = 2;
Dma_desc_ptr_small[1].YCNT = 0;
Dma_desc_ptr_small[1].YMOD = 0;
Dma_desc_ptr_small[2].NDPL = 0xffff&(int)&Dma_desc_ptr_small[0];
Dma_desc_ptr_small[2].NDPH = ((int)&Dma_desc_ptr_small[0]&0xffff0000)>>16;
Dma_desc_ptr_small[2].SAL = (int)&Ppibuf2&0xffff;
Dma_desc_ptr_small[2].SAH = ((int)&Ppibuf2&0xffff0000)>>16;
Dma_desc_ptr_small[2].DMACFG = (0x7<<12)|(0x9<<8)|WNR | WDSIZE_16 | DI_EN | RESTART|DMA_EN;//stop mode,16-bit transfer,open DMA0 channel
Dma_desc_ptr_small[2].XCNT = 4096;
Dma_desc_ptr_small[2].XMOD = 2;
Dma_desc_ptr_small[2].YCNT = 0;
Dma_desc_ptr_small[2].YMOD = 0;
k = 0;
i = 0;
for( j = 0 ; j < 0x2000000;j+=2)
{
if(i <128)
{
pSDRam[j] = (j<<7)|i;
pSDRam[j+1] = j>>1;
}
else
{
pSDRam[j] = (k<<8)|k;
pSDRam[j+1] = k;
}
i++;
if(i ==0)
{
k++;
if(k == 256)
k = 0;
}
}
}
void TestRead()
{
}
void changedata()
{
unsigned long l_j;
unsigned char l_i;
l_i = 0;
for( l_j = 0 ; l_j < 0x2000000;l_j+=2)
{
pSDRam[l_j] = (l_j<<7)|l_i;
pSDRam[l_j+1] = l_j>>1;
l_i++;
}
}
void changedata2()
{
unsigned long j;
unsigned char i;
unsigned short k ;
k = 0;
for( j = 0 ; j < 0x2000000;j+=2)
{
if(i <128)
{
pSDRam[j] = (j<<7)|i;
pSDRam[j+1] = j>>1;
}
else
{
pSDRam[j] = (k<<8)|k;
pSDRam[j+1] = k;
}
i++;
if(i ==0)
{
k++;
if(k == 256)
k = 0;
}
}
}
void main(void)
{
unsigned long i = 2,j,k;
// signal(SIGRSET,main);
ushort reg;
ushort tempNumberOfPpibuf;
ulong StartAddrL1;
*pPLL_CTL = 0x0001|((40)<<9);
reg = cli();
idle();
sti(reg);
initEbiu();
initPFLAGS();
Init_SDRAM();
InitVar();
Init_DMA();
Init_PPI();
Init_Interrupts();
// TestRead();
while(1)
{
for( i = 0 ; i < 600*250;i++);
if(dsp2plx.firtPpiInterrupt&0x0001 )
{
tempNumberOfPpibuf = dsp2plx.NumberOfPpibuf;
//do something
//
/* dsp2plx.NumberCalculationbuf++;
if(dsp2plx.NumberCalculationbuf>=3)
dsp2plx.NumberCalculationbuf = 0;
*/
switch (dsp2plx.NumberCalculationbuf)
{
case 0: StartAddrL1 = &Ppibuf0;
break;
case 1: StartAddrL1 = &Ppibuf1;
break;
case 2: StartAddrL1 = &Ppibuf2;
break;
default:
}
// StartAddrL1 = (int)&Ppibuf0;
dsp2plx.pL1ToSdramAddr = (ulong)( pSDRam+dsp2plx.L1ToSdramBank*4*1024*1024)+dsp2plx.L1ToSdramOffset;
L1DMASdram(StartAddrL1,dsp2plx.pL1ToSdramAddr);
// L1DMASdram(StartAddrL1,0);
//while(tempNumberOfPpibuf == dsp2plx.NumberOfPpibuf);
}//end of if outer
}//end of while
}//end of main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -