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

📄 d12op.h

📁 44b0+PDIUSBD12开发的U盘源码
💻 H
字号:
#ifndef __D12OP_H__
#define __D12OP_H__

  
#include "D12Def.h"
 
#include "D12Int.h"
#include "..\INC\user.h"
#include "..\MassStorage\FAT.h"

  


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 D12Dat; 
}

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

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

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

void D12Main(void)
{
	U8 i;
	/********************************/
	InitVDisk();//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
	UFI_Init();
	/********************************/
	 
 	Uart_SendString("search");
	if(UsbRdChipId()==0x1210)
	{	
		Uart_SendString("Pdiusbd12 Found, chip id = 0x1210\n");
		 
		
		if( UsbInit() == 1 )		//STAUS_ERR
		{	
			Uart_SendString("USB Device Initial is Error! \n" ) ;
			return ;
		}
		
		while(1)
		{	 
		
			i = D12RdInt();
			if(i)   
			UsbIntProc(i);	
		}
		
		D12SetMode(MyD12EpCfgOff, D12Pll24M);	//pull-up off
	}
	else
	{
		Uart_SendString("No Pdiusbd12 Found\n");
	}
}

#endif

⌨️ 快捷键说明

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