Ответ:
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено John 20 ноября 2002 г. 18:26
В ответ на: так и у меня они в памяти так лежат. А есть девайс дескриптор и Конфиг дескриптор? Что там в полях прописано про индексы стрингов? отправлено 333ий 20 ноября 2002 г. 17:44

// Общие определения
// Так и не понял, зачем это. Пока не использую
// No descriptor read
#define USB_DEFAULT 0x00
// Descriptor read, Addr not assigned
#define USB_DESCRIPTOR_READ 0x01
// Descriptor Read, Addr assigned
#define USB_ADDRESS_ASSIGNED 0x02
// Device configured
#define USB_CONFIGURED 0x03

// GLOBAL STATUS VALUES
#define STD_COMMAND 0x00
#define SETUP_COMMAND_PHASE 0x40
// Used when we are stalling the function EP0
#define FUNCTION_ERROR 0x7F
// Used when we are stalling the HUB EP0
#define HUB_ERROR 0xFF

// 1.1 Request Values
#define GET_STATUS 0x00
#define CLEAR_FEATURE 0x01
#define SET_FEATURE 0x03
#define SET_ADDRESS 0x05
#define GET_DESCRIPTOR 0x06
#define SET_DESCRIPTOR 0x07
#define GET_CONFIGURATION 0x08
#define SET_CONFIGURATION 0x09
#define GET_INTERFACE 0x0A
#define SET_INTERFACE 0x0B
#define SYNCH_FRAME 0x0C

// HID Request Values
#define GET_REPORT 0x01
#define GET_IDLE 0x02
#define GET_PROTOCOL 0x03
#define SET_REPORT 0x09
#define SET_IDLE 0x0A
#define SET_PROTOCOL 0x0B

// Descriptor Types
#define DEVICE 0x01
#define CONFIGURATION 0x02
#define XSTRING 0x03
#define INTERFACE 0x04
#define ENDPOINT 0x05
#define DEVICE_QUALIFIER 0x06
#define OTHER_SPEED_CONFIGURATION 0x07
#define INTERFACE_POWER 0x08
#define HID 0x21
#define HIDREPORT 0x22
#define HIDPHYSICAL 0x23

// Lengths of various descriptor segments
// Length of device descriptor
#define DEV_LENGTH 18
// Length of configuration descriptor
#define CFG_LENGTH 9
// Length of interface descriptor
#define INT_LENGTH 9
// Length of HID descriptor
#define HID_LENGTH 9
// Length of endpoint descriptor
#define END_LENGTH 7

// Class codes
#define HIDCLASS 0x03
#define NOSUBCLASS 0x00
#define BOOTSUBCLASS 0x01
#define VENDORSPEC 0xFF

// Recipient Selectors/Masks
#define RECIPIENT_MASK 0x1F
#define DEVICE_RECIPIENT 0x00
#define INTERFACE_RECIPIENT 0x01
#define ENDPOINT_RECIPIENT 0x02
#define OTHER_RECIPIENT 0x03

// Feature Selectors
#define DEVICE_REMOTE_WAKEUP 0x01
#define ENDPOINT_STALL 0x00

// Endpoint attributes
#define EA_CONTROL 0x00
#define EA_ISOCHRONIUS 0x01
#define EA_BULK 0x02
#define EA_INTERRUPT 0x03
// For isochronous endpoints
// Synchronization type
#define EA_NOSYCHRONIZATION 0x00
#define EA_ASYNCHRONOUS 0x04
#define EA_ADAPTIVE 0x08
#define EA_SYNCHRONOUS 0x0C
// Usage type
#define EA_DATA 0x00
#define EA_FEEDBACK 0x10
#define EA_IMPFEEDBACK 0x20


// Дескрипторы

// Device descriptor
flash unsigned char DEV_DESC [ DEV_LENGTH ] =
{
// Length of this desc.
DEV_LENGTH,
// DEVICE descriptor
DEVICE,
// USB revision (BCD)
0x01, 0x01,
// Device class, subclass, protocol
0, 0, 0,
// Max packet size for control pipe
8,
// Vendor ID National
0x00, 0x04,
// Product ID Здесь нужно вставить тип устройства
ProductIDL, ProductIDH,
// Revision ID Здесь нужно вставить версию ПО
RevisionIDL, RevisionIDH,
// Index of manufacturer string
1,
// Index of product string
2,
// Index of serial number string
3,
// Number of configurations
1
};

// Configuration descriptor - сумма конфигурации, интерфейса и Endpoint'ов
flash unsigned char CFG_DESC [ CFG_LENGTH + INT_LENGTH + END_LENGTH * 4 ] =
{
// Собственно configuration
// Length of this desc.
CFG_LENGTH,
// CONFIGURATION descriptor
CONFIGURATION,
// Total length returned
( CFG_LENGTH + INT_LENGTH + END_LENGTH * 4 ), 0,
// Number of interfaces
1,
// Number of configurations
1,
// Index of configuration string - нет такой строки
0,
// Attribute : self powered
0x40,
// Max power
0,

// Interface
// Length of this desc.
INT_LENGTH,
// INTERFACE descriptor
INTERFACE,
// Interface number
0,
// Alternate setting
0,
// # of (non 0) endpoints
4,
// Interface class
0xFF,
// Interface subclass
0xFF,
// Interface protocol
0xFF,
// Index of interface string
2,

// Endpoint descriptors
// Endpoint 1
// Length of this desc.
END_LENGTH,
// ENDPOINT descriptor
ENDPOINT,
// Address (IN)
0x81,
// attributes (Bulk)
EA_BULK,
// Max packet size (64)
0x40,0x00,
// Interval (ms)
0x00,

// Endpoint 2
// Length of this desc.
END_LENGTH,
// ENDPOINT descriptor
ENDPOINT,
// Address (OUT)
0x02,
// attributes (Bulk)
EA_BULK,
// Max packet size (64)
0x40,0x00,
// Interval (ms)
0x00,

// Endpoint 3
// Length of this desc.
END_LENGTH,
// ENDPOINT descriptor
ENDPOINT,
// Address (IN)
0x83,
// attributes (Bulk)
EA_BULK,
// Max packet size (64)
0x40,0x00,
// Interval (ms)
0x00,

// Endpoint 4
// Length of this desc.
END_LENGTH,
// ENDPOINT descriptor
ENDPOINT,
// Address (OUT)
0x04,
// attributes (Bulk)
EA_BULK,
// Max packet size (64)
0x40,0x00,
// Interval (ms)
0x00
};



Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru