Вверх ↑
Ответов: 46
Рейтинг: 6
#1: 2007-03-20 17:09:42 ЛС | профиль | цитата
Dilma писал(а):
vyachko, тут код приводить надо с использованием Windows-API. Описание логики работы USB контроллера врятли чем-то может помочь.

Вот, что-то нашёл, не знаю оно или нет (я в программировании не силён):
usb100.h

Взято с http://www.koders.com.
За режим питания отвечает MaxPower.

И ещё с http://msdn2.microsoft.com/en-us/library/ms793522.aspx
Windows Driver Kit: Buses
USB_CONFIGURATION_DESCRIPTOR
USB client drivers use the USB_CONFIGURATION_DESCRIPTOR structure to hold a USB-defined configuration descriptor.

typedef struct _USB_CONFIGURATION_DESCRIPTOR {
UCHAR bLength ;
UCHAR bDescriptorType ;
USHORT wTotalLength ;
UCHAR bNumInterfaces ;
UCHAR bConfigurationValue;
UCHAR iConfiguration ;
UCHAR bmAttributes ;
UCHAR MaxPower ;
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR ;

Members
bLength
Specifies the length, in bytes, of this structure.
bDescriptorType
Specifies the descriptor type. Must be set to USB_CONFIGURATION_DESCRIPTOR_TYPE.
wTotalLength
Specifies the total length, in bytes, of all data for the configuration. The length includes all interface, endpoint, class, or vendor-specific descriptors that are returned with the configuration descriptor.
bNumInterfaces
Specifies the total number of interfaces supported by this configuration.
iConfiguration
Specifies the device-defined index of the string descriptor for this configuration.
bConfigurationValue
Contains the value that is used to select a configuration. This value is passed to the USB SetConfiguration request , as described in version 1.1 of the Universal Serial Bus Specification. The port driver does not currently expose a service that allows higher-level drivers to set the configuration.
bmAttributes
Specifies a bitmap to describe behavior of this configuration. The bits are described and set in little-endian order.
Bit Meaning
0 - 4 Reserved.
5 The configuration supports remote wakeup.
6 The configuration is self-powered and does not use power from the bus.
7 The configuration is powered by the bus.

MaxPower
Specifies the power requirements of this device in two-milliampere units. This member is valid only if bit seven is set in bmAttributes.

Headers
Declared in usb100.h. Include usb100.h.

Comments
If wTotalLength is greater than the buffer size provided in the URB to hold all descriptors retrieved (interface, endpoint, class, and vendor-defined), incomplete data will be returned. In order to retrieve complete descriptors, the request will need to be re-sent with a larger buffer.

If bmAttributes bits six and seven are both set, then the device is powered both by the bus and by a source external to the bus.

Other members that are part of this structure but not described here should be treated as opaque and considered to be reserved for system use.

И ещё немного для тех, кто не верит про настройку величины тока. http://www.microsoft.com/whdc/system/bus/USB/IAD.mspx

CONFIGURATION DESCRIPTOR:
BYTE bLength: 0x09
BYTE bDescriptorType: 0x02
WORD wTotalLength: 0x....
BYTE bNumInterface: 0x03
BYTE bConfigurationValue: 0x01
BYTE iConfiguration: 0x01
BYTE bmAttributes: 0x80 (BUS Powered)
BYTE bMaxPower: 0x19 (50 mA)

Для желающих более подробно то: http://udf-cat.tstu.edu.ua/fileserver/Engeneering/Computing%20Science/Software/Programming/Агуров%20П.%20Интерфейс%20USB.%20Практика%20использования%20и%20программирования.%202004.djvu (8,16МБ).

карма: 1
Время верстки: %cr_time% Текущее время: %time%
0
файлы: 1code_1103.txt [7.2KB] [240]