Files added to implement Vendor Class functions:
- usb-device-endpoint-functions.c
Application Programming Interfaces (APIs) provided:
USB_DEVICE_EndpointWrite
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_EndpointWrite Initiates the write by requesting the data be placed in the specified endpoint. The write will be completed when the host requests the data. |
USB Device Handle, Transfer Handle, Endpoint, Pointer to the data buffer, Length of transfer Device-Transfer-flag* |
Status of the transfer request |
*Note the value of the device transfer flag can be found in the enum USB_DEVICE_TRANSFER_FLAGS
Example of writing to an Endpoint:
USB_DEVICE_HANDLE dvcHandle
dvcHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
USB_DEVICE_TRANSFER_HANDLE dvcTransferHandle;
USB_DEVICE_RESULT result;
…
// Sending 64 bits of data from 'databuffer to the TxEndpoint
result = USB_DEVICE_EndpointWrite( dvcHandle,
&dvcTransferHandle ,
TxEndpoint,
databuffer, 64,
USB_DEVICE_TRANSFER_FLAGS_DATA_COMPLETE);
if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.
}
USB_DEVICE_EndpointRead
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_EndpointRead Moves the data from the specified endpoint into a data buffer. |
USB Device Handle, Transfer Handle, Endpoint, Pointer to the data buffer, Length of transfer |
Status of the transfer request |
Example of reading an Endpoint:
USB_DEVICE_HANDLE dvcHandle
dvcHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
USB_DEVICE_TRANSFER_HANDLE dvcTransferHandle;
USB_DEVICE_RESULT result;
…
// Reading in the contents of an Endpoint
result = USB_DEVICE_EndpointRead( dvcHandle,
&dvcTransferHandle ,
RxEndpoint,
databuffer,
sizeof(databuffer);
if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.
}
USB_DEVICE_EndpointTransferCancel
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_EndpointTransfer Cancel Cancels and terminates an incomplete transfer (read or write) on an endpoint. |
USB Device Handle, Endpoint, Transfer Handle |
Status of the transfer request |
Example of cancelling an Endpoint transfer:
USB_DEVICE_HANDLE dvcHandle
dvcHandle = USB_DEVICE_Open( USB_DEVICE_INDEX_0 );
USB_DEVICE_TRANSFER_HANDLE dvcTransferHandle;
USB_DEVICE_RESULT result;
…
// cancelling a pending transfer
result = USB_DEVICE_EndpointTransferCancel( dvcHandle,
App_Endpoint,
&dvcTransferHandle );
if( result != USB_DEVICE_RESULT_OK)
{
//Handle error.
}