Module Description
The USB Core Layer implements the device abstraction defined in the Universal Serial Bus Specification, for applications to interact with the USB device interface on the device. The software in this layer responds to standard requests and returns standard descriptors. In current stack the Init() routine part of USBD_HW_API_T structure initializes both hardware layer and core layer.
Common definitions and declarations for the USB stack.
#define B3VAL |
( |
|
x | ) |
((x) & 0xFF),(((x) >> 8) & 0xFF),(((x) >> 16) & 0xFF) |
Class Request
Definition at line 100 of file usbd.h.
#define REQUEST_DEVICE_TO_HOST 1 |
Request from device to host
Definition at line 91 of file usbd.h.
#define REQUEST_HOST_TO_DEVICE 0 |
bmRequestType.Dir definesRequest from host to device
Definition at line 89 of file usbd.h.
#define REQUEST_RESERVED 3 |
Reserved Request
Definition at line 104 of file usbd.h.
#define REQUEST_STANDARD 0 |
bmRequestType.Type definesStandard Request
Definition at line 98 of file usbd.h.
#define REQUEST_TO_DEVICE 0 |
bmRequestType.Recipient definesRequest to device
Definition at line 111 of file usbd.h.
#define REQUEST_TO_ENDPOINT 2 |
Request to endpoint
Definition at line 115 of file usbd.h.
#define REQUEST_TO_INTERFACE 1 |
Request to interface
Definition at line 113 of file usbd.h.
#define REQUEST_TO_OTHER 3 |
Request to other
Definition at line 117 of file usbd.h.
Vendor Request
Definition at line 102 of file usbd.h.
#define USB_CONFIG_BUS_POWERED 0x80 |
Bus powered
Definition at line 278 of file usbd.h.
#define USB_CONFIG_POWERED_MASK 0x40 |
bmAttributes in Configuration DescriptorPower field mask
Definition at line 276 of file usbd.h.
#define USB_CONFIG_REMOTE_WAKEUP 0x20 |
remote wakeup
Definition at line 282 of file usbd.h.
#define USB_CONFIG_SELF_POWERED 0xC0 |
Self powered
Definition at line 280 of file usbd.h.
#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR)) |
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 |
Configuration descriptor type
Definition at line 220 of file usbd.h.
#define USB_DEBUG_DESCRIPTOR_TYPE 10 |
Debug descriptor type
Definition at line 236 of file usbd.h.
#define USB_DEVICE_CLASS_APP 0xFE |
Application device class
Definition at line 267 of file usbd.h.
#define USB_DEVICE_CLASS_AUDIO 0x01 |
Audio device class
Definition at line 247 of file usbd.h.
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 |
Communications device class
Definition at line 249 of file usbd.h.
#define USB_DEVICE_CLASS_HUB 0x09 |
Hub device class
Definition at line 263 of file usbd.h.
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 |
Human interface device class
Definition at line 251 of file usbd.h.
#define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF |
miscellaneous device class
Definition at line 265 of file usbd.h.
#define USB_DEVICE_CLASS_MONITOR 0x04 |
monitor device class
Definition at line 253 of file usbd.h.
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 |
physical interface device class
Definition at line 255 of file usbd.h.
#define USB_DEVICE_CLASS_POWER 0x06 |
power device class
Definition at line 257 of file usbd.h.
#define USB_DEVICE_CLASS_PRINTER 0x07 |
Printer device class
Definition at line 259 of file usbd.h.
#define USB_DEVICE_CLASS_RESERVED 0x00 |
USB Device ClassesReserved device class
Definition at line 245 of file usbd.h.
#define USB_DEVICE_CLASS_STORAGE 0x08 |
Storage device class
Definition at line 261 of file usbd.h.
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF |
Vendor specific device class
Definition at line 269 of file usbd.h.
#define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR)) |
#define USB_DEVICE_DESCRIPTOR_TYPE 1 |
USB Descriptor TypesDevice descriptor type
Definition at line 218 of file usbd.h.
#define USB_DEVICE_QUALI_SIZE (sizeof(USB_DEVICE_QUALIFIER_DESCRIPTOR)) |
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 |
Device qualifier descriptor type
Definition at line 228 of file usbd.h.
#define USB_ENDPOINT_0_HS_MAXP 64 |
Control endopint EP0's maximum packet size in high-speed mode.
Definition at line 335 of file usbd.h.
#define USB_ENDPOINT_0_LS_MAXP 8 |
Control endopint EP0's maximum packet size in low-speed mode.
Definition at line 337 of file usbd.h.
#define USB_ENDPOINT_BULK_HS_MAXP 512 |
Bulk endopint's maximum packet size in high-speed mode.
Definition at line 339 of file usbd.h.
#define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR)) |
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5 |
Endpoint descriptor type
Definition at line 226 of file usbd.h.
#define USB_ENDPOINT_DIRECTION_MASK 0x80 |
bMaxPower in Configuration Descriptor bEndpointAddress in Endpoint DescriptorEndopint address mask
Definition at line 292 of file usbd.h.
#define USB_ENDPOINT_IN |
( |
|
addr | ) |
((addr) | 0x80) |
Macro to convert IN endopint number to endpoint address value.
Definition at line 296 of file usbd.h.
#define USB_ENDPOINT_OUT |
( |
|
addr | ) |
((addr) | 0x00) |
Macro to convert OUT endopint number to endpoint address value.
Definition at line 294 of file usbd.h.
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 |
Adaptive sync Endopint
Definition at line 319 of file usbd.h.
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 |
Asynchronous sync Endopint
Definition at line 317 of file usbd.h.
#define USB_ENDPOINT_SYNC_MASK 0x0C |
Endopint sync type mask
Definition at line 313 of file usbd.h.
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 |
no synchronization Endopint
Definition at line 315 of file usbd.h.
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C |
Synchronous sync Endopint
Definition at line 321 of file usbd.h.
#define USB_ENDPOINT_TYPE_BULK 0x02 |
bulk Endopint type
Definition at line 309 of file usbd.h.
#define USB_ENDPOINT_TYPE_CONTROL 0x00 |
Control Endopint type
Definition at line 305 of file usbd.h.
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03 |
interrupt Endopint type
Definition at line 311 of file usbd.h.
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 |
isochronous Endopint type
Definition at line 307 of file usbd.h.
#define USB_ENDPOINT_TYPE_MASK 0x03 |
bmAttributes in Endpoint DescriptorEndopint type mask
Definition at line 303 of file usbd.h.
#define USB_ENDPOINT_USAGE_DATA 0x00 |
Endopint data usage type
Definition at line 325 of file usbd.h.
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10 |
Endopint feedback usage type
Definition at line 327 of file usbd.h.
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 |
Endopint implicit feedback usage type
Definition at line 329 of file usbd.h.
#define USB_ENDPOINT_USAGE_MASK 0x30 |
Endopint usage type mask
Definition at line 323 of file usbd.h.
#define USB_ENDPOINT_USAGE_RESERVED 0x30 |
Endopint reserved usage type
Definition at line 331 of file usbd.h.
#define USB_FEATURE_ENDPOINT_STALL 0 |
USB Standard Feature selectorsENDPOINT_STALL feature
Definition at line 181 of file usbd.h.
#define USB_FEATURE_REMOTE_WAKEUP 1 |
REMOTE_WAKEUP feature
Definition at line 183 of file usbd.h.
#define USB_FEATURE_TEST_MODE 2 |
TEST_MODE feature
Definition at line 185 of file usbd.h.
#define USB_GETSTATUS_ENDPOINT_STALL 0x01 |
ENDPOINT_STALL status
Definition at line 174 of file usbd.h.
#define USB_GETSTATUS_REMOTE_WAKEUP 0x02 |
REMOTE_WAKEUP capable status
Definition at line 172 of file usbd.h.
#define USB_GETSTATUS_SELF_POWERED 0x01 |
USB GET_STATUS Bit ValuesSELF_POWERED status
Definition at line 170 of file usbd.h.
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 |
Interface association descriptor type
Definition at line 238 of file usbd.h.
#define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR)) |
#define USB_INTERFACE_DESCRIPTOR_TYPE 4 |
Interface descriptor type
Definition at line 224 of file usbd.h.
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 |
Interface power descriptor type
Definition at line 232 of file usbd.h.
#define USB_OTG_DESCRIPTOR_TYPE 9 |
OTG descriptor type
Definition at line 234 of file usbd.h.
#define USB_OTHER_SPEED_CONF_SIZE (sizeof(USB_OTHER_SPEED_CONFIGURATION)) |
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 |
Other speed configuration descriptor type
Definition at line 230 of file usbd.h.
#define USB_REQUEST_CLEAR_FEATURE 1 |
CLEAR_FEATURE request
Definition at line 145 of file usbd.h.
#define USB_REQUEST_GET_CONFIGURATION 8 |
GET_CONFIGURATION request
Definition at line 155 of file usbd.h.
#define USB_REQUEST_GET_DESCRIPTOR 6 |
GET_DESCRIPTOR request
Definition at line 151 of file usbd.h.
#define USB_REQUEST_GET_INTERFACE 10 |
GET_INTERFACE request
Definition at line 159 of file usbd.h.
#define USB_REQUEST_GET_STATUS 0 |
USB Standard Request CodesGET_STATUS request
Definition at line 143 of file usbd.h.
#define USB_REQUEST_SET_ADDRESS 5 |
SET_ADDRESS request
Definition at line 149 of file usbd.h.
#define USB_REQUEST_SET_CONFIGURATION 9 |
SET_CONFIGURATION request
Definition at line 157 of file usbd.h.
#define USB_REQUEST_SET_DESCRIPTOR 7 |
SET_DESCRIPTOR request
Definition at line 153 of file usbd.h.
#define USB_REQUEST_SET_FEATURE 3 |
SET_FEATURE request
Definition at line 147 of file usbd.h.
#define USB_REQUEST_SET_INTERFACE 11 |
SET_INTERFACE request
Definition at line 161 of file usbd.h.
#define USB_REQUEST_SYNC_FRAME 12 |
SYNC_FRAME request
Definition at line 163 of file usbd.h.
#define USB_STRING_DESCRIPTOR_TYPE 3 |
String descriptor type
Definition at line 222 of file usbd.h.
#define WBVAL |
( |
|
x | ) |
((x) & 0xFF),(((x) >> 8) & 0xFF) |
USB device stack's event callback function type.
The USB device stack exposes several event triggers through callback to application layer. The application layer can register methods to be called when such USB event happens.
- Parameters
-
hUsb | Handle to the USB device stack. |
- Returns
- The call back should returns ErrorCode_t type to indicate success or error condition.
- Return values
-
LPC_OK | On success |
ERR_USBD_UNHANDLED | Event is not handled hence pass the event to next in line. |
ERR_USBD_xxx | Other error conditions. |
Definition at line 65 of file usbd_core.h.
USBD setup request and endpoint event handler type.
The application layer should define the custom class's EP0 handler with function signature. The stack calls all the registered class handlers on any EP0 event before going through default handling of the event. This gives the class handlers to implement class specific request handlers and also to override the default stack handling for a particular event targeted to the interface. If an event is not handled by the callback the function should return ERR_USBD_UNHANDLED. For all other return codes the stack assumes that callback has taken care of the event and hence will not process the event any further and issues a STALL condition on EP0 indicating error to the host.
For endpoint interrupt handler the return value is ignored by the stack.
- Parameters
-
hUsb | Handle to the USB device stack. |
data | Pointer to the data which will be passed when callback function is called by the stack. |
event | Type of endpoint event. See USBD_EVENT_T for more details. |
- Returns
- The call back should returns ErrorCode_t type to indicate success or error condition.
- Return values
-
LPC_OK | On success. |
ERR_USBD_UNHANDLED | Event is not handled hence pass the event to next in line. |
ERR_USBD_xxx | For other error conditions. |
Definition at line 107 of file usbd_core.h.
USB device stack's event callback function type.
The USB device stack exposes several event triggers through callback to application layer. The application layer can register methods to be called when such USB event happens.
- Parameters
-
hUsb | Handle to the USB device stack. |
param1 | Extra information related to the event. |
- Returns
- The call back should returns ErrorCode_t type to indicate success or error condition.
- Return values
-
LPC_OK | On success |
ERR_USBD_UNHANDLED | Event is not handled hence pass the event to next in line. |
ERR_USBD_xxx | For other error conditions. |
Definition at line 82 of file usbd_core.h.
USB device stack/module handle.
Definition at line 655 of file usbd.h.