//***********************************************************************
// *
// P H I L I P S P R O P R I E T A R Y *
// *
// COPYRIGHT (c) 1999 BY PHILIPS SINGAPORE (APIC). *
// -- ALL RIGHTS RESERVED -- *
// *
// File Name : USBDebug.c *
// Author : Albert Goh *
// Created : 3 March 2000 *
// *
//***********************************************************************
//***********************************************************************
// *
// USBDebug has the ability to test the USB core in Bus enumeration or *
// in CBI/bulk mode. *
// *
//***********************************************************************
//***********************************************************************
// *
// Module History *
// ************** *
// *
// Date Version Author Changes *
// ==== ======= ====== ======= *
// 030300 0.1 Albert Created *
// *
//***********************************************************************
//***********************************************************************
//* *
//* Include Files Definition *
//* *
//***********************************************************************
#include "standard.h"
#include "Kernel.h"
#include "D14.h"
#include "usb.h"
#define SETUP_DMA_REQUEST 0x7104
#define GET_FIRMWARE_VERSION 0x7204
#define GET_SET_TWAIN_REQUEST 0x7304
extern volatile D14_CNTRL_REG xdata D14_Cntrl_Reg;
extern void Init_D14(void);
extern UC code FS_Device_Descriptor[];
extern UC code HS_Device_Descriptor[];
extern UC code Device_Qualifier_HS_Info[];
extern UC code Device_Qualifier_FS_Info[];
extern UC code FS_Config_Descriptor[];
extern UC code HS_Config_Descriptor[];
extern UC code Config_Descriptor_HS_Info[];
extern UC code Config_Descriptor_FS_Info[];
extern UC code Standard_Manufacturer_String[];
extern UC code Standard_Product_String[];
extern UC code Standard_String_ID[];
extern UC code HS_Interface_Descriptor_Default[];
extern UC code HS_Interface_Descriptor_Alternate1[];
extern UC code HS_Interface_Descriptor_Alternate2[];
extern UC code HS_Interface_Descriptor_Alternate3[];
extern UC code Interface_Descriptor_Default[];
extern UC code Interface_Descriptor_Alternate1[];
extern UC code Interface_Descriptor_Alternate2[];
extern UC code Iso_In_1024_Descriptor[];
extern UC code Iso_In_1020_Descriptor[];
extern UC code Iso_In_512_Descriptor[];
extern UC code Iso_In_128_Descriptor[];
extern UC code Iso_In_Zero_Descriptor[];
extern UC code Int_In_Descriptor[];
//TEST_BULK
extern UC code Bulk_In_512_Descriptor[];
extern UC code Bulk_In_256_Descriptor[];
extern UC code Bulk_In_64_Descriptor[];
//TEST_BULK
extern UI count;
extern void Start_mSEC_Timer(Data);
extern UI Temp;
UC Device_Config_Value;
extern KERNEL Kernel_Flag;
extern DMA_INT_FLAG DMA_Int_Flag;
extern USB_INT_FLAG USB_Int_Flag;
extern UC code Test_Packet[];
extern void Enable_Endpoint(void);
//***********************************************************************
//* *
//* Prototype Routine Definition *
//* *
//***********************************************************************
void USB_SOF(void);
void USB_uSOF(void);
void USB_DMA_State(void);
void USB_Setup(void);
void fn_Not_Implemented(void);
void Send_Device_Status(void);
void Send_Interface_Status(void);
void Send_Endpoint_Status(void);
void Send_Device_Descriptor(void);
void Send_FS_Configuration_Descriptor(void);
void Send_HS_Configuration_Descriptor(void);
void Send_Product_String(void);
void Send_Manufacturer_String(void);
void Send_String_ID(void);
void Bulk_In(void);
void Bulk_Out(void);
void Control_Out_Endpt(void);
void Control_In_Endpt(void);
void Int_Out(void);
void Int_In(void);
void Iso_Out(void);
void Iso_In(void);
void Set_Configuration(void);
void Get_Configuration(void);
void Set_Interface_Request(void);
void Get_Interface_Request(void);
void Send_Qualifier_Descriptor(void);
void Send_Configuration_Descriptor_FSInfo(void);
void Send_Configuration_Descriptor_HSInfo(void);
//void Get_CBI_Command(void);
void Process_Synch_Frame(void);
extern void Vendor_Specific_Command(void);
extern void Init_Endpoint(void);
//***********************************************************************
//* *
//* Variable Definition *
//* *
//***********************************************************************
USB_INT_FLAG USB_Int_Flag;
USB_DEVICE_REQ idata USB_Device_Request;
USB_DEVICE USB_Device;
UC code *Descriptor_Ptr;
UC idata Endpt_FIFO[64];
UI FIFO_Count;
UC idata File_Number;
UC idata Current_File;
FILESIZE idata FileSize;
ULI bytecount;
//***********************************************************************
//* *
//* Routine Definition *
//* *
//***********************************************************************
//***********************************************************************
//* *
//* Routine : USB Debug Mode *
//* Input : USB Interrupt Register *
//* Output : None *
//* Function : Branch to respective ISR *
//* *
//***********************************************************************
void USB_Debug_Mode(void)
{
if(USB_Int_Flag.BITS.EP0SETUP)
USB_Setup();
if(USB_Int_Flag.VALUE!=0)
{
/* if(USB_Int_Flag.BITS.SOF)
USB_Int_Flag.BITS.SOF=0;
if(USB_Int_Flag.BITS.uSOF)
USB_Int_Flag.BITS.uSOF=0;*/
if(USB_Int_Flag.BITS.SUSP)
{
USB_Int_Flag.BITS.SUSP = 0;//clear flag
D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 1;
D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 0;
//Write a 1 followed by a 0, activate suspend mode.
}
if(USB_Int_Flag.BITS.RESUME)
{
USB_Int_Flag.BITS.RESUME = 0;
D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 1;
D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 0;
//Write a 1 followed by a 0, issue a resume signal.
D14_Cntrl_Reg.D14_UNLOCK_DEVICE_LSB = 0x37;
D14_Cntrl_Reg.D14_UNLOCK_DEVICE_MSB = 0xAA;
//Write 0xaa37 to unlock the FIFOs.
}
if(USB_Int_Flag.BITS.HS_STAT)
{
USB_Int_Flag.BITS.HS_STAT = 0;
if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
{
// HS_FS_LED = HIGH_SPEED;
Kernel_Flag.BITS.HS_FS_State = HIGH_SPEED;
Init_Endpoint();
}
}
if(USB_Int_Flag.BITS.DMA)
{
USB_Int_Flag.BITS.DMA = 0;
Kernel_Flag.BITS.Transfer_Start =1;
}
/* if(USB_Int_Flag.BITS.EP0TX)
USB_Int_Flag.BITS.EP0TX = 0;
if(USB_Int_Flag.BITS.EP0RX)
USB_Int_Flag.BITS.EP0RX = 0;//*/
}
}
//***********************************************************************
//*
USB2.0_ISP1581_driver
5星 · 超过95%的资源 需积分: 11 159 浏览量
2009-02-02
19:43:42
上传
评论
收藏 29KB RAR 举报
juliet_88
- 粉丝: 1
- 资源: 25