Page 1 of 1

usbFunctionRead problem

Posted: Tue Oct 05, 2010 1:22 pm
by lali
I'm using USB_CFG_IMPLEMENT_FN_READ feature,descriptor data stored in flash are decompressed by usbFunctionRead on the fly,but it can't be recognized by host.

code like this:

Code: Select all

uchar buffer[256];
uchar usbFunctionRead(uchar *data, uchar len)
{
   uchar *r = usbMsgPtr;    //compressed data ptr in flash

                if(firstrun) mydepack(r,buffer);     //decompress needs about 5ms execute time
         
   memcpy(data,buffer+pos,len);
                pos+=len;
   return len;
}


If I do not use compression it can do work,like this:

Code: Select all

uchar buffer[256];
uchar usbFunctionRead(uchar *data, uchar len)
{
   uchar *r = usbMsgPtr;    //uncompressed data ptr in flash

                if(firstrun){
                memcpy_P(buffer,r,256);
                _delay_ms(5);              //to ensure it's not some timing problem.
                }

   memcpy(data,buffer+pos,len);
                pos+=len;
   return len;
}


I checked decompress function,stack,can't figure out.Is there some transmit manager limit in V-USB interrupt service ?

Re: usbFunctionRead problem

Posted: Tue Oct 05, 2010 2:26 pm
by _frank26080115
"device not recognized" doesn't seem like a bug that would be caused by a malfunctioning usbFunctionRead, can you describe the problem more?

Re: usbFunctionRead problem

Posted: Tue Oct 05, 2010 3:41 pm
by lali
I'm just follow tutorial from here:http://vusb.wikidot.com/driver-api "Receiving data from the device" method 2.The point is that the latter usbFunctionRead can do work,the first usbFunctionRead can't.

Re: usbFunctionRead problem

Posted: Tue Oct 05, 2010 7:39 pm
by _frank26080115
your 2nd code makes no sense, why is usbMsgPtr the source for memcpy_P?
also a 5ms delay si probably too long for USB stuff

Re: usbFunctionRead problem

Posted: Sun Oct 24, 2010 5:27 am
by lali
I give up.It seems PS3 doesn't like compressed descriptor data :(