Skip to main content
HBahr
Associate
January 25, 2019
Solved

i tried to send a message to my pc using USB CDC . i get a error : error: 'hUsbDeviceFS' undeclared (first use in this function) but the 'hUsbDeviceFS' is defined in the usb_devise.c

  • January 25, 2019
  • 3 replies
  • 1897 views

..

This topic has been closed for replies.
Best answer by HBahr

hi,

i just found a solution. i was using the STM32L496G-DICO.i was trying to preform the example project in the MOOC training provided by st "STM32L4 hands-on-sessions".

"https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/stm32cubemx-and-cubeHhal-basics.html"

you can see vedio number 35 if you want to know exactly what i was doing.

the problem was that  a error accured when compiling "the usb handler hUsbDeviceFS is not defined"  . But when i reviewed the project structures it was defined in one of the includes….

i just Added hUsbDeviceFS as a global variable in the main ( I added this line : USBD_HandleTypeDef hUsbDeviceFS; ) and every think worked fine.

Kind Regards,

Hamza

3 replies

ST Technical Moderator
January 28, 2019

Hello,

Could you please give us more details on your environment and which device are you using? Are you usig CubeMX or example from Cube firmware package and which versions?

Maybe, you should review the structure of the projects provided in the Templates of CUbe package for supported tool chains, and map them to yours.

Kind Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
HBahr
HBahrAuthorBest answer
Associate
January 28, 2019

hi,

i just found a solution. i was using the STM32L496G-DICO.i was trying to preform the example project in the MOOC training provided by st "STM32L4 hands-on-sessions".

"https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/stm32cubemx-and-cubeHhal-basics.html"

you can see vedio number 35 if you want to know exactly what i was doing.

the problem was that  a error accured when compiling "the usb handler hUsbDeviceFS is not defined"  . But when i reviewed the project structures it was defined in one of the includes….

i just Added hUsbDeviceFS as a global variable in the main ( I added this line : USBD_HandleTypeDef hUsbDeviceFS; ) and every think worked fine.

Kind Regards,

Hamza

SAvra.1
Visitor II
June 9, 2020

I think this should be more correct. Since it's already declared in the usb_device.c

 extrern USBD_HandleTypeDef hUsbDeviceFS;