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 HCD speed definitions #81

Open
carlo-dev-git opened this issue Jan 9, 2025 · 0 comments
Open

USB HCD speed definitions #81

carlo-dev-git opened this issue Jan 9, 2025 · 0 comments
Assignees
Labels
bug Something isn't working hal HAL-LL driver-related issue or pull-request. usb Universal Serial Bus

Comments

@carlo-dev-git
Copy link

In usbh_conf.c sample code the funtion USBH_LL_GetSpeed()

USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
{
  USBH_SpeedTypeDef speed = USBH_SPEED_FULL;

  switch (HAL_HCD_GetCurrentSpeed(phost->pData))
  {
  case 0:   //// HCD_SPEED_HIGH (ok)
    speed = USBH_SPEED_HIGH;
    break;
  case 1:   //// HCD_SPEED_FULL (duplicated)
    speed = USBH_SPEED_FULL;
    break;
  case 2:   //// HCD_SPEED_LOW (duplicated)
    speed = USBH_SPEED_LOW;
    break;
  default:
    speed = USBH_SPEED_FULL;
    break;
  }
  return  speed;
}

calls HAL_HCD_GetCurrentSpeed() from stm32h7xx_ll_usb.c

/**
  * @brief  Return Host Core speed
  * @param  USBx  Selected device
  * @retval speed : Host speed
  *          This parameter can be one of these values:
  *            @arg HCD_SPEED_HIGH: High speed mode
  *            @arg HCD_SPEED_FULL: Full speed mode
  *            @arg HCD_SPEED_LOW: Low speed mode
  */
uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef const *USBx)
{
  uint32_t USBx_BASE = (uint32_t)USBx;
  __IO uint32_t hprt0 = 0U;

  hprt0 = USBx_HPRT0;
  return ((hprt0 & USB_OTG_HPRT_PSPD) >> 17);
}

From the documentation this function is expected to return one of the following values defined in file stm32h7xx_hal_hcd.h:

/** @defgroup HCD_Speed HCD Speed
  * @{
  */
#define HCD_SPEED_HIGH               USBH_HS_SPEED
#define HCD_SPEED_FULL               USBH_FSLS_SPEED // duplicated ???
#define HCD_SPEED_LOW                USBH_FSLS_SPEED // duplicated ???

but I think this is an error.

USB_GetHostSpeed() should return a constant taken from stm32h7xx_ll_usb.h

/** @defgroup USB_LL Device Speed
  * @{
  */
#define USBD_HS_SPEED                          0U
#define USBD_HSINFS_SPEED                      1U
#define USBH_HS_SPEED                          0U
#define USBD_FS_SPEED                          2U
#define USBH_FSLS_SPEED                        1U

and HAL_HCD_GetCurrentSpeed() should be documented for returning a constant taken from stm32h7xx_hal_hcd.h (se above).

--

From RM0043 par.57.14.28

Bits 18:17 PSPD[1:0]: Port speed
Indicates the speed of the device attached to this port.
01: Full speed
10: Low speed
11: Reserved
00: High speed

@ALABSTM ALABSTM self-assigned this Jan 10, 2025
@ALABSTM ALABSTM added bug Something isn't working usb Universal Serial Bus labels Jan 10, 2025
@ALABSTM ALABSTM added the hal HAL-LL driver-related issue or pull-request. label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hal HAL-LL driver-related issue or pull-request. usb Universal Serial Bus
Projects
Development

No branches or pull requests

2 participants