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

📄 lib_desc.h

📁 ARM9200开发板的ROM boot程序源码1.0
💻 H
📖 第 1 页 / 共 2 页
字号:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : lib_desc.h
//* Object              : USB peripheral library.
//*
//* 1.0 07/23/01 ODi    : Creation
//*----------------------------------------------------------------------------
#ifndef lib_desc_h
#define lib_desc_h
#include    "periph/stdc/std_c.h"
#include 	"Drivers/monitor/drv_usb.h"
/* *********************************************************************** */
/* Following definitions corresponds to the USB specification Rev. 1.1     */
/* They are used during the USB enumeration                                */
/* *********************************************************************** */

/* USB standard request code */
#define USB_GET_STATUS           0
#define USB_CLEAR_FEATURE        1
#define USB_SET_FEATURE          3
#define USB_SET_ADDRESS          5
#define USB_GET_DESCRIPTOR       6
#define USB_SET_DESCRIPTOR       7
#define USB_GET_CONFIGURATION    8
#define USB_SET_CONFIGURATION    9
#define USB_GET_INTERFACE       10
#define USB_SET_INTERFACE       11
#define USB_SYNCH_FRAME         12

/* USB descriptor types */
#define USB_DEVICE               1
#define USB_CONFIGURATION        2
#define USB_STRING               3
#define USB_INTERFACE            4
#define USB_ENDPOINT             5

/* USB standard feature selectors */
#define USB_DEVICE_REMOTE_WAKEUP 1
#define USB_ENDPOINT_HALT        0
/*---------------------------*/
/* USB Setup Data            */
/*---------------------------*/
typedef struct {
	char  bmRequestType;      /* Characteristics of request */
	char  bRequest;           /* Specific request */
	short wValue;             /* Word-sized field */
	short wIndex;             /* Word-sized field; used to pass an index or an offset */
	short wLength;            /* Number of bytes to transfert */
} USBSetupData;

/*-------------------------------------------*/
/* USB Standard device descriptor            */
/*-------------------------------------------*/
#pragma pack(1)

typedef  struct {
	char  bLength;            /* Size of this descriptor */
	char  bDescriptorType;    /* DEVICE descriptor type */
	short bcdUSB;             /* USB Specification release Number */
	char  bDeviceClass;       /* Class code (assigned by the USB) */
	char  bDeviceSubClass;    /* Subclass code (assigned by the USB) */
	char  bDeviceProtocol;    /* Protool code (assigned by the USB) */
	char  bMaxPacketSize0;    /* Maximum packet size for endpoint 0 */
	short idVendor;           /* Vendor ID */
	short idProduct;          /* Product ID */
	short bcdDevice;          /* Device release number */
	char  iManufacturer;      /* Index of string descriptor describing manufacturer*/
	char  iProduct;           /* Index of string descriptor describing the product */
	char  iSerialNumber;      /* Index of string descriptor describing the device's serial number */
	char  bNumConfigurations; /* Number of possible configurations */
} USBDeviceDesc;

/*-------------------------------------------*/
/* USB Standard configuration descriptor     */
/*-------------------------------------------*/
typedef struct {
	char  bLength;            /* Size of this descriptor */
	char  bDescriptorType;    /* CONFIGURATION descriptor type */
	short wTotalLength;       /* Total length of data returned for this configuration */
	char bNumInterfaces;      /* Number of interfaces supported by this configuration */
	char bConfigurationValue; /* Value to use as an argument to the set configuration() request */
	char iConfiguration;      /* Index of string descriptor describing this configuration */
	char bmAttributes;        /* Configuration characteristics */
	char MaxPower;            /* Maximum Power consumption */
} USBConfigurationDesc;

/*---------------------------------------*/
/* USB Standard interface descriptor     */
/*---------------------------------------*/
typedef struct {
	char  bLength;            /* Size of this descriptor */
	char  bDescriptorType;    /* INTERFACE descriptor type */
	char  bInterfaceNumber;   /* Number of interface */
	char  bAlternateSetting;  /* Number of interfaces supported by this configuration */
	char  bNumEndpoints;      /* Number of endpoints used by this interface */
	char  bInterfaceClass;    /* Class code */
	char  bInterfaceSubClass; /* Subclass code */
	char  bInterfaceProtocol; /* Protocol code */
	char  iInterface;         /* Index of string descriptor describing this interface */
} USBInterfaceDesc;

/*--------------------------------------*/
/* USB Standard endpoint descriptor     */
/*--------------------------------------*/
typedef struct {
	char  bLength;            /* Size of this descriptor */
	char  bDescriptorType;    /* ENDP諭NT descriptor type */
	char  bEndpointAddress;   /* Address of the endpoint on the USB device described by this descriptor */
	char  bmAttributes;       /* Bitmap */
	short wMaxPacketSize;     /* Maximum packet size this endpoint is capable of sending or receiving */
	char  bInterval;          /* Interval for polling endpoint for data transfers */
} USBEndpointDesc;

/*------------------------------------------*/
/* USB Standard UNICODE string descriptor  */
/*-----------------------------------------*/
typedef struct {
	char  bLength;            /* Size of this descriptor */
	char  bDescriptorType;    /* STRING descriptor type */
	char  *bString;           /* UNICODE encoded string */
} USBStringDesc;

__inline u_short wTotalLength(char const *pCfg)
{
	return ((pCfg[3] << 8) | pCfg[2]);
}

__inline char bEndpointAddress(char const *pEp)
{
	return (pEp[2] & 0x0F);
}

__inline u_short wMaxPacketSize(char const *pEp)
{
	return ((pEp[5] << 8) | pEp[4]);
}

/* *********************************************************************** */
/* Following structure must be defined by the application                  */
/* Each pointer to function corresponds to standard request from the host  */
/* defined by the USB spec. Rev. 1.1                                       */
/*                                                                         */
/* If the request is not supported, the field must be set to 0. A STALL    */
/* handshake will be initialized with the host.                            */
/* *********************************************************************** */

typedef struct {
/* ======================================================================= */
/* Following functions are called by usbDispatchRequest() if a class or a  */
/* vendor request has been detected                                        */
/* ======================================================================= */
	void (*dispatchClassRequest)    (
		SPipe *pPipe,            /* Default Pipe Handler */
		USBSetupData *pSetup,      /* Descriptor type */
		void *pPrivateClassData);  /* Pointer to private datas */
	void (*dispatchVendorRequest) (
		SPipe *pPipe,            /* Default Pipe Handler */
		USBSetupData *pSetup,      /* Descriptor type */
		void *pPrivateVendorData); /* Pointer to private datas */

/* ======================================================================= */
/* Following functions are called after the request has been checked       */
/* according to the USB macro status                                       */
/* ======================================================================= */
	void (*clearFeature) (
		SPipe *pPipe,     /* Default Pipe Handler */
		char    type,       /* Descriptor type */
		char    index,      /* Descriptor index */
		short   feature);   /* Feature */
	void (*getConfiguration)(
		SPipe *pPipe);    /* Default Pipe Handler */
	void (*getDescriptor) (
		SPipe *pPipe,     /* Default Pipe Handler */
		char    type,       /* Descriptor type */
		char    index,      /* Descriptor index */
		short   langID,     /* Language ID */
		short   length);    /* Desriptor length */

⌨️ 快捷键说明

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