cancel
Showing results for 
Search instead for 
Did you mean: 

Caps lock led turn on/off

muhammaduzairafzal45
Associate III
Posted on August 22, 2014 at 08:53

I want to turn on/off keyboard led using STM32F4 Discovery HID example.. Keys are working fine.I have problem with output Set_report. Led is not turning on/off although it seems i am sending correct request.I am sending following 1 byte control output report each time a key is pressed to turn on caps lock led as follows:

USBH_Set_Report(&USB_OTG_Core_dev , &USB_Host,0x00,0x02,1,(uint8_t *)0x02);

USBH_Status USBH_Set_Report (USB_OTG_CORE_HANDLE *pdev, 

                                 USBH_HOST *phost,

                                    uint8_t reportType,

                                    uint8_t reportId,

                                    uint8_t reportLen,

                                    uint8_t* reportBuff)

{

  

  phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_INTERFACE |\

    USB_REQ_TYPE_CLASS;

  

  

  phost->Control.setup.b.bRequest = USB_HID_SET_REPORT;

  phost->Control.setup.b.wValue.w = (reportType << 8 ) | reportId;

  

  phost->Control.setup.b.wIndex.w = 0;

  phost->Control.setup.b.wLength.w = reportLen;

  

  return USBH_CtlReq(pdev, phost, reportBuff , reportLen );

}

can anyone tell me,what i am doing wrong here? thanks.

#keyboard #hid #usb
7 REPLIES 7
faddistr
Associate II
Posted on August 27, 2014 at 19:34

I have same issue. Have you fix it? Version of library isV2.1.0

u8 c=3;
res=USBH_Set_Report(&USB_OTG_Host_Hnd,&USB_Host,0x00,0x00,0x01,&c);
//res allwaysUSBH_BUSY

faddistr
Associate II
Posted on August 27, 2014 at 19:37

faddistr
Associate II
Posted on August 28, 2014 at 13:58

I fix my request:  USBH_Set_Report(pdev,phost,0x02,0x00,0x01,&c); But result strange - the keyboard begin sending packets with 0 and caps lock turns on regardless of �?.

faddistr
Associate II
Posted on August 28, 2014 at 16:16

With software usb sniffer i found that computer sends such requests several(6) times. So i just sent several requests in main cycle and all works fine. ^_^ After each request it must be processed with USBH_Process. 

erisson
Associate II

You need wait for USBH_OK

[code]

u8 c=3;

USBH_StatusTypeDef res = USBH_BUSY;

do

{

res=USBH_Set_Report(&USB_OTG_Host_Hnd,&USB_Host,0x02,0x00,0x01,&c);

}

while(res != USBH_OK);

[/code]

can you share your code

Thread is from 4+ years ago, it is quite likely the respondent will not get email alerts or currently monitor the forum.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..