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

📄 usb.h

📁 源代码
💻 H
字号:
//
//	@File : USB.H
//	@Description : Interface of EBOOT USB Boot downloader
//
 
#ifndef __USB_H_
#define __USB_H_

#include "usbcfg.h"		///< must included here

volatile S3C2440A_USBD_REG * pUSBCtrlAddr;
int g_DMAbufIndex = 0;
//int debugM = 0;
volatile int DMADone = 0;


static ULONG realPhysicalAddr_UsbdRxBuf=0;


volatile unsigned char downArr[BUFARRAYSIZE];
volatile unsigned char *downPt;

U32 VA2PA(U32 va)
{
	if ((va >= 0xA0000000) && (va < 0xA4000000))
		{
			return (va - 0xA0000000 + 0x30000000);
		}
	if ((va >= 0x80000000) && (va < 0x84000000))
		{
			return (va - 0x80000000 + 0x30000000);
		}
	if ((va >= 0x30000000) && (va < 0x34000000))
		{
			EdbgOutputDebugString("Invalid VA (0x%08x) return (0x%08x)\r\n", va, va);
			return va;
		}
	return 0x0;
}

volatile unsigned int downPtIndex = DMABUFFER_VA; //DMABUFFER;
volatile unsigned int readPtIndex = DMABUFFER_VA; //DMABUFFER;
volatile unsigned int loopcnt = 0;
volatile DWORD DownloadAddress, TotalSize;

static U8 ep1Buf[EP1_PKT_SIZE];
static int transferIndex=0;

extern void IsrHandler(void);		// in usb.s	by J.I modifed(8/22)
void Isr_Init(void);
void IsrUsbd(unsigned int val);
//static void Ep3Handler(void);
static void Ep4Handler(void);			// by J.I inserted(8/22)
//static void ConfigEp3DmaMode(U32 bufAddr,U32 count);
static void ConfigEp4DmaMode(U32 bufAddr,U32 count);
//static void DMA2Handler(void);
static void DMA3Handler(void);		// by J.I inserted(8/22)


static void InitDescriptorTable(void);
BOOL InitUSB(void);
static void ReconfigUsbd(void);


static U32 ep0State;

volatile U8 Rwuen;
volatile U8 Selfpwr=TRUE;

struct USB_SETUP_DATA{
	U8 bmRequestType;    
	U8 bRequest;         
	U8 bValueL;          
	U8 bValueH;          
	U8 bIndexL;          
	U8 bIndexH;          
	U8 bLengthL;         
	U8 bLengthH;         
};

struct USB_DEVICE_DESCRIPTOR{
	U8 bLength;    
	U8 bDescriptorType;         
	U8 bcdUSBL;
	U8 bcdUSBH;
	U8 bDeviceClass;
	U8 bDeviceSubClass;
	U8 bDeviceProtocol;
	U8 bMaxPacketSize0;
	U8 idVendorL;
	U8 idVendorH;
	U8 idProductL;
	U8 idProductH;
	U8 bcdDeviceL;
	U8 bcdDeviceH;
	U8 iManufacturer;
	U8 iProduct;
	U8 iSerialNumber;
	U8 bNumConfigurations;
};

struct USB_CONFIGURATION_DESCRIPTOR{
	U8 bLength;    
	U8 bDescriptorType;         
	U8 wTotalLengthL;
	U8 wTotalLengthH;
	U8 bNumInterfaces;
	U8 bConfigurationValue;
	U8 iConfiguration;
	U8 bmAttributes;
	U8 maxPower;          
};

struct USB_INTERFACE_DESCRIPTOR{
	U8 bLength;    
	U8 bDescriptorType;         
	U8 bInterfaceNumber;
	U8 bAlternateSetting;
	U8 bNumEndpoints;
	U8 bInterfaceClass;
	U8 bInterfaceSubClass;
	U8 bInterfaceProtocol;
	U8 iInterface;
};

struct USB_ENDPOINT_DESCRIPTOR{
	U8 bLength;    
	U8 bDescriptorType;         
	U8 bEndpointAddress;
	U8 bmAttributes;
	U8 wMaxPacketSizeL;
	U8 wMaxPacketSizeH;
	U8 bInterval;
};

struct USB_CONFIGURATION_SET{
	U8 ConfigurationValue;
};

struct USB_GET_STATUS{
	U8 Device;
	U8 Interface;
	U8 Endpoint0;
	U8 Endpoint1;
//	U8 Endpoint3;
	U8 Endpoint4;	// by J.I modified(8/22)
};

struct USB_INTERFACE_GET{
	U8 AlternateSetting;
};

struct USB_SETUP_DATA descSetup;
struct USB_DEVICE_DESCRIPTOR descDev;
struct USB_CONFIGURATION_DESCRIPTOR descConf;
struct USB_INTERFACE_DESCRIPTOR descIf;
struct USB_ENDPOINT_DESCRIPTOR descEndpt0;
struct USB_ENDPOINT_DESCRIPTOR descEndpt1;
struct USB_CONFIGURATION_SET ConfigSet;
struct USB_INTERFACE_GET InterfaceGet;
struct USB_GET_STATUS StatusGet;   //={0,0,0,0,0};



static const U8 descStr0[]={
	4,STRING_TYPE,LANGID_US_L,LANGID_US_H,  //codes representing languages
    };

static const U8 descStr1[]={  //Manufacturer  
        (0x14+2),STRING_TYPE, 
        'S',0x0,'y',0x0,'s',0x0,'t',0x0,'e',0x0,'m',0x0,' ',0x0,'M',0x0,
        'C',0x0,'U',0x0,
    };
    
static const U8 descStr2[]={  //Product  
        (0x2a+2),STRING_TYPE, 
        'S',0x0,'E',0x0,'C',0x0,' ',0x0,'S',0x0,'3',0x0,'C',0x0,'2',0x0,
        '4',0x0,'1',0x0,'0',0x0,'X',0x0,' ',0x0,'T',0x0,'e',0x0,'s',0x0,
        't',0x0,' ',0x0,'B',0x0,'/',0x0,'D',0x0
    };

#endif // __USB_H_	

⌨️ 快捷键说明

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