Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB keyboard. LED control #59

Open
alekseibutiaev opened this issue May 20, 2023 · 6 comments
Open

USB keyboard. LED control #59

alekseibutiaev opened this issue May 20, 2023 · 6 comments
Assignees
Labels
bug Something isn't working internal bug tracker Issue confirmed and logged into the internal bug tracking system mw Middleware-related issue or pull-request. usb Universal Serial Bus

Comments

@alekseibutiaev
Copy link

alekseibutiaev commented May 20, 2023

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
Copy link
Contributor

TOUNSTM commented May 24, 2023

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 ALABSTM added mw Middleware-related issue or pull-request. usb Universal Serial Bus labels Jul 12, 2023
@ALABSTM
Copy link
Contributor

ALABSTM commented Jul 12, 2023

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
Copy link
Author

alekseibutiaev commented Jul 13, 2023

@alekseibutiaev
Copy link
Author

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

@ALABSTM
Copy link
Contributor

ALABSTM commented Aug 2, 2023

Hi @alekseibutiaev,

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

To summarize:

  • The issue you are pointing out is related to the USBH_HID_SetReport() function.
  • However, the fix you are proposing is to be implemented in the USBH_HID_Process() function and more precisely in the lines of code below:

else
{
/* 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)
{
/* Change state to issue next IN token */
HID_Handle->state = HID_GET_DATA;
}
}
}
break;

  • The fix you are proposing is the following:
-      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
Copy link
Contributor

ALABSTM commented Aug 2, 2023

ST Internal Reference: 158663

@ALABSTM ALABSTM added bug Something isn't working internal bug tracker Issue confirmed and logged into the internal bug tracking system labels Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internal bug tracker Issue confirmed and logged into the internal bug tracking system mw Middleware-related issue or pull-request. usb Universal Serial Bus
Projects
None yet
Development

No branches or pull requests

4 participants