📄 mkit100.c
字号:
sprintf(m_udn+cnt,"%c",*(reply_ptr+cnt+1));
cnt++;
}
while(cnt<name_length);
printf("\nManufacturer : %s",m_udn);
}
}
}
if(iInterface!=0)
{
ccode=get_control(reply_ptr,3,'S',iInterface);
decode_ccode(ccode,message);
printf("\nGet Interface... %s",message);
name_length=( (*reply_ptr&0x00FF)>>1 );
if(name_length!=0)
{
printf("\nName length is %d",name_length);
name_length--;
if( ( (ccode==0)||(ccode>7) ) && (name_length>0) )
{
cnt=0;
do
{
sprintf(i_udn+cnt,"%c",*(reply_ptr+cnt+1));
cnt++;
}
while(cnt<name_length);
printf("\nInterface : %s",i_udn);
}
}
}
printf("\n\nPress any key to continue...");
getch();
clrscr();
do
{
printf("\nISP1161 Enumeration Demo");
printf("\n========================");
printf("\n[d] Display Device Descriptor");
printf("\n[c] Display Configuration Descriptor");
printf("\n[9] Exit This Routine");
printf("\n\n\nThe descriptor has been recorded at the beginning of");
printf("\nthe routine. Choose exit if you wish to re-enumerate.");
gotoxy(1,18);
printf("\nUSB Device Information");
printf("\n======================");
printf("\nManufacturer : %s",m_udn);
printf("\nProduct : %s",p_udn);
printf("\nInterface : %s",i_udn);
user_in=read_key(1);
clrscr();
if(user_in=='d') {decode_dev(dev_desc,1);}
if(user_in=='c') {decode_config(config_desc,1);}
if(user_in!='9')
{
printf("\n\nPress any key to continue...");
read_key(1);
}
clrscr();
}
while(user_in!='9');
}
void mouse_demo(void)
{
unsigned int user_in;
unsigned long *lp;
unsigned long *data_ptr;
unsigned int *reply_ptr;
unsigned int reply[128];
unsigned int cnt;
unsigned int data_in[8];
unsigned char usb_device_name[128];
unsigned char *udn;
unsigned int ccode;
unsigned int temp;
char message[50];
unsigned int name_length;
unsigned int iManufacturer=0,iProduct=0,iInterface=0;
unsigned int dev_desc[128];
unsigned int ep_desc[128];
unsigned int config_desc[512];
unsigned int str_desc[128];
unsigned int i_desc[128];
char m_udn[50]="NULL";
char p_udn[50]="NULL";
char i_udn[50]="NULL";
int addr=3;
reply_ptr=reply;
reset_usb();
clrscr();
reset_usb();
erase_all();
set_operational();
enable_port();
delay(300);
set_operational();
enable_port();
write_register32(Com32_HcRhPortStatus1,0x00000010);
write_register32(Com32_HcRhPortStatus2,0x00000010);
pwait(5000);
set_address(0,addr);
clrscr();
//Get Device
ccode=get_control(dev_desc,addr,'D');
decode_ccode(ccode,message);
printf("\n\nGetDescriptor... %s",message);
if( (ccode==0) || (ccode>7) )
{
decode_dev(dev_desc,0);
iProduct =(dev_desc[7]&0xFF00)>>8;
iManufacturer =(dev_desc[7]&0x00FF) ;
device_info('W','M',iManufacturer);
device_info('W','P',iProduct);
}
//Get Configuration
ccode=get_control(config_desc,addr,'C');
decode_ccode(ccode,message);
printf("\n\nGetConfiguration... %s",message);
if( (ccode==0) || (ccode>7) )
{
decode_config(config_desc,0);
iInterface =(config_desc[8]&0xFF00)>>8;
device_info('W','I',iInterface);
}
device_info('S',0,0);
//Get String
if(iProduct!=0)
{
ccode=get_control(reply,addr,'S',iProduct);
decode_ccode(ccode,message);
printf("\nGet Product... %s",message);
name_length=( (*reply_ptr&0x00FF)>>1 );
if(name_length>0)
{
printf("\nName length is %d",name_length);
name_length--;
if((ccode==0) && (name_length>0) )
{
cnt=0;
do
{
sprintf(p_udn+cnt,"%c",*(reply_ptr+cnt+1));
cnt++;
}
while(cnt<name_length);
printf("\nProduct : %s",p_udn);
}
}
}
if(iManufacturer!=0)
{
ccode=get_control(reply_ptr,3,'S',iManufacturer);
decode_ccode(ccode,message);
name_length=( (*reply_ptr&0x00FF)>>1 );
printf("\nGet Manufacturer...%s",message);
if(name_length!=0)
{
printf("\nName length is %d",name_length);
name_length--;
if((ccode==0) && (name_length>0) )
{
cnt=0;
do
{
sprintf(m_udn+cnt,"%c",*(reply_ptr+cnt+1));
cnt++;
}
while(cnt<name_length);
printf("\nManufacturer : %s",m_udn);
}
}
}
if(iInterface!=0)
{
ccode=get_control(reply_ptr,3,'S',iInterface);
decode_ccode(ccode,message);
printf("\nGet Interface... %s",message);
name_length=( (*reply_ptr&0x00FF)>>1 );
if(name_length!=0)
{
printf("\nName length is %d",name_length);
name_length--;
if((ccode==0) && (name_length>0) )
{
cnt=0;
do
{
sprintf(i_udn+cnt,"%c",*(reply_ptr+cnt+1));
cnt++;
}
while(cnt<name_length);
printf("\nInterface : %s",i_udn);
}
}
}
printf("\n\nPress any key to continue...");
getch();
set_config(3,1);
play_mouse();
}
void bulk_test(void)
{
unsigned int cnt;
unsigned int user_in;
unsigned int user_data[1024];
unsigned int header_data[4];
unsigned int *u_ptr;
unsigned int *h_ptr;
unsigned int ccode;
unsigned int active;
unsigned int timeout=500;
unsigned int no_of_pac=8; //No of packets of 64bytes to be sent out
//initialize test data
cnt=0;
do
{
user_data[cnt]=cnt;
cnt++;
}
while(cnt<1024);
u_ptr=user_data;
h_ptr=h_ptr;
clrscr();
set_operational();
enable_port();
printf("Philips ISP1161 Bulk Transfer Test\n");
printf("==================================");
make_bulk_ptd(h_ptr,1,64*no_of_pac,0,0);
put_bulk_ptd(h_ptr,(no_of_pac*32)+8,u_ptr);
write_register16(Com16_HcBufferStatus,0x08);
printf("\nPTD dumped into ATL buffer");
cnt=0;
do
{
gotoxy(1,4);
printf("Waiting for PTD to be processed... ");
get_bulk_ptd(h_ptr,4);
ccode=((*h_ptr)&0xF000)>>12;
active=((*h_ptr)&0x0800);
cnt++;
}
while( (active!=0) && (cnt<timeout) );
printf("Done!!!");
printf("\n\nCompletion Code:%X \nActive Bit:%X",ccode,active>>10);
getch();
}
void show_choice(void)
{
unsigned int chip_id;
clrscr();
chip_id=read_register16(Com16_HcChipID);
printf("Philips ISP1161 PCI Mini Test Kit Version 1.02\n");
printf("==============================================");
printf("\n[1] DEMO - Port Monitor");
printf("\n[2] DEMO - USB Mouse");
printf("\n[3] DEMO - Enumeration");
printf("\n[4] Bulk Transfer Test");
printf("\n[5] ATL Buffer View");
printf("\n[6] Erase HC Buffer Memory");
printf("\n[9] Exit");
printf("\n\n\n\nChipID Detected : %4X\n",chip_id);
}
void main(void)
{
unsigned int cnt;
unsigned char function[10][40];
unsigned char status_buffer[60];
unsigned int user_in;
unsigned int chip_id;
clrscr();
_setcursortype(_NOCURSOR);
findPCIdev(0x00068000, &g_ISA_base_address, &g_host_IRQ_num);
set_pci_bridge();
g_1161_command_address = g_ISA_base_address + 2;
g_1161_data_address = g_ISA_base_address;
chip_id=read_register16(Com16_HcChipID);
printf("ChipID Detected : %4X",chip_id);
do
{
write_register16(Com16_HcITLBufferLength,0);
write_register16(Com16_HcATLBufferLength,0x400);
gotoxy(1,1);
show_choice();
user_in=read_key(1);
reset_usb();
if(user_in=='1') {port_monitor();}
if(user_in=='2') {mouse_demo();}
if(user_in=='3') {get_usb();}
if(user_in=='4') {bulk_test();}
if(user_in=='5') {see_buf();}
if(user_in=='6') {erase_all();}
gotoxy(1,20);
}
while(user_in!='9');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -