⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_descriptor_parser.h

📁 reference about wireless design which is helpful to everyone
💻 H
字号:
#ifndef USBDESCRIPTORPARSER_H
#define USBDESCRIPTORPARSER_H
/** \addtogroup module_usb_descriptor_parser  USB Descriptor Parser (usbdp)
 * \brief This module contains internally used functions for locating USB descriptors.
 *
 * The parsing mechanism supports all standard descriptors, i.e. DEVICE, CONFIGURATION, INTERFACE,
 * ENDPOINT and STRING, but also other types that use the standard descriptor format:
 * \code
 * typedef struct {
 *    BYTE bLength;                // Size of this descriptor (in bytes)
 *    BYTE bDescriptorType;        // Descriptor type
 *    ...
 * } USB_XXXXXXXX_DESCRIPTOR;
 * \endcode
 *
 * \section section_usbdp_requirements Requirements
 * The standard-formatted descriptors must be placed back-to-back in either XDATA or CODE memory.
 * Two markers (XDATA or CODE memory pointers), \ref pUsbDescStart and \ref pUsbDescEnd, define where
 * the first descriptor begins and where the last descriptor ends, respectively
 * (so that <tt>pUsbDescEnd - pUsbDescStart</tt> equals the total length of the descriptors).
 *
 * The markers can be dynamic, provided that they are not changed while the descriptor parser is in use.
 * However, in most cases the USB descriptor set will be static, hence the markers are also static.
 * The following example shows how static markers are declared and made public in 8051 assembler:
 * \code
 *                 ; Make the symbols public
 *                 PUBLIC pUsbDescStart;
 *                 PUBLIC pUsbDescEnd;
 *
 *                 ...
 *
 * pUsbDescStart:
 * deviceDesc:     ; Device descriptor (the first descriptor)
 *                 DB deviceDescEnd - deviceDesc
 *                 DB DESC_TYPE_DEVICE  ; bDescriptorType
 *                 DB 10H, 01H          ; bcdUSB
 *                 DB 00H               ; bDeviceClass
 *                 DB 00H               ; bDeviceSubClass
 *
 *                 ...
 *
 * string3Desc:    ; String descriptor: Serial number (the last descriptor)
 *                 DB string3DescEnd - string3Desc;
 *                 DB DESC_TYPE_STRING  ; bDescriptorType
 *                 DB '1', 0;
 *                 DB '2', 0;
 *                 DB '3', 0;
 * string3DescEnd:
 * pUsbDescEnd:
 * \endcode
 * @{
 */
#include "cc2511_usb_library_headers.h"


#ifdef EXTERN
   #undef EXTERN
#endif
#ifdef USBDESCRIPTORPARSER_C
   #define EXTERN
#else
   #define EXTERN extern
#endif


//-------------------------------------------------------------------------------------------------------
/// USBDP internal module data
typedef struct {
    const BYTE __xdata *pDesc; ///< Pointer to the current descriptor
} USBDP_DATA;
EXTERN USBDP_DATA __data usbdpData; ///< USBDP internal module data
//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------
/// \name Indexes Into USB Descriptors
//@{
#define DESC_LENGTH_IDX             0 ///< Index of the bLength field (all descriptors)
#define DESC_TYPE_IDX               1 ///< Index of the bDescriptorType field (all descriptors)
#define DESC_CONFIG_LENGTH_LSB_IDX  2 ///< Index of LOBYTE(USB_CONFIGURATION_DESCRIPTOR.wTotalLength)
#define DESC_CONFIG_LENGTH_MSB_IDX  3 ///< Index of HIBYTE(USB_CONFIGURATION_DESCRIPTOR.wTotalLength)
//@}
//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------
// Function prototypes
void usbdpInit(void);
void __xdata* usbdpFindNext(BYTE wantedType, BYTE haltAtType);
USB_DEVICE_DESCRIPTOR __xdata* usbdpGetDeviceDesc(void);
USB_CONFIGURATION_DESCRIPTOR __xdata* usbdpGetConfigurationDesc(UINT8 cfgValue, UINT8 cfgIndex);
USB_INTERFACE_DESCRIPTOR __xdata* usbdpGetInterfaceDesc(UINT8 cfgValue, UINT8 intNumber, UINT8 altSetting);
USB_STRING_DESCRIPTOR __xdata* usbdpGetStringDesc(UINT8 strIndex);
//-------------------------------------------------------------------------------------------------------


//@}


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -