⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d12op.c

📁 s3c44b0+sl811读写u盘程序
💻 C
字号:
#include "..\inc\DataType.h"
#include "..\inc\D12Def.h"
#include "..\target\44b.h"

void d12_common(void);
void d12_keyboard(void);
void d12_mouse(void);

void * function_d12[][2]=
{
	(void *)d12_common, 	     "枚举为普通USB设备     ",
	(void *)d12_keyboard, 	     "枚举为HID KEYBOARD    ",
	(void *)d12_mouse, 	 "枚举为HID MOUSE       ",
        0,0
};

void d12_common(void)
{

}

void d12_keyboard(void)
{

}
void d12_mouse(void)
{
}

void D12SetEpStat(U8 Ep,U8 Stat)
{
	D12Cmd = Ep+0x40;	
	D12Dat = Stat;
}

void D12SetAddr(U8 Addr)
{
	D12Cmd = 0xd0;
	D12Dat = Addr;
}

void D12SetEp(U8 Val)
{
	D12Cmd = 0xd8;
	D12Dat = Val;
}

void D12SetDma(U8 Dma)
{
	D12Cmd = 0xfb;
	D12Dat = Dma;
}

void D12SetMode(U8 Val1, U8 Val2)
{
	D12Cmd = 0xf3;
	D12Dat = Val1;
	D12Dat = Val2;
}

void D12SendResume()
{
	D12Cmd = 0xf6;
}

void D12AckEp(U8 Ep)
{
	D12Cmd = Ep;
	D12Cmd = 0xf1;
	if(!Ep)
		D12Cmd = 0xf2;		
}

U32 D12RdChipId()
{
	U32 tmp;
	
	D12Cmd = 0xfd;
	tmp = D12Dat;
	tmp = tmp<<8|D12Dat;		
	return tmp;	
}

U8 D12GetDma()
{
	D12Cmd = 0xfb;
	return D12Cmd;
}

U8 D12RdEp(U8 Ep,U8 buf[],U8 cnt)
{
	U8 tmp;
	
	D12SelEp(Ep);
	if(D12Cmd&1)
	{
		D12Cmd = 0xf0;
		tmp = D12Cmd;
		tmp = D12Cmd;
		if(tmp<cnt)
			cnt = tmp;
		tmp = cnt;
		while(cnt)
		{
			*buf++ = D12Cmd;
			cnt--;
		}
		D12Cmd = 0xf2;
		return tmp;	
	}
	else
		return 0;		
}

void D12WrEp(U8 Ep, U8 buf[], U8 cnt)
{
	while(1)
	{
		D12SelEp(Ep);
		if(!(D12Cmd&1))
			break;
	}
	D12Cmd = 0xf0;
	D12Dat = 0;
	D12Dat = cnt;
	while(cnt)
	{
		D12Dat = *buf++;
		cnt--;
	}
	D12Cmd = 0xfa;
}

U8 D12RdInt()
{
	D12Cmd = 0xf4;
	return D12Cmd;
}

void d12_test(void)
{
 int i,uart_temp;
 if(UsbRdChipId()==0x1210)
	{
		Uart_Printf("Find Pdiusbd12, chip id = 0x1210 ");
		
		UsbInit();

    	ChangePllValue(24,6,1); //改系统主频为20MHZ
    	Uart_Init(20000000,115200);
		
		Uart_Printf("\n请用USB延长线连接开发板和电脑   退出本功能请按任意键");
		
		do
		{
		
			i = UsbQueryInt();
			UsbIntProc(i);			
		}while(!(rUTRSTAT0 & 0x1)); //Receive data read
		
		uart_temp=RdURXH0();
		
		ChangePllValue(0x3a,3,1); //改系统主频为66MHZ
    	Uart_Init(66000000,115200);
	}
}

U32 pIrqStart, pIrqFinish, pIrqHandler;

⌨️ 快捷键说明

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