Transferring data from STM32F407 to libusb through USB CDC class

6.7k views Asked by At

I'm working on the project in which I should transfer data from a microcontroller to a PC with the USB protocol. I am working with the STM32F407 microcontroller for transferring data to a PC with the USB Protocol.

I am using libsub for transferring data in Windows 7.

I have written a program with STM32cubeMX and configured the USB device class library. I can transfer data with the CDC virtual COM port, but I want to transfer data with libusb. I install the libusb driver for my device, but when I send data from the microcontroller to PC nothing is send!!!!

What is my problem? How can I send data from a USB device to a PC with USB and high speed?

Enter image description here

1

There are 1 answers

2
ralf htp On

In USB protocol the host device initiates any transfer, for example a bulk transfer. i assume that the ST32f407 is the device and the pc ist the host so the ST32 can not initiate any USB transfer. The communication over virtual COM works because it the virtual COM is like a tunnel, but this tunnel was also initated and is (logically) kept alive by the host (pc)

Bulk transactions

Like all other USB transfers, the host always initiates a bulk transfer. The communication takes place between the host and the target endpoint. The USB protocol does not enforce any format on the data sent in a bulk transaction.

source: https://msdn.microsoft.com/de-de/library/windows/hardware/ff539199%28v=vs.85%29.aspx

All data transfers are initiated and controlled by the host and USB peripherals are slaves responding to host commands

source: https://www.midi.org/articles/basic-of-usb

in usb even interrupts have to wait until the host polls:

Any one who has had experience of interrupt requests on microcontrollers will know that interrupts are device generated. However under USB if a device requires the attention of the host, it must wait until the host polls it before it can report that it needs urgent attention!

source: http://www.beyondlogic.org/usbnutshell/usb4.shtml#Interrupt

See http://www.beyondlogic.org/usbnutshell/usb4.shtml#Bulk for bulk transfers

So you can send data from the device to the host but the host has to establish the communication meaning has 'ask' for the data. This is done via the bulk IN endpoint that is used to read data from the device to the host