Vendor Class APIs

Files added to implement Vendor Class functions:
usb-device-endpoint-functions.c

APIs provided:


USB_DEVICE_EndpointWrite

Description Inputs Returns
USB_DEVICE_EndpointWrite
initiates the write by requesting 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 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 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.

}

20th Annual
Microchip MASTERs Conference 2016

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.