Skip to main content
Graduate II
June 15, 2024
Question

USB Device Connection and Disconnection

  • June 15, 2024
  • 2 replies
  • 2464 views

STM32F4 is working in USB Device MSC mode successfully.

I need to detect the USB connection state. I put the HAL_PCD_ConnectCallback function in main.c but on compiling I received warning.

Debug/../USB_DEVICE/Target/usbd_conf.c:307: multiple definition of `HAL_PCD_ConnectCallback';

I see it is weak in HAL_PCB_IRQHandler. Please suggest what I am missing. 

 

 

    This topic has been closed for replies.

    2 replies

    Super User
    June 15, 2024

    Maybe not change the ConnectCallback ...try: 

     

    USBD_Get_USB_Status() -> until : usb_status = USBD_OK;

     

    Nico3Author
    Graduate II
    June 16, 2024

    I just realized.. i can simply use PA9 to detect. 

    Nico3Author
    Graduate II
    June 19, 2024

    STM32F4 is set in USB DEVICE MSC mode.

    I am seeing LED is glowing even when USB is not connected to HOST laptop.  Intensity of LED glowing is low.  Anyway, on connection to HOST laptop, the LED glow at high intensity which makes sense.

    I am not using PA9 for VBUS detection. I set PA9 in reset condition and also rise/fall edge detection with PD but still LED2 is glowing.

    Does USB hardware in STM32 always provide some power to PA9 pin ?

    Nico3_0-1718822248112.png

     

    Super User
    June 16, 2024

    >I received warning

    Read the compiler messages carefully, there must be reference to previous definition.