Skip to main content

usb.generaltransfer(deviceAddress, endpointAddress, endpointType, data)

Initiates a transfer via the imp005’s USB

Availability

Device (from impOS™ 34)
Only available on the imp005

Parameters

Name Type Description
deviceAddress Integer The address of the device
endpointAddress Integer The address of the endpoint
endpointType Integer The type of the endpoint
data Blob The data to be transferred

Returns

Nothing

Description

This method initiates a USB transfer. The USB event callback specified in usb.configure() will be called when the transfer completes.

The endpoint must be opened before any transfers can be made (see usb.openendpoint()). The endpoint value is an 8-bit integer formed from the following bit fields:

Bits Description
D0-3 The endpoint number
D4-6 Reserved
D7 The direction of transfer: 0 is out, 1 is in

The value of the endpointType parameter is provided in the endpoint descriptor generated when the device connects, an event which triggers a call to the callback function registered with usb.configure(). It will one of the following values:

Value Type
0x00 Control endpoint
0x01 Isochronous endpoint not supported
0x02 Bulk endpoint
0x03 Interrupt In endpoint (from impOS™ 36)

At the moment, interrupt out transfers are not supported.

For an out-bound transfer the blob passed into the data parameter should contain the data to be written. For an incoming transfer, the blob should be pre-sized to the number of bytes that will be read. The actual bytes read are written into the eventdetails table in the USB event callback (usb.configure()).