STM32F3 Composite USB (CDC with flow control + Bulk)

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
mobyfab
Posts: 452
Joined: Sat Nov 19, 2011 6:47 pm
Location: Versailles, France
Has thanked: 12 times
Been thanked: 18 times

STM32F3 Composite USB (CDC with flow control + Bulk)

Postby mobyfab » Sat Dec 28, 2013 6:39 pm

Hey,

I made a quick test using the IAD USB class and it seems to work fine. (not finished implementing the Bulk IF)

It's running a CDC interface and bulk interface.

The CDC interface can handle flow control commands (RTS/DTR)
I needed that to emulate some legacy devices while still having access to a custom (bulk) USB interface.

You need special drivers on Windows as the ones by ST won't work. They are not designed for IAD, just normal CDC.
Works out of the box on Linux. (/dev/ttyACM0)

Code is here:
https://github.com/mobyfab/ChibiOS-Exam ... F3-USB-CDC

User avatar
Giovanni
Site Admin
Posts: 13086
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 759 times
Been thanked: 637 times
Contact:

Re: STM32F3 Composite USB (CDC with flow control + Bulk)

Postby Giovanni » Sat Dec 28, 2013 8:07 pm

Hi,

What the IAD class does?

Giovanni

mobyfab
Posts: 452
Joined: Sat Nov 19, 2011 6:47 pm
Location: Versailles, France
Has thanked: 12 times
Been thanked: 18 times

Re: STM32F3 Composite USB (CDC with flow control + Bulk)

Postby mobyfab » Sat Dec 28, 2013 8:25 pm

It allows to use multiple drivers (device functions) with one USB device.

In my case I have a CDC driver and a Bulk USB (WinUSB) driver, but we could have more as long as there are enough endpoints.
You just need to specify which interface the driver needs to use in the inf files for windows, it's automatic on linux.

The end result is like having multiple devices into one.
I believe having 3 CDC is possible on a F3. (uses 6 endpoints out of 7, 2 per interface)

http://www.usb.org/developers/whitepape ... de_r10.pdf

Code: Select all

Information for device ChibiOS/RT Device (VID=0x0483 PID=0xABCD):

Connection Information:
------------------------------
Connection status: Device connected
Device actual bus speed: Full
Device is hub: No
Device adress: 0x0002
Current configuration value: 0x01
Number of open pipes: 5

Device Descriptor:
------------------------------
0x12   bLength
0x01   bDescriptorType
0x0200   bcdUSB
0xEF   bDeviceClass   (Miscellaneous device)
0x02   bDeviceSubClass   
0x01   bDeviceProtocol   
0x40   bMaxPacketSize0   (64 Bytes)
0x0483   idVendor
0xABCD   idProduct
0x0200   bcdDevice
0x01   iManufacturer   "STMicroelectronics"
0x05   iProduct   "ChibiOS/RT Device"
0x03   iSerialNumber   "270"
0x01   bNumConfigurations

Configuration Descriptor:
------------------------------
0x09   bLength
0x02   bDescriptorType
0x006A   wTotalLength
0x03   bNumInterfaces
0x01   bConfigurationValue
0x05   iConfiguration   "ChibiOS/RT Device"
0xC0   bmAttributes   (Self-powered Device)
0x32   bMaxPower   (100 mA)

Interface Association Descriptor:
------------------------------
0x08   bLength
0x0B   bDescriptorType
0x00   bFirstInterface
0x02   bInterfaceCount
0x02   bFunctionClass   (Communication Device Class)
0x00   bFunctionSubClass   
0x00   bFunctionProtocol   
0x02   iFunction   "ChibiOS/RT Virtual COM Port"

Interface Descriptor:
------------------------------
0x09   bLength
0x04   bDescriptorType
0x00   bInterfaceNumber
0x00   bAlternateSetting
0x01   bNumEndPoints
0x02   bInterfaceClass   (Communication Device Class)
0x02   bInterfaceSubClass   (Abstract Control Model)
0x01   bInterfaceProtocol   (ITU-T V.250)
0x02   iInterface   "ChibiOS/RT Virtual COM Port"

CDC Header Functional Descriptor:
------------------------------
0x05   bFunctionalLength
0x24   bDescriptorType
0x00   bDescriptorSubtype
0x0110   bcdCDC

CDC Call Management Functional Descriptor:
------------------------------
0x05   bFunctionalLength
0x24   bDescriptorType
0x01   bDescriptorSubtype
0x00   bmCapabilities
0x01   bDataInterface

CDC Abstract Control Management Functional Descriptor:
------------------------------
0x04   bFunctionalLength
0x24   bDescriptorType
0x02   bDescriptorSubtype
0x02   bmCapabilities

CDC Union Functional Descriptor:
------------------------------
0x05   bFunctionalLength
0x24   bDescriptorType
0x06   bDescriptorSubtype
0x00   bControlInterface
0x01   bSubordinateInterface(0)

Endpoint Descriptor:
------------------------------
0x07   bLength
0x05   bDescriptorType
0x82   bEndpointAddress   (IN Endpoint)
0x03   bmAttributes   (Transfer: Interrupt / Synch: None / Usage: Data)
0x0008   wMaxPacketSize   (8 Bytes)
0xFF   bInterval

Interface Descriptor:
------------------------------
0x09   bLength
0x04   bDescriptorType
0x01   bInterfaceNumber
0x00   bAlternateSetting
0x02   bNumEndPoints
0x0A   bInterfaceClass   (CDC Data)
0x00   bInterfaceSubClass   
0x00   bInterfaceProtocol   
0x02   iInterface   "ChibiOS/RT Virtual COM Port"

Endpoint Descriptor:
------------------------------
0x07   bLength
0x05   bDescriptorType
0x01   bEndpointAddress   (OUT Endpoint)
0x02   bmAttributes   (Transfer: Bulk / Synch: None / Usage: Data)
0x0040   wMaxPacketSize   (64 Bytes)
0x00   bInterval

Endpoint Descriptor:
------------------------------
0x07   bLength
0x05   bDescriptorType
0x81   bEndpointAddress   (IN Endpoint)
0x02   bmAttributes   (Transfer: Bulk / Synch: None / Usage: Data)
0x0040   wMaxPacketSize   (64 Bytes)
0x00   bInterval

Interface Association Descriptor:
------------------------------
0x08   bLength
0x0B   bDescriptorType
0x02   bFirstInterface
0x01   bInterfaceCount
0xFF   bFunctionClass   (Vendor specific)
0x00   bFunctionSubClass   
0x00   bFunctionProtocol   
0x04   iFunction   "ChibiOS/RT Bulk Interface"

Interface Descriptor:
------------------------------
0x09   bLength
0x04   bDescriptorType
0x02   bInterfaceNumber
0x00   bAlternateSetting
0x02   bNumEndPoints
0xFF   bInterfaceClass   (Vendor specific)
0x00   bInterfaceSubClass   
0x00   bInterfaceProtocol   
0x04   iInterface   "ChibiOS/RT Bulk Interface"

Endpoint Descriptor:
------------------------------
0x07   bLength
0x05   bDescriptorType
0x03   bEndpointAddress   (OUT Endpoint)
0x02   bmAttributes   (Transfer: Bulk / Synch: None / Usage: Data)
0x0040   wMaxPacketSize   (64 Bytes)
0x00   bInterval

Endpoint Descriptor:
------------------------------
0x07   bLength
0x05   bDescriptorType
0x83   bEndpointAddress   (IN Endpoint)
0x02   bmAttributes   (Transfer: Bulk / Synch: None / Usage: Data)
0x0040   wMaxPacketSize   (64 Bytes)
0x00   bInterval

String Descriptor Table
--------------------------------
Index  LANGID  String
0x00   0x0000  0x0409
0x01   0x0409  "STMicroelectronics"
0x02   0x0409  "ChibiOS/RT Virtual COM Port"
0x03   0x0409  "270"
0x04   0x0409  "ChibiOS/RT Bulk Interface"
0x05   0x0409  "ChibiOS/RT Device"

------------------------------

Connection path for device:
Contrôleur hôte PCI vers USB standard universel
Root Hub
ChibiOS/RT Device (VID=0x0483 PID=0xABCD)

Brought to you by TDD v1.82.0, Aug 20 2013, 17:17:20

mobyfab
Posts: 452
Joined: Sat Nov 19, 2011 6:47 pm
Location: Versailles, France
Has thanked: 12 times
Been thanked: 18 times

Re: STM32F3 Composite USB (CDC with flow control + Bulk)

Postby mobyfab » Sun Dec 29, 2013 11:11 pm

Bulk interface is working as well now.

You can use this to test it: http://winusbnet.codeplex.com/wikipage? ... Test%20App
guid is 9f543223-cede-4fa3-b376-a25ce9a30e74 (you can find it in the bulk driver .inf file)

It will reply with the value you send it, multiplied by 2.

I might make a driver similar to the serial usb.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 1 guest