cancel
Showing results for 
Search instead for 
Did you mean: 

USB OTG/Host driver for a custom/vendor-specifc USB device

marceldanilo
Associate II
Posted on May 21, 2012 at 15:16

Hi everyone!

I'm new to the STM32 world, so I'm looking for some concrete example that USB OTG application with a STM32 uC.

Did someone have sucess with a similar project that can be shared here?

If however you can advise me to guide me, I would be thankful.

15 REPLIES 15
alok472
Associate II
Posted on May 23, 2012 at 06:23

Start from the USB library example. UM1021.

marceldanilo
Associate II
Posted on June 23, 2012 at 00:14

According to what i have read, just MSD and HID device drivers are developed. Does it mean that I still do can connect just MSD/HID devices to the STM32 USB Host?

There is someway to adapt the HID driver to a vendor-specific device? Is it so hard? I have no ideia. 

Posted on June 23, 2012 at 01:36

Doesn't it all predicate on your ability and knowledge about how to even interact with this custom device.

If you have no experience with programming USB devices, their device drivers, and the like, then yes you're going to have a bit of a learning curve ahead of you.

Start by reviewing the sources supplied in the firmware libraries and see if it makes any sense within your current understanding of USB devices, and functionality.

http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32_f105-07_f2_f4_usb-host-device_lib.zip

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
marceldanilo
Associate II
Posted on June 23, 2012 at 16:05

Thank you very much clive1;

But as a shortcut, if anyone has already managed to connect a usb device vendor-specific to the STM32, and could share here would be easier for me to find my path.

Someone may have achieved.

Posted on June 23, 2012 at 18:25

Do you have a specific type or class, make/model in mind? Might be helpful to cultivate some interest.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tsuneo
Senior
Posted on June 23, 2012 at 19:14

In this post to Keil forum, I wrote on the outline of class implementation for USB host using STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0

http://www.keil.com/forum/20569/

I examined v2.1.0 source, and I found just slight difference from above summary.

If you open the spec of your target device, we can discuss on the implementation details, here.

1) How many interfaces does the device have - single or composite device?

2) How many endpoints and what is the transfer type/direction of each endpoint?

3) Does it use vendor requests?

Tsuneo

marceldanilo
Associate II
Posted on June 23, 2012 at 20:28

Actually, what Iwant to read as a USB device is other microcontroller Arm, a AT91SAM7S256. This ucontroller contains a USB 2.0 Full Speed machine. I need to use the USB because it is the unique physical access I have to it. It is embedded in a Lego NXT controller;

A similar work I have found is this: 

http://john.toebes.com/projects/first/46-samantha.html

;

This module uses PIC32 (USB OTG) to connect to the NXT. Based on this work, could I adapt the used driver to the STM32?

Through the USB Tracer I have read the information table below;

Tsuneno, I am reading your post on Keil forum;

Thanks clive1/chinzei.tsuneo!!

Parameter

Value

Hardware ID

USB\VID_0694&PID_0002&REV_0000

Setup Class

visaUsbDevice

Class GUID

{a3330edf-239d-4206-833b-1d58952613d5}

PDO Name

\Device\USBPDO-9

Service Name

WinUsb

</colgroup>

Parameter

Value

Connection Information

ConnectionIndex

0x4

CurrentConfigurationValue

0x1

Speed

0x1 (UsbFullSpeed)

DeviceIsHub

FALSE

DeviceAddress

0x3

NumberOfOpenPipes

0x2

ConnectionStatus

DeviceConnected

Pipe #0

Endpoint Descriptor

bLength

0x7

bEndpointAddress

0x1 [OUT]

bmAttributes

0x2 (USB_ENDPOINT_TYPE_BULK)

wMaxPacketSize

0x40

bInterval

0x0

Pipe #1

Endpoint Descriptor

bLength

0x7

bEndpointAddress

0x82 [IN]

bmAttributes

0x2 (USB_ENDPOINT_TYPE_BULK)

wMaxPacketSize

0x40

bInterval

0x0

Device Descriptor

bLength

0x12

bcdUSB

0x0200 (USB 2.0)

bDeviceClass

0x0

bDeviceSubClass

0x0

bDeviceProtocol

0x0

bMaxPacketSize0

0x8

idVendor

0x694 (Lego Group)

idProduct

0x2 (Mindstorms NXT)

bcdDevice

0x0

iManufacturer

0x0

iProduct

0x0

iSerialNumber

0x1 (0x409: 0016530703E2)

bNumConfigurations

0x1

</colgroup>

Parameter

Value

Configuration Descriptor

bLength

0x9

bDescriptorType

USB_CONFIGURATION_DESCRIPTOR_TYPE

wTotalLength

0x20

bNumInterfaces

0x1

iConfiguration

0x0

bmAttributes

0xC0 ( Bus_Powered Self_Powered )

MaxPower

0x0

Interface Descriptor

bLength

0x9

bInterfaceNumber

0x0

bAlternateSetting

0x0

bNumEndpoints

0x2

bInterfaceClass

0xFF (Vendor Specific)

bInterfaceSubClass

0xFF

bInterfaceProtocol

0xFF

iInterface

0x0

Endpoint Descriptor

bLength

0x7

bEndpointAddress

0x1 [OUT]

bmAttributes

0x2 (USB_ENDPOINT_TYPE_BULK)

wMaxPacketSize

0x40

bInterval

0x0

Endpoint Descriptor

bLength

0x7

bEndpointAddress

0x82 [IN]

bmAttributes

0x2 (USB_ENDPOINT_TYPE_BULK)

wMaxPacketSize

0x40

bInterval

0x0

marceldanilo
Associate II
Posted on June 23, 2012 at 20:33

tsuneo
Senior
Posted on June 27, 2012 at 07:11

Sorry for long delay,

For these days, I'm trying to download ''Bluetooth Development kit'' (BDK_Download1.zip) from Mindstorms support: Files site,

http://mindstorms.lego.com/en-us/support/files/default.aspx

but the download always stop at the first short portion. This kit should include a document of Bluetooth and USB protocols of NXT.

A couple of data sheet sites have a copy of this document.

''LEGO MINDSTORMS NXT Communication Protocol''

I give up to download the original, though it's better to work on the original, for the latest version..

The USB protocol seems that a command (query) packet is sent over bulk OUT, and a status (reply) packet returns from bulk IN. No vendor request is used.

Can you confirm it using a PC and a NXT, over a USB sniffer?

Tsuneo