Vendor Class APIs for Harmony v2

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.

}

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
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.