USB
  Simple bulk example

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Simple bulk example
Tsuneo
Member
posted January 06, 2006 08:55 PM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
Simple bulk example

SiLabs USB_Bulk example is excellent. However, as the start point for modification, simpler example is desirable. USB_INT (now USB_Interrupt) example is rather simpler than USB_Bulk on its control structure. This is the reason why USB_INT is often selected by developers who attempt USB world. Fortunately, USB_INT can be easily converted to bulk one. The conversion procedure is summarized as follows.

On the firmware,
a) Replace PID on the Device Descriptor to bulk one
b) Change transfer attribute (bmAttributes) on the Endpoint Descriptor from interrupt to bulk

On the host application
a) Replace GUID to bulk one

(Note)
- On the firmware, VID/PID (Vendor ID/Product ID) specifies device driver.
- On the host application, GUID (Global Unique IDentifier) specifies device driver.
- Bulk and interrupt transfer is (almost) identical on the handling on firmware and host application

The detail is as follows.

Enjoy your USB development.

Tsuneo


[Firmware]
USB_DESCRIPTOR.c (F3xx_USB_Descriptor.c)

const device_descriptor DeviceDesc =
{
18, // bLength
0x01, // bDescriptorType
0x1001, // bcdUSB
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
EP0_PACKET_SIZE, // bMaxPacketSize0
0xC410, // idVendor
0x0300, // idProduct 0x0000 <-- 0x0003 (LSB first)
0x0000, // bcdDevice
0x01, // iManufacturer
0x02, // iProduct
0x00, // iSerialNumber
0x01 // bNumConfigurations
}; //end of DeviceDesc

const endpoint_descriptor Endpoint1Desc =
{
0x07, // bLength
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x02, // bmAttributes 0x03 (interrupt) <-- 0x02 (bulk)
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
10 // bInterval
}; //end of Endpoint2Desc

const endpoint_descriptor Endpoint2Desc =
{
0x07, // bLength
0x05, // bDescriptorType
0x02, // bEndpointAddress
0x02, // bmAttributes 0x03 (interrupt) <-- 0x02 (bulk)
EP2_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
10 // bInterval
}; //end of Endpoint2Desc


[Host application]
USB_TestDlg.cpp

/////////////////////////////////////////////////////////////////////////////
// USB driver definitions

DEFINE_GUID(GUID_INTERFACE_SILABS_INTERRUPT,
// 0xdda31245, 0x1bfc, 0x4225, 0xb2, 0xb8, 0xea, 0xaa, 0xb2, 0xe3, 0x90, 0xb6);
0x37538c66, 0x9584, 0x42d3, 0x96, 0x32, 0xeb, 0xad, 0xa, 0x23, 0xd, 0x13);


My USB topics
Simple bulk example
How to increase HID_Example In/Out packet size?
FIFO read/write performance
256000 bytes/sec Isochronous transfer
Isochronous test patch
Multi-thread and Overlapped example for USB_INT Host Application
Vendor Requests test code
USB_INT and USB_BULK on Cypress device driver

[EDIT]
Jan 06, 2006 Added Endpoint1Desc, that was mistakenly dropped
Jun 06, 2006 Corrected idProduct field to LSB first (0x0003 -> 0x0300)
March 29, 2007 In the original example, USB_INT was renamed just to USB_Interrupt.

[This message has been edited by Tsuneo (edited March 28, 2007).]

IP: Logged

egawtry
Member
posted January 30, 2007 10:45 AM     Click Here to See the Profile for egawtry   Click Here to Email egawtry     Edit/Delete Message
Tsuneo,

Don't you also have to install the bulk driver on the PC?

-Erik

IP: Logged

Tsuneo
Member
posted January 30, 2007 11:47 AM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
Hi Erik,

That's right.

If the SiLabs bulk device driver is not installed on the PC yet, Windows will show the New Hardware wizard, when the device is plugged in to the PC.
Specify SiLabs USB_Bulk folder for the INF file.

C:\SiLabs\MCU\Examples\C8051F32x\USB_Bulk
OR
C:\SiLabs\MCU\Examples\C8051F34x\USB_Bulk

Either will do. The device driver is identical.

Tsuneo

[This message has been edited by Tsuneo (edited January 30, 2007).]

IP: Logged

Tsuneo
Member
posted October 25, 2007 04:21 AM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
BulkUSB device driver on WinDDK

Other than SiLabs bulk device driver, WinDDK provides BulkUSB device driver example. This device driver is almost compatible (same?) to SiLabs one.


[WinDDK installation and build]
To download free WinDDK from MS, visit this topic.
WinDDK in Kernel-Mode Driver Framework (KMDF) download

Burn the ISO image of WinDDK to a CDR disk, run the installer as usual.

After installation of WinDDK, you'll see this example here.
C:\WINDDK\3790.1830\src\wdm\usb\bulkusb\

To build this example,
1) Select the build environment, for example,
'Start' button > All programs > Development Kits > Windows DDK 3790.1830
> Built Environments > Windows XP > Windows XP Free Build Environment

2) In the poped-up DOS window, move to the example source directory, and run the build utility

cd src\wdm\usb\bulkusb\sys
build -cZ

3) When the build finishes successfully, bulkusb.sys is resulted in
\objfre_wxp_x86\i386 directory under the source directory.

The INF file (bulkusb.inf) is found in
C:\WINDDK\3790.1830\src\wdm\usb\bulkusb\sys\bulkusb.inf

Copy these sys and INF file to a directory.
(The INF setting expects that the bulkusb.sys file is placed in the same directory as the INF, unless you modify it).
Modify the VID/PID or strings on the INF file, if required.


[Firmware]
Just the VID/PID may be needed to modify.
(except for the endpoint bmAttributes, described in above post)

The default VID/PID on the INF file is,
VID/PID (idVendor/idProduct) = 045E/930A

Match the VID/PID on the firmware to that of the INF file.
Of course, you can modify VID/PID on the INF, and keep the firmware unchanged.
To avoid device driver conflict, however, I recommend you to attach a different VID/PID from the SiLabs bulk VID/PID.


[Host application]
Just the GUID is needed to modify.
The interface GUID for this device driver is defined in bulkusr.h
C:\WINDDK\3790.1830\src\wdm\usb\bulkusb\sys\bulkusr.h

Copy this header file to the host app project, and change
GUID_INTERFACE_SILABS_INTERRUPT to GUID_CLASS_I82930_BULK

As the SiLabs bulk device driver, each endpoint is accessed like "PIPE00", "PIPE01".
The numbering follows the order in which the endpoint descriptors appear on the firmware.
Up to six endpoints are allowed on a single interface, mixing IN and OUT.
(See bulkrwr.c BulkUsb_PipeWithName() )


That's all.

Tsuneo

[This message has been edited by Tsuneo (edited October 25, 2007).]

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b