📄 gfd_dmac.c
字号:
/**************************************************************************************
*
* (c) 2004 ASIC,all rights reserved
*
*
* This source code and any compilation or derivative thereof
*is proprietary information and is confidential in nature.
* Under no circumstance is this software to be exposed or placed
*under an open source License of any type without expressed
*written permission of ASIC.
*
*filename: HA_Dmac.c
*history:
*
* Version Date Author Comment
*------------------------------------------------------------------------------------
* 1.0 2004.9.24 lmq Initial Creation
* 1.1 2005.3.24 xl delete the HA_DMA_TRANS_TX1 function ,changed
USB_DMA_TRANS_TX function interrupt judge condition
**************************************************************************************/
#include "HA_TypeDef.h"
#include "gfd_dmac.h"
#include "gfd_usb_irq.h"
#include "hardware_reg.h"
#include "hardware.h"
///////
//extern global variable
//////
extern struct USBDevice MSDevice;
ER HA_InitDMAC(void)
{
/////////////////////////////////////////////intial the register DMACIntErrClr DMACIntTCClear
*(RP) DMACIntErrClr =0xFFFFFFFF;
*(RP)DMACIntTCClear =0xFFFFFFFF;
*(RP)DMACIntErrClr =0x00000000;
*(RP)DMACIntTCClear =0x00000000;
return 0;
}
ER HA_DMA_TRANS_test(U32 souadress, U32 destadress, U32 datawidth, U32 datalength, U32 tansnum)
{
U32 temp,temp1,temp2,temp3,i;
*(RP)DMACSouAdd_test = souadress;
*(RP)DMACdesAdd_test = destadress;
temp1 = 0xb0000000;
if (datawidth == 0x8) temp2 = 0x0;
else if (datawidth == 0x16) temp2 = 0x1;
else if (datawidth == 0x32) temp2 = 0x2;
if (datalength == 0x16) temp3 = 0x10;
else if (datalength == 0x8) temp3 = 0x8;
else if (datalength == 0x4) temp3 = 0x4;
else if (datalength == 0x1) temp3 = 0x1;
temp = (tansnum & 0xfff) + temp1 + (temp2 << 24) + (temp3 << 16);
*(RP)DMACContr_test = temp;
*(RP)DMACEnbldChns_test = 0x000001;
i = *(RP)DMACComplish_test;
while((i&0x1) != 0x1)
{ i = *(RP)DMACComplish_test; };
return 1;
}
ER USB_DMA_TRANS_RX(U32 srcadd, U32 destadd, U32 srcwidth, U32 destwidth, U32 srcsize, U32 channelnum, U32 transnum)
{
//Parameters Notes:
//sourcewidth: byte/halfword/word
//destwidth: byte/halfword/word
//sourcesize: 1,4,8,16
//channelnum: 0-5 general channel--DMA通道选择
//transnum: number of to be transed data,by source data width--数据传输数目
//
//note: destsize is omitted,because sourcewidth*sourcesize
// must=destwidth*destsize
U32 temp;
U32 tempdata,temp1,temp2,temp3;
U32 tempsrc,tempdest,tempcontrol,tempconfig;
temp = channelnum;
tempsrc = DMACbase + 0x1000 + temp*0x100;
tempdest = DMACbase + 0x1004 + temp*0x100;
*(RP)tempsrc = srcadd;
*(RP)tempdest = destadd;
tempcontrol = DMACbase + 0x100c + temp*0x100;
tempconfig = DMACbase + 0x1010 + temp*0x100;
temp1 = (transnum << 2) + 0x2;
temp2 = temp1 << 12;
if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x4))
temp3 = 0x49b;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x4ad;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x4bf;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x2bd;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x2ab;
else if ((srcwidth == 0x32)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x0bb;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x46f;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x45d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x25b;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x26d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x27f;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x06b;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x07d;
else if ((srcwidth == 0x8)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x41f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x22f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x21d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x01b;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x02d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x16))
temp3 = 0x03f;
tempdata = temp2 + temp3; //设置控制寄存器
*(RP)tempcontrol = tempdata;
if (MSDevice.dUSBStat.usbdmapp == APP){
*(RP)tempconfig =0X08d;
}else{
*(RP)tempconfig =0X09d;
}
return 0;
}
ER USB_DMA_TRANS_TX(U32 srcadd, U32 destadd, U32 srcwidth, U32 destwidth, U32 srcsize, U32 channelnum, U32 transnum)
{
//Parameters Notes:
//sourcewidth: byte/halfword/word
//destwidth: byte/halfword/word
//sourcesize: 1,4,8,16
//channelnum: 0-5 general channel --DMA 通道选择
//transnum: number of to be transed data,by source data width
//
//note: destsize is omitted,because sourcewidth*sourcesize
// must=destwidth*destsize
U32 temp;
U32 tempdata,temp1,temp2,temp3;
U32 tempsrc,tempdest,tempcontrol,tempconfig;
temp = channelnum;
tempsrc = DMACbase + 0x1000 + temp*0x100;
tempdest = DMACbase + 0x1004 + temp*0x100;
*(RP)tempsrc = srcadd;
*(RP)tempdest = destadd;
tempcontrol = DMACbase + 0x100c + temp*0x100;
tempconfig = DMACbase + 0x1010 + temp*0x100;
temp1 = (transnum << 2) + 0x1;
temp2 = temp1 << 12;
if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x4))
temp3 = 0x49b;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x4ad;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x4bf;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x2bd;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x2ab;
else if ((srcwidth == 0x32)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x0bb;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x46f;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x45d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x25b;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x26d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x27f;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x06b;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x07d;
else if ((srcwidth == 0x8)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x41f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x22f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x21d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x01b;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x02d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x16))
temp3 = 0x03f;
tempdata = temp2 + temp3; //设置控制寄存器
*(RP)tempcontrol = tempdata;
if(MSDevice.dUSBStat.usbdmapp == APP)
{
*(RP)tempconfig =0X80b;
}
else
{
*(RP)tempconfig =0X81b;
}
return 0;
}
ER HA_DMA_INITIAL_ONECHANNEL(U32 channelnum) //初始化单个DMA 通道
{
U32 temp = 0x1;
U32 num;
num = channelnum;
while(num != 0)
{
temp = temp*2;
num = num - 1;
}
*(RP)DMACIntErrClr = (U32)temp;
*(RP)DMACIntTCClear =(U32)temp;
*(RP)DMACIntErrClr =0x00000000;
*(RP)DMACIntTCClear =0x00000000;
return 0;
}
void ENT_INT_DMA( void )
{
ent_int();
mask_irq(INT_DMA);
if(MSDevice.dUSBStat.usbdmapp == APP)
{
usbdma();
}
unmask_irq(INT_DMA);
ret_int();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -