Help me about USB EHCI !!!
Posted: Sat Apr 09, 2011 9:36 pm
void readdesc(EHCI_DEV *ehci)
{
uint32_t cmd;
DWORD *setup_td,*td0,*td1,*td2,*status_td,*qh;
USB_SETUP_REQUEST usr;
qh=ehci->queue;
setup_td=qh+14;
td0=setup_td+8;
td1=td0+8;
td2=td1+8;
status_td=td2+8;
usr.bmRequestType=0x80;
usr.bRequest=GET_DESCRIPTOR;
usr.wValue=0x100;
usr.wIndex=0;
usr.wLength=18;
memcpy(ehci->buf,&usr,18);
setup_td[0]=GetPhysicalAddress( (DWORD)td0 );
setup_td[1]=GetPhysicalAddress( (DWORD)td0 );
setup_td[2]=(18<<16) | (1<<15) | (3<<10) | (2<<8) | 0x80;
setup_td[3]=GetPhysicalAddress( (DWORD)ehci->buf );
td0[0]=GetPhysicalAddress( (DWORD)td1 );
td0[1]=GetPhysicalAddress( (DWORD)td1 );
td0[2]=(1<<31) | (8<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td0[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5) );
td1[0]=GetPhysicalAddress( (DWORD)td2 );
td1[1]=GetPhysicalAddress( (DWORD)td1 );
td1[2]=(8<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td1[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5+8) );
td2[0]=GetPhysicalAddress( (DWORD)status_td );
td2[1]=GetPhysicalAddress( (DWORD)status_td );
td2[2]=(1<<31) | (6<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td2[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5+8+8) );
status_td[0]=1;
status_td[1]=1;
status_td[2]=(1<<31) | (0<<16) | (1<<15) | (3<<10) | (0<<8) | 0x80;
status_td[3]=0;
qh[0]=GetPhysicalAddress( (DWORD)qh ) | 2;
qh[1]=(8<<16) | (1<<15) | (0<<14) | (2<<12) | (0<<8) | 0;
qh[2]=(1<<30);
qh[3]=0;
qh[4]=GetPhysicalAddress( (DWORD)setup_td );
qh[5]=0;
*ehci->CONFIGFLAG = 1;
*ehci->PERIODICLISTBASE=0;
ehci->status=0;
*ehci->ASYNCLISTADDR = GetPhysicalAddress( (DWORD)qh ) | 2;
*ehci->USBSTS = 0x0f;
cmd = *ehci->USBCMD;
cmd &= 0xfffffffe;
*ehci->USBCMD = cmd | 0x00080021;
delay(200);
// wait for complete
while(ehci->status==0);
dbgout("Already Send");
}
The problem is : It stay in "//wait for complete" , It not generate any Interrupt (if have a interrupt,I can catch it in debugger), Can your tell me what wrong !!! very thanks!!!
{
uint32_t cmd;
DWORD *setup_td,*td0,*td1,*td2,*status_td,*qh;
USB_SETUP_REQUEST usr;
qh=ehci->queue;
setup_td=qh+14;
td0=setup_td+8;
td1=td0+8;
td2=td1+8;
status_td=td2+8;
usr.bmRequestType=0x80;
usr.bRequest=GET_DESCRIPTOR;
usr.wValue=0x100;
usr.wIndex=0;
usr.wLength=18;
memcpy(ehci->buf,&usr,18);
setup_td[0]=GetPhysicalAddress( (DWORD)td0 );
setup_td[1]=GetPhysicalAddress( (DWORD)td0 );
setup_td[2]=(18<<16) | (1<<15) | (3<<10) | (2<<8) | 0x80;
setup_td[3]=GetPhysicalAddress( (DWORD)ehci->buf );
td0[0]=GetPhysicalAddress( (DWORD)td1 );
td0[1]=GetPhysicalAddress( (DWORD)td1 );
td0[2]=(1<<31) | (8<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td0[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5) );
td1[0]=GetPhysicalAddress( (DWORD)td2 );
td1[1]=GetPhysicalAddress( (DWORD)td1 );
td1[2]=(8<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td1[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5+8) );
td2[0]=GetPhysicalAddress( (DWORD)status_td );
td2[1]=GetPhysicalAddress( (DWORD)status_td );
td2[2]=(1<<31) | (6<<16) | (1<<15) | (3<<10) | (1<<8) | 0x80;
td2[3]=GetPhysicalAddress( (DWORD)(ehci->buf+5+8+8) );
status_td[0]=1;
status_td[1]=1;
status_td[2]=(1<<31) | (0<<16) | (1<<15) | (3<<10) | (0<<8) | 0x80;
status_td[3]=0;
qh[0]=GetPhysicalAddress( (DWORD)qh ) | 2;
qh[1]=(8<<16) | (1<<15) | (0<<14) | (2<<12) | (0<<8) | 0;
qh[2]=(1<<30);
qh[3]=0;
qh[4]=GetPhysicalAddress( (DWORD)setup_td );
qh[5]=0;
*ehci->CONFIGFLAG = 1;
*ehci->PERIODICLISTBASE=0;
ehci->status=0;
*ehci->ASYNCLISTADDR = GetPhysicalAddress( (DWORD)qh ) | 2;
*ehci->USBSTS = 0x0f;
cmd = *ehci->USBCMD;
cmd &= 0xfffffffe;
*ehci->USBCMD = cmd | 0x00080021;
delay(200);
// wait for complete
while(ehci->status==0);
dbgout("Already Send");
}
The problem is : It stay in "//wait for complete" , It not generate any Interrupt (if have a interrupt,I can catch it in debugger), Can your tell me what wrong !!! very thanks!!!