Use the Longan Nano as USB device on host computer

Is there some documentation on How to use the Longan Nano as USB device ?
Is it event possible ?
For example, is it possible to communicate with the HID interface ?

There are some USBFS examples. And you can see the TRM of GD32VF103.The chapter 21 of GD32VF103 UserManual is usbfs.

Thanks, I will take a look.

Does somebody managed to compile a USB device project from this above library repository ?

I’m trying to compile CDC_ACM demo from Demo_Suites github.
But I didn’t manage to compile it. First it ask for adding macro “USE_USB_FS” in usb_conf.h. But second it ask for some code that seems to be specific firmware code that I found in “usb_fs_driver”..

Adding these sources files generate new errors like :

src/drv_usb_core.c: In function 'usb_txfifo_write':
src/drv_usb_core.c:251:20: error: '__packed' undeclared (first use in this function)
  251 |         *fifo = *((__packed uint32_t *)src_buf);
      |                    ^~~~~~~~
src/drv_usb_core.c:251:20: note: each undeclared identifier is reported only once for each function it appears in

The macro __packed seems to be ARM specific no ?


Check the problem I got, here: If you manage in, I’m curious to have the solution.

Today I use a serial to USB adapter (FTDI like module) and it works for my needs. But I would prefer to connect the board with only the USB-C cable.



1 Like

This project works great:

1 Like