#include "type.h"
#include "debug.h"
#include "usbstruct.h"
#include "usbapi.h"
#include "usbhw_lpc.h"
Go to the source code of this file.
Defines | |
#define | MAX_DESC_HANDLERS 4 |
#define | DESC_bLength 0 |
#define | DESC_bDescriptorType 1 |
#define | CONF_DESC_wTotalLength 2 |
#define | CONF_DESC_bConfigurationValue 5 |
#define | CONF_DESC_bmAttributes 7 |
#define | INTF_DESC_bAlternateSetting 3 |
#define | ENDP_DESC_bEndpointAddress 2 |
#define | ENDP_DESC_wMaxPacketSize 4 |
Functions | |
void | USBRegisterDescriptors (const U8 *pabDescriptors) |
BOOL | USBGetDescriptor (U16 wTypeIndex, U16 wLangID, int *piLen, U8 **ppbData) |
BOOL | USBHandleStandardRequest (TSetupPacket *pSetup, int *piLen, U8 **ppbData) |
void | USBRegisterCustomReqHandler (TFnHandleRequest *pfnHandler) |
Standard request handler.
This modules handles the 'chapter 9' processing, specifically the standard device requests in table 9-3 from the universal serial bus specification revision 2.0
Specific types of devices may specify additional requests (for example HID devices add a GET_DESCRIPTOR request for interfaces), but they will not be part of this module.
some requests have to return a request error if device not configured:
GET_INTERFACE, GET_STATUS, SET_INTERFACE, SYNCH_FRAME
this applies to the following if endpoint != 0:
SET_FEATURE, GET_FEATURE
Definition in file usbstdreq.c.
#define CONF_DESC_bConfigurationValue 5 |
configuration value offset
Definition at line 62 of file usbstdreq.c.
#define CONF_DESC_bmAttributes 7 |
configuration characteristics
Definition at line 63 of file usbstdreq.c.
#define CONF_DESC_wTotalLength 2 |
total length offset
Definition at line 61 of file usbstdreq.c.
#define DESC_bDescriptorType 1 |
descriptor type offset
Definition at line 58 of file usbstdreq.c.
#define DESC_bLength 0 |
length offset
Definition at line 57 of file usbstdreq.c.
#define ENDP_DESC_bEndpointAddress 2 |
endpoint address offset
Definition at line 69 of file usbstdreq.c.
#define ENDP_DESC_wMaxPacketSize 4 |
maximum packet size offset
Definition at line 70 of file usbstdreq.c.
#define INTF_DESC_bAlternateSetting 3 |
alternate setting offset
Definition at line 66 of file usbstdreq.c.
#define MAX_DESC_HANDLERS 4 |
device, interface, endpoint, other
Definition at line 53 of file usbstdreq.c.
Parses the list of installed USB descriptors and attempts to find the specified USB descriptor.
[in] | wTypeIndex | Type and index of the descriptor |
[in] | wLangID | Language ID of the descriptor (currently unused) |
[out] | *piLen | Descriptor length |
[out] | *ppbData | Descriptor data |
Definition at line 104 of file usbstdreq.c.
BOOL USBHandleStandardRequest | ( | TSetupPacket * | pSetup, | |
int * | piLen, | |||
U8 ** | ppbData | |||
) |
Default handler for standard ('chapter 9') requests
If a custom request handler was installed, this handler is called first.
[in] | pSetup | The setup packet |
[in,out] | *piLen | Pointer to data length |
[in] | ppbData | Data buffer. |
Definition at line 400 of file usbstdreq.c.
void USBRegisterCustomReqHandler | ( | TFnHandleRequest * | pfnHandler | ) |
Registers a callback for custom device requests
In USBHandleStandardRequest, the custom request handler gets a first chance at handling the request before it is handed over to the 'chapter 9' request handler.
This can be used for example in HID devices, where a REQ_GET_DESCRIPTOR request is sent to an interface, which is not covered by the 'chapter 9' specification.
[in] | pfnHandler | Callback function pointer |
Definition at line 429 of file usbstdreq.c.
void USBRegisterDescriptors | ( | const U8 * | pabDescriptors | ) |
Registers a pointer to a descriptor block containing all descriptors for the device.
[in] | pabDescriptors | The descriptor byte array |
Definition at line 87 of file usbstdreq.c.