Skip to content

USB HCD speed definitions #81

Closed
Closed
@carlo-dev-git

Description

@carlo-dev-git

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghalHAL-LL driver-related issue or pull-request.internal bug trackerIssue confirmed and logged into the internal bug tracking systemusbUniversal Serial Bus

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions