two transactions to send the report?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

two transactions to send the report?

Post by ulao » Fri Mar 05, 2010 1:55 am

Basically I have 9 packets I need to send and maybe more in the future. I can only send 8 with 1.1 spec, so I need to to a multi endpoint, or hoping for a better method. Any project examples out there? Is there something that I could do with the control endpoint?

I see how to set up the mutli in endpoints but dont see how I send more then one?I guess I would have expected a usbSetInterrupt( endPoint, report, size ); but ts not done that way.

er wait, just saw usbSetInterrupt3 , so Do I need do so something like

usbSetInterrupt(reportBuffer1, curGamepad->report_size);
usbSetInterrupt3(reportBuffer2, curGamepad->report_size);

? going to try this.

ok didnt work..

what iuf I did somthign like this

usbSetInterrupt((void *)&reportBuffer + 0, curGamepad->report_size);
while (!usbInterruptIsReady()) usbPoll();
usbSetInterrupt((void *)&reportBuffer + 8, curGamepad->report_size);

The hid still only sees the first 8 ?

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: two transactions to send the report?

Post by ulao » Sat Mar 06, 2010 12:35 am

ok got it.

while (!usbInterruptIsReady()) usbPoll(); // need to wait
usbSetInterrupt((void *)&reportBuffer + 0, curGamepad->report_size);
while (!usbInterruptIsReady()) usbPoll();//need to wait
usbSetInterrupt((void *)&reportBuffer + 8, curGamepad->report_size);

no need for any fancy endpoints.

CRP

Re: two transactions to send the report?

Post by CRP » Fri Jan 28, 2011 1:35 am

Hi, could you please explain what you are doing?

I am in a similar situation, in fact I am trying to emulate a PS3 controller. The reportDescriptor is rather complex (for me at least), but I think that the first 9 bytes contain controller data: report id, 19 buttons, 13 bits of unknown data (padding? if so why 13 and not just 5?), then 4 bytes for 4 axes.
There's also a lot of other stuff after this (about 282 bytes!?!) but no idea what that is (maybe accelerometer?)

Anyway, I have these 9 bytes to send. Currently I have the following code:


Code: Select all

   
   for(;;){                // main event loop
      wdt_reset();
      usbPoll();
      if(usbInterruptIsReady()){
      // called after every poll of the interrupt endpoint
         
      get_data();
      make_sense();
      usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
      }
   }



would I just repeat everything inside the loop twice as per your example?

CRP

Re: two transactions to send the report?

Post by CRP » Sat Jan 29, 2011 12:58 am

ok, I found out by myself.
In my case, where I have a 10 byte descriptor, I use the following code:

Code: Select all

   for(;;){                // main event loop
      while (!usbInterruptIsReady()){
         wdt_reset();
         usbPoll();
      }
      get_data();
      make_sense();
      usbSetInterrupt((void *)&reportBuffer + 0, 8);
      while (!usbInterruptIsReady()){
         wdt_reset();
         usbPoll();
      }
      usbSetInterrupt((void *)&reportBuffer + 8, 2);
   }


If the last piece of the buffer is of length 8, another Interrupt has to be set with length zero, in order to signal end of buffer.
Also, it is important that the buffer length corresponds to the length implied by the hid descriptor. Initially I had a 19 byte descriptor, but would only use the first 10 bytes. This did not work until I commented out the unused descriptor portion.

Post Reply