2.2.4 Library Interface

This section describes the Application Programming Interface (API) functions of the USB Device Layer Library.

Refer to each section for a detailed description.

a) System Interaction Functions

Name Description
USB_DEVICE_InitializeCreates and initializes an instance of the USB device layer.
USB_DEVICE_DeinitializeDe-initializes the specified instance of the USB device layer.
USB_DEVICE_StatusProvides the current status of the USB device layer.
USB_DEVICE_TasksUSB Device layer calls all other function driver tasks in this function. It also generates and forwards events to its clients.

b) Client Core Functions

Name Description
USB_DEVICE_OpenOpens the specified USB device layer instance and returns a handle to it.
USB_DEVICE_CloseCloses an opened handle to an instance of the USB device layer.
USB_DEVICE_ClientStatusGetReturns the client specific status.
USB_DEVICE_EventHandlerSetUSB Device Layer Event Handler Callback Function set function.

c) Device Power State Management Functions

Name Description
USB_DEVICE_PowerStateSetSets power state of the device.
USB_DEVICE_RemoteWakeupStatusGetGets the "Remote wake-up" status of the device.
USB_DEVICE_IsSuspendedReturns true if the device is in a suspended state.
USB_DEVICE_RemoteWakeupStartThis function will start the resume signaling.
USB_DEVICE_RemoteWakeupStartTimed This function will start a self timed Remote Wake-up.
USB_DEVICE_RemoteWakeupStopThis function will stop the resume signaling.

d) Device Management Functions

Name Description
USB_DEVICE_StateGetReturns the current state of the USB device.
USB_DEVICE_AttachThis function will attach the device to the USB.
USB_DEVICE_DetachThis function will detach the device from the USB.
USB_DEVICE_ActiveConfigurationGetInforms the client of the current USB device configuration set by the USB host.
USB_DEVICE_ActiveSpeedGetInforms the client of the current operation speed of the USB bus.

e) Endpoint Management Functions

Name Description
USB_DEVICE_EndpointIsStalledThis function returns the stall status of the specified endpoint and direction.
USB_DEVICE_EndpointStallThis function stalls an endpoint in the specified direction.
USB_DEVICE_EndpointStallClearThis function clears the stall on an endpoint in the specified direction.
USB_DEVICE_EndpointDisableDisables a device endpoint.
USB_DEVICE_EndpointEnableEnables a device endpoint.
USB_DEVICE_EndpointIsEnabledReturns true if the endpoint is enabled.
USB_DEVICE_EndpointReadReads data received from host on the requested endpoint.
USB_DEVICE_EndpointTransferCancelThis function cancels a transfer scheduled on an endpoint.
USB_DEVICE_EndpointWriteThis function requests a data write to a USB Device Endpoint.

f) Control Transfer Functions

Name Description
USB_DEVICE_ControlReceive Receives data stage of the control transfer from host to device.
USB_DEVICE_ControlSendSends data stage of the control transfer from device to host.
USB_DEVICE_ControlStatusInitiates status stage of the control transfer.

g) Data Types and Constants

Name Description
USB_DEVICE_EVENTUSB Device Layer Events.
USB_DEVICE_HANDLEData type for USB device handle.
USB_DEVICE_CONTROL_STATUSUSB Device Layer Control Transfer Status Stage flags.
USB_DEVICE_CONTROL_TRANSFER_RESULTEnumerated data type identifying results of a control transfer.
USB_DEVICE_INITUSB Device Initialization Structure.
USB_DEVICE_POWER_STATEEnumerated data type that identifies if the device is self powered or bus powered.
USB_DEVICE_REMOTE_WAKEUP_STATUSEnumerated data type that identifies if the remote wakeup status of the device.
USB_DEVICE_HANDLE_INVALIDConstant that defines the value of an Invalid Device Handle.
USB_DEVICE_INDEX_0USB device layer index definitions.
USB_DEVICE_INDEX_1This is macro USB_DEVICE_INDEX_1.
USB_DEVICE_INDEX_2This is macro USB_DEVICE_INDEX_2.
USB_DEVICE_INDEX_3This is macro USB_DEVICE_INDEX_3.
USB_DEVICE_INDEX_4This is macro USB_DEVICE_INDEX_4.
USB_DEVICE_INDEX_5This is macro USB_DEVICE_INDEX_5.
USB_DEVICE_CLIENT_STATUSEnumerated data type that identifies the USB Device Layer Client Status.
USB_DEVICE_CONFIGURATION_DESCRIPTORS_TABLEPointer to an array that contains pointer to configuration descriptors.
USB_DEVICE_EVENT_DATA_CONFIGUREDUSB Device Set Configuration Event Data type.
USB_DEVICE_EVENT_HANDLERUSB Device Layer Event Handler Function Pointer Type.
USB_DEVICE_EVENT_RESPONSEDevice Layer Event Handler function return type.
USB_DEVICE_FUNCTION_REGISTRATION_TABLEUSB Device Function Registration Structure.
USB_DEVICE_MASTER_DESCRIPTORUSB Device Master Descriptor Structure.
USB_DEVICE_STRING_DESCRIPTORS_TABLEPointer to an array that contains pointer to string descriptors.
USB_DEVICE_EVENT_RESPONSE_NONEDevice Layer Event Handler Function Response Type.
USB_DEVICE_EVENT_DATA_ENDPOINT_READ_COMPLETEUSB Device Layer Endpoint Read and Write Complete Event Data type.
USB_DEVICE_EVENT_DATA_ENDPOINT_WRITE_COMPLETEUSB Device Layer Endpoint Read and Write Complete Event Data type.
USB_DEVICE_EVENT_DATA_SOFUSB Device Start Of Frame Event Data Type.
USB_DEVICE_EVENT_DATA_SYNCH_FRAMEUSB Device Synch Frame Event Data type.
USB_DEVICE_RESULTUSB Device Layer Results Enumeration.
USB_DEVICE_TRANSFER_FLAGSEnumerated data type that identifies the USB Device Layer Transfer Flags.
USB_DEVICE_TRANSFER_HANDLEData type for USB Device Endpoint Data Transfer Handle.
USB_DEVICE_MICROSOFT_OS_DESCRIPTOR_SUPPORT_ENABLE Specifies if the USB Device stack should support Microsoft OS Descriptor.