AnsweredAssumed Answered

USB HID - Get Feature Report Asynchronous

Question asked by dev on Dec 2, 2014
Latest reply on Dec 15, 2014 by dev
Hello guys,

I am working with the new CubeMX lib on a STM32F4 platform and altough I worked a lot with the ST USB HID implementation/stack it still gives me headaches. I am still new to USB.
I am developing an HID device which has custom Feature Reports which indicate the device peripherie status or reporting configuration results etc. Because some of this Feature Report requests need interaction with peripherie, and this peripherie could be in use while the interrup occurs, I can not answer these requests directly in the USB interrupt. I wanted to answer the requests on the control endpoint in the main loop, but my test application on the usb host side does not receive any data.

Answering the GetFeatureReport in the interrupt works perfectly well, but answering it delayed in the main loop does not. I guess its because the interrupt cleans up the endpoint at the end of the interrupt, but how can i prevent this, what is the correct why to do this? 

http://pastebin.com/rfwr4wFu

       
  1.    
    uint8_t reportBuffer[4] = {0};
       
  2.    
  3.    
    uint8_t asyncReport = 0;
       
  4.    
  5.    
     
       
  6.    
  7.    
    void MainLoop_Tick(){
       
  8.    
  9.    
            if(asyncReport != 0){
       
  10.    
  11.    
                    if(asyncReport == STATUS_REPORT_ID){
       
  12.    
  13.    
                            //DO SENSOR STUFF
       
  14.    
  15.    
                            reportBuffer[0] = STATUS_REPORT_ID;
       
  16.    
  17.    
                            USBD_CtlSendData (&USB_DEVICE, reportBuffer, 4);
       
  18.    
  19.    
                    }
       
  20.    
  21.    
            }
       
  22.    
  23.    
    }
       
  24.    
  25.    
     
       
  26.    
  27.    
    void USBD_HID_ProcessGetFeatureEvent(uint8_t report_id){
       
  28.    
  29.    
            switch(report_id){
       
  30.    
  31.    
                    case STATUS_REPORT_ID:
       
  32.    
  33.    
                            asyncReport = STATUS_REPORT_ID;
       
  34.    
  35.    
                            break;
       
  36.    
  37.    
                    default:
       
  38.    
  39.    
                            reportBuffer[0] = report_id;
       
  40.    
  41.    
                            USBD_CtlSendData (&USB_DEVICE, reportBuffer, 4);
       
  42.    
  43.    
                            break;
       
  44.    
  45.    
            }
       
  46.    
  47.    
    }
       

Outcomes