AnsweredAssumed Answered

USB HID writefile ( output report ) only works under some F103xx board, GetLastError is 31

Question asked by sun.shawn on Jan 25, 2015
Latest reply on Jan 27, 2015 by Chinzei.Tsuneo
I have 5 stm32 boards, 3 with F103RBT6 , 2 with F103C8T6.

I build an USB HID firmware  by using USB FS Device Library 4.0, the code is just modified from the custom HID demo in the ST USB device library.

the firmware works okay on all of the boards in regards the HID input report.
But when I tried using Windows API WriteFile() to write the HID output report to the boards, only 3 of the board works:
2 of the F103RBT6 board and 1 of the F103C8T6 board.

For the boards which can't work correctly, the first WriteFile failed with GetLastError 31. the 2nd WriteFile will cause the thread blocked, after a long waiting (30 seconds maybe ) the writeFile failed with GetLastError 995.
In the EP1_OUT_callback() in usb_endp.c I set the PB14 to high at the begining of the handler like this:

void EP1_OUT_Callback(void)
    //read received data ( 64 bytes )
    GPIO_SetBits(GPIOB, GPIO_Pin_14 );
    USB_SIL_Read( EP1_OUT, OutputDataBuffer );
        //deal withe the OUTPUT data
    SetEPRxStatus(ENDP1, EP_RX_VALID);
    GPIO_ResetBits(GPIOB, GPIO_Pin_14 );

 but I can't find this pulse in oscilloscope.  
With those board which works okay, I can see the pulse in the scope. So it seems that the EP1_OUT_Callback is not invoked for some reason.

I have no idea what should I try to find out the root cause.

Any suggestions are appreciated!

Thanks in advance.