I'm developing a firmware on STM32F429 to have a USB composite device composed of a custom device and a CDC port, on the OTG_FS device.
The hw device is connected with a PC; it correctly shows 3 devices: a composite device, a generic USB device, a COM port.
The communication on custom device - EPs 0x81 and 0x02 - is correctly communicating with my program on Windows.
The problem is the CDC port (virtual serial port). It creates 3 EPs:
- 0x83 INTR for CDC command channel
- 0x82 BULK IN 64 bytes
- 0x01 BULK OUT 64 bytes
I open a Putty terminal on host: by Wireshark session I see the descriptors and some CONTRL packets; they are correct so I guess that the EP0 is correct.
Then I see the URB_BULK IN and URB_INTERRUPT IN requests to wait data.
If I press a key on terminal I correctly receive a BULK OUT packet with 1 byte. So far the receving procedure echoes the same byte to PC. So I prepare a transmission of 1 byte and when the IEP TXFE arrives the PCD_WriteEmptyTxFifo() is called, retrieve the EP data and send the buffer (1 byte) by USB_WritePacket() function.
I breakpointed the writes on FIFO register and here the buffer is ok and the DIEPTSIZ2 = 0x00080001.
Here is the problem: pushing the data (a byte) into the EP FIFO register causes the PC receives a BULK_IN packet composed with a 7 bytes content (??). The received data buffer contains useless bytes.
What I expect is a single byte to the host (the same the terminal sent = key code)!
Why the PC receives a different number of bytes??
-- ADDED
I tried to change the EP numbers:
CUSTOM device = 0x83, 0x01
CDC device = CMD 0x82, 0x81, 0x02
With this configuration the serial port is ok, the custom device is detected as USB device, but it not communicating and no IRQ are fired.