Usb.openendpoint and usb.generaltransfer

Hi

Does anyone have a working example of using the USB interface?

I can configure the interface on my IMP005, but can’t figure out the openendpoint and generaltransfer APIs.

Specifically, what values should I use for openendpoint.deviceAddress and openendpoint.type? And what value should I use for generaltransfer.deviceAddress? I can’t seem to find them in any of the values returned from USB_DEVICE_CONNECTED.

Thanks.

Hi

I’ve attached some example code for an ftdi serial device (please DON’T use the mass storage example since it’s destructive - ie it basically writes a pattern into the flash memory without knowledge of the file system).

The deviceAddress is chosen by you - any will do (eg 1) but zero. It is NOT returned by the device in any descriptor.
As part of the enumeration you need to set the address to the device. After that any communication (hence any control or general transfer) must use that address!
For more info, have a look of this: http://www.usbmadesimple.co.uk/ums_5.htm.

The endpoint info (including the types) are returned by the device in the endpoint descriptors (see the usb_device.debug.nut in the archive attached).

Regards

Guiseppe

Many thanks for that, very useful.

Happy Christmas,

Chris