Skip to main content
Visitor II
September 20, 2024
Question

Differentiation between USB_OTG_HS and USB_OTG_FS in STM32F4xx

  • September 20, 2024
  • 2 replies
  • 1775 views

Hi,

I am working on USB CDC on STM32F469NI. For USB_OTG_FS and USB_OTG_HS, the auto generated USB handles are

 
USBD_HandleTypeDef hUsbDeviceFS;
USBD_HandleTypeDef hUsbDeviceHS;

Is there any macro in HAL or while auto generation, that I can get to know which of the USB_OTG_xx is being used, so that I can extern the proper variable into my firmware?

Thanks,

Himanshu

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    September 20, 2024

    Hi @nagahimanshu7 

    You can define your own macros, PCD Speed is defined in HAL and you should select one of these predefined constants:
    #define PCD_SPEED_HIGH USBD_HS_SPEED
    #define PCD_SPEED_HIGH_IN_FULL USBD_HSINFS_SPEED
    #define PCD_SPEED_FULL USBD_FS_SPEED

    Using CubeMX you can select which instance to be used.

    Super User
    September 20, 2024

    There isn't a macro, but the choice is based on the peripheral you've configured in CubeMX. It shouldn't be a mystery. Similar to if you used I2C1 or I2C2.