STMicroelectronics / STM32CubeF1

STM32Cube MCU Full Package for the STM32F1 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
507 stars 170 forks source link

USB keyboard. LED control #59

Open alekseibutiaev opened 1 year ago

alekseibutiaev commented 1 year ago

Custom board and with MCU STM32F10[5-7] the function USBH_HID_SetReport does not works correctly.

How To Reproduce

  1. Indicate the global behavior of your application project. works with USB keyboard write led status but does not changed.. but changed after press some keys

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...). module MW

  3. The use case that generates the problem.

  4. How we can reproduce the problem. write status of led by function USBH_HID_SetReport

Additional context i have solution

butiaev@butiaev-HP-Notebook:~/STM32Cube/STM32CubeF1$ git diff master
diff --git a/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c b/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
index be9b308..2f7c360 100644
--- a/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
+++ b/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
@@ -457,19 +457,17 @@ static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost)
 #endif
         }
       }
-      else
+      /* IN Endpoint Stalled */
+      else if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_STALL)
       {
-        /* IN Endpoint Stalled */
-        if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_STALL)
-        {
-          /* Issue Clear Feature on interrupt IN endpoint */
-          if (USBH_ClrFeature(phost, HID_Handle->ep_addr) == USBH_OK)
-          {
+        /* Issue Clear Feature on interrupt IN endpoint */
+        if (USBH_ClrFeature(phost, HID_Handle->ep_addr) == USBH_OK) {
             /* Change state to issue next IN token */
             HID_Handle->state = HID_GET_DATA;
           }
         }
-      }
+      else if(phost->RequestState == CMD_WAIT)
+        USBH_CtlReq(phost, 0, 0);
       break;

     default:
butiaev@butiaev-HP-Notebook:~/STM32Cube/STM32CubeF1$

My project is firmfare https://github.com/alekseibutiaev/experience/tree/master/zxkeyboard & hardware https://github.com/alekseibutiaev/electronics/tree/master/ZX_Keyboard

TOUNSTM commented 1 year ago

Hello @alekseibutiaev,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

ALABSTM commented 1 year ago

Hi @alekseibutiaev,

Thank you for this proposal. May I ask where is defined the CMD_WAIT macro you used in your code snippet above? Thanks.

In the meanwhile, please note that STM32CubeF1 firmware still integrates version 3.3.3 of the USB Host library, while version 3.5.1 has been published here since a couple of months. Would you mind giving it a try a see if the issue still persists?

The newer version is backward compatible and you can easily integrate it into your application manually. Please keep us informed.

With regards,

alekseibutiaev commented 1 year ago

i found it in this file https://github.com/STMicroelectronics/STM32CubeF1/tree/master/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:378

alekseibutiaev commented 1 year ago

just only try version 3.5.1 --- same problem, same solution

ALABSTM commented 1 year ago

Hi @alekseibutiaev,

Thank you for your reply. Your report will be forwarded to our development teams for further analysis.

To summarize:

https://github.com/STMicroelectronics/STM32CubeF1/blob/bdec2f6b0658b5725b41c96cb1f066c362acc4d0/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c#L460-L473

-      else
-       {
        /* IN Endpoint Stalled */
-        if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_STALL)
+      else if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_STALL)
        {
          /* Issue Clear Feature on interrupt IN endpoint */
          if (USBH_ClrFeature(phost, HID_Handle->ep_addr) == USBH_OK)
          {
             /* Change state to issue next IN token */
             HID_Handle->state = HID_GET_DATA;
           }
         }
-      }
+      else if (phost->RequestState == CMD_WAIT)
+      {
+        USBH_CtlReq(phost, 0, 0);
+      }
       break;

With regards,

ALABSTM commented 1 year ago

ST Internal Reference: 158663