📄 usb_descriptors.h
字号:
//! @file usb_descriptors.h,v
//!
//! Copyright (c) 2004 Atmel.
//!
//! Use of this program is subject to Atmel's End User License Agreement.
//! Please read file license.txt for copyright notice.
//!
//! @brief USB Identifers.
//!
//! This file contains the usb parameters that uniquely identify the
//! application through descriptor tables.
//!
//! @version 1.3 at90usb128-demo-audio-1_0_2 $Id: usb_descriptors.h,v 1.3 2006/03/17 13:06:08 rletendu Exp $
//!
//! @todo
//! @bug
#ifndef _USB_USERCONFIG_H_
#define _USB_USERCONFIG_H_
//_____ I N C L U D E S ____________________________________________________
#include "config.h"
#include "modules/usb/device_chap9/usb_standard_request.h"
#include "conf_usb.h"
//_____ M A C R O S ________________________________________________________
#define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
#define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
#define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg.bLength))
#define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
//_____ U S B D E F I N E _______________________________________________
// USB Device descriptor
#define USB_SPECIFICATION 0x0200
#define DEVICE_CLASS 0 // each configuration has its own class
#define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
#define DEVICE_PROTOCOL 0 // each configuration has its own protocol
#define EP_CONTROL_LENGTH 64
#define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh
#define PRODUCT_ID 0x2019
#define RELEASE_NUMBER 0x1000
#define MAN_INDEX 0x01
#define PROD_INDEX 0x02
#define SN_INDEX 0x03
#define NB_CONFIGURATION 1
// USB mic configuration descriptor
#define NB_INTERFACE 2 //Usb mic has two interfaces
#define CONF_NB 1
#define CONF_INDEX 0
#define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
#define MAX_POWER 50 // 100 mA
// Standard Audio control (AC) interface descriptor
#define INTERFACE_NB 0
#define ALTERNATE 0
#define NB_ENDPOINT 0 // No endpoint for AC interface
#define INTERFACE_CLASS 0x01 // Audio Class
#define INTERFACE_SUB_CLASS 0x01 // Audio_control sub class
#define INTERFACE_PROTOCOL 0x00 // Unused
#define INTERFACE_INDEX 0
// USB Endpoint 1 descriptor FS
#define ENDPOINT_NB_1 (EP_AUDIO_IN | 0x80)
#define EP_ATTRIBUTES_1 0x01 // BULK = 0x02, INTERUPT = 0x03
#define EP_IN_LENGTH 16
#define EP_SIZE_1 EP_IN_LENGTH
#define EP_INTERVAL_1 0x01 // One packet per frame
// AC interface descriptor Audio specific
#define AUDIO_CLASS_REVISION 0x0100
#define NB_OF_STREAMING_INTERFACE 0x01
#define BELONGS_AUDIO_INTERFACE 0x01
// Input Terminal descriptor
#define INPUT_TERMINAL_ID 0x01
#define INPUT_TERMINAL_TYPE 0x0201 // Terminal is microphone
#define INPUT_TERMINAL_ASSOCIATION 0x00 // No association
#define INPUT_TERMINAL_NB_CHANNELS 0x01 // One channel for input terminal
#define INPUT_TERMINAL_CHANNEL_CONF 0x0000 // Mono sets no position
#define INPUT_TERMINAL_CH_NAME_ID 0x00 // No channel name
//MIC Feature Unit descriptor
#define MIC_FEATURE_UNIT_ID 0x02
#define MIC_FEATURE_UNIT_SOURCE_ID 0x01
#define MIC_BMA_CONTROLS 0x0003 // Mute + Volume
//#define MIC_BMA_CONTROLS 0x0001 // Mute Only
// Output Terminal descriptor
#define OUTPUT_TERMINAL_ID 0x03
#define OUTPUT_TERMINAL_TYPE 0x0101 // USB Streaming
#define OUTPUT_TERMINAL_ASSOCIATION 0x00 // No association
#define OUTPUT_TERMINAL_SOURCE_ID 0x02 // From Feature Unit Terminal
//Audio Streaming (AS) interface descriptor
#define STD_AS_INTERFACE_NB 0x01 // Index of Std AS Interface
//Alternate O Audio Streaming (AS) interface descriptor
#define ALT0_AS_INTERFACE_INDEX 0x00 // Index of Std AS interface Alt0
#define ALT0_AS_NB_ENDPOINT 0x00 // Nb od endpoints for alt0 interface
#define ALT0_AS_INTERFACE_CLASS 0x01 // Audio class
#define ALT0_AS_INTERFACE_SUB_CLASS 0x02 // Audio streamn sub class
#define ALT0_AS_INTERFACE_PROTOCOL 0x00 // Unused
//Alternate 1 Audio Streaming (AS) interface descriptor
#define ALT1_AS_INTERFACE_INDEX 0x01 // Index of Std AS interface Alt0
#define ALT1_AS_NB_ENDPOINT 0x01 // Nb od endpoints for alt1 interface
#define ALT1_AS_INTERFACE_CLASS 0x01 // Audio class
#define ALT1_AS_INTERFACE_SUB_CLASS 0x02 // Audio streamn sub class
#define ALT1_AS_INTERFACE_PROTOCOL 0x00 // Unused
//AS general Interface descriptor
#define AS_TERMINAL_LINK 0x03 // Unit Id of the output terminal
#define AS_DELAY 0x01 // Interface delay
#define AS_FORMAT_TAG 0x0001 // PCM Format
// Format type
#define FORMAT_TYPE 0x01 // Format TypeI
#define FORMAT_NB_CHANNELS 0x01 // One Channel
#define FORMAT_FRAME_SIZE 0x02 // Two bytes per audio sample
#define FORMAT_BIT_RESOLUTION 0x10 // 16 bits per sample
#define FORMAT_SAMPLE_FREQ_NB 0x01 // One frequency supported
#define FORMAT_LSBYTE_SAMPLE_FREQ 0x1F40 // 0x001F40=8kHz Sample frequency
#define FORMAT_MSBYTE_SAMPLE_FREQ 0x00 // MsByte of 0x001F40
//Audio endpoint specific descriptor field
#define AUDIO_EP_ATRIBUTES 0x00 // No sampling freq, no pitch, no pading
#define AUDIO_EP_DELAY_UNIT 0x00 // Unused
#define AUDIO_EP_LOCK_DELAY 0x0000 // Unused
#define LANG_ID 0x00
#define DEVICE_STATUS 0x00 // TBD
#define INTERFACE_STATUS 0x00 // TBD
#define USB_MN_LENGTH 5
#define USB_MANUFACTURER_NAME \
{ Usb_unicode('A') \
, Usb_unicode('T') \
, Usb_unicode('M') \
, Usb_unicode('E') \
, Usb_unicode('L') \
}
#define USB_PN_LENGTH 18
#define USB_PRODUCT_NAME \
{ Usb_unicode('A') \
,Usb_unicode('V') \
,Usb_unicode('R') \
,Usb_unicode(' ') \
,Usb_unicode('U') \
,Usb_unicode('S') \
,Usb_unicode('B') \
,Usb_unicode(' ') \
,Usb_unicode('A') \
,Usb_unicode('U') \
,Usb_unicode('D') \
,Usb_unicode('I') \
,Usb_unicode('O') \
,Usb_unicode(' ') \
,Usb_unicode('D') \
,Usb_unicode('E') \
,Usb_unicode('M') \
,Usb_unicode('O') \
}
#define USB_SN_LENGTH 0x05
#define USB_SERIAL_NUMBER \
{ Usb_unicode('1') \
,Usb_unicode('.') \
,Usb_unicode('0') \
,Usb_unicode('.') \
,Usb_unicode('0') \
}
//Audio Channel Name
#define AUDIO_CHANNEL_NAME \
{ Usb_unicode('A') \
, Usb_unicode('T') \
, Usb_unicode('M') \
, Usb_unicode('E') \
, Usb_unicode('L') \
}
#define LANGUAGE_ID 0x0409
//! Usb Request
typedef struct
{
U8 bmRequestType; //!< Characteristics of the request
U8 bRequest; //!< Specific request
U16 wValue; //!< field that varies according to request
U16 wIndex; //!< field that varies according to request
U16 wLength; //!< Number of bytes to transfer if Data
} S_UsbRequest;
//! Usb Device Descriptor
typedef struct {
U8 bLength; //!< Size of this descriptor in bytes
U8 bDescriptorType; //!< DEVICE descriptor type
U16 bscUSB; //!< Binay Coded Decimal Spec. release
U8 bDeviceClass; //!< Class code assigned by the USB
U8 bDeviceSubClass; //!< Sub-class code assigned by the USB
U8 bDeviceProtocol; //!< Protocol code assigned by the USB
U8 bMaxPacketSize0; //!< Max packet size for EP0
U16 idVendor; //!< Vendor ID. ATMEL = 0x03EB
U16 idProduct; //!< Product ID assigned by the manufacturer
U16 bcdDevice; //!< Device release number
U8 iManufacturer; //!< Index of manu. string descriptor
U8 iProduct; //!< Index of prod. string descriptor
U8 iSerialNumber; //!< Index of S.N. string descriptor
U8 bNumConfigurations; //!< Number of possible configurations
} S_usb_device_descriptor;
//! Usb Configuration Descriptor
typedef struct {
U8 bLength; //!< size of this descriptor in bytes
U8 bDescriptorType; //!< CONFIGURATION descriptor type
U16 wTotalLength; //!< total length of data returned
U8 bNumInterfaces; //!< number of interfaces for this conf.
U8 bConfigurationValue; //!< value for SetConfiguration resquest
U8 iConfiguration; //!< index of string descriptor
U8 bmAttibutes; //!< Configuration characteristics
U8 MaxPower; //!< maximum power consumption
} S_usb_configuration_descriptor;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -