Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: usbFunctionSetup and usbFunctionWrite in action?

$
0
0
When you download the v-usb code it comes with an example that demonstrates this in a command prompt. I wrote some code using PID. This is the set up.

unsigned  usbFunctionSetup(uchar data[8])
{
   usbRequest_t    *rq = (void *)data;
   usbMsgPtr = reportBuffer;


   if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS)
   {    /* class request type */
      if(rq->bRequest == USBRQ_HID_GET_REPORT)
      {
         if (  rq->wValue.bytes[0] == 2 )
         {//PID Block Load Report
            char error=1;
            if (_FFB_effect_index>4) error =2;
            reportBuffer[0]=2; //report id 2
            reportBuffer[1]=_FFB_effect_index;//effect index
            reportBuffer[2]=error;//1 =  success:2 = full: 3 = error
         }                   
         return USB_NO_MSG;      
      }   
      else if (rq->bRequest == USBRQ_HID_SET_REPORT)
       {
           if (  rq->wValue.bytes[0] == 1 )  _setReport=1;//set effect  Report
         return USB_NO_MSG;
       }
   
   }
    return 0;
}


The Write is proprietary to what I use if for but you just need to analyze the data.
uchar usbFunctionWrite(uchar *data, uchar len)
{
if (data[0]==1 && _setReport ){ _setReport=0; ...}
...
}

Viewing all articles
Browse latest Browse all 4524

Trending Articles