# stm32 usb feature report sending

I am working with USB HID in stm32f072. On Get_Report Request I have to send data to Host PC through Control Transfer Endpoint. I am trying to do so. But it is sending always some wrong data. If I want to elaborate the problem, that is

 case HID_REQ_GET_REPORT:

if(req->wValue==PID_POOL_BLOCK_REPORT){

buf[0] = 0x07;
buf[1] = 0xFF;
buf[2] = 0xFF,
buf[3] = 0x0A;
buf[4] = 0x02;

if(USBD_LL_FlushEP (pdev, 0x00)==USBD_OK){

USBD_CtlSendData (pdev,
buf,
5);

}
}


But the data send through is actually "0xF6 0x3A 0x82 0x28 0x45". I have no clue what is happening inside. I have benn trying it with flushing the endpoint too. But it seems no working. What to do really? Any clue please. Thank you.

• Is buf a local variable? – CL. Dec 13 '15 at 15:05
• yes, local. But does it matter? What is your point? – istiaq2379 Dec 13 '15 at 16:13

USB works asynchronously. USBD_CtlSendData just saves a pointer to the buffer; the data gets actually read from memory and transmitted when the host asks for it.