Ibrahim Dogan - Advanced PIC Microcontroller Projects in C

Здесь есть возможность читать онлайн «Ibrahim Dogan - Advanced PIC Microcontroller Projects in C» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Burlington, Год выпуска: 2008, ISBN: 2008, Издательство: Elsevier Ltd, Жанр: Программирование, Компьютерное железо, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Advanced PIC Microcontroller Projects in C: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Advanced PIC Microcontroller Projects in C»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

• The only project book on the PIC 18 series using the C programming language
• Features 20 complete, tried and test projects
• Includes a CD-ROM of all the programs, hex listings, diagrams, and data sheets

Advanced PIC Microcontroller Projects in C — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Advanced PIC Microcontroller Projects in C», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

8.4 Descriptors

All USB devices have a hierarchy of descriptors that describe various features of the device: the manufacturer ID, the version of the device, the version of USB it supports, what the device is, its power requirements, the number and type of endpoints, and so forth.

The most common USB descriptors are:

• Device descriptors

• Configuration descriptors

• Interface descriptors

• HID descriptors

• Endpoint descriptors

The descriptors are in a hierarchical structure as shown in Figure 8.7. At the top of the hierarchy we have the device descriptor, then the configuration descriptors, followed by the interface descriptors, and finally the endpoint descriptors. The HID descriptor always follows the interface descriptor when the interface belongs to the HID class.

Figure 87 USB descriptor hierarchy All descriptors have a common format The - фото 259

Figure 8.7: USB descriptor hierarchy

All descriptors have a common format. The first byte ( bLength ) specifies the length of the descriptor, while the second byte ( bDescriptorType ) indicates the descriptor type.

8.4.1 Device Descriptors

The device descriptor is the top-level set of information read from a device and the first item the host attempts to retrieve.

A USB device has only one device descriptor, since the device descriptor represents the entire device. It provides general information such as manufacturer, serial number, product number, the class of the device, and the number of configurations. Table 8.5 shows the format for a device descriptor with the meaning of each field.

bLength is the length of the device descriptor.

bDescriptorType is the descriptor type.

bcdUSB reports the highest version of USB the device supports in BCD format. The number is represented as 0xJJMN, where JJ is the major version number, M is the minor version number, and N is the subminor version number. For example, USB 1.1 is reported as 0x0110.

bDeviceClass , bDeviceSubClass , and bDeviceProtocol are assigned by the USB organization and are used by the system to find a class driver for the device.

bMaxPacketSize0 is the maximum input and output packet size for endpoint 0.

idVendor is assigned by the USB organization and is the vendor’s ID.

idProduct is assigned by the manufacturer and is the product ID.

bcdDevice is the device release number and has the same format as the bcdUSB .

iManufacturer , iProduct , and iSerialNumber are details about the manufacturer and the product. These fields have no requirement and can be set to zero.

bNumConfigurations is the number of configurations the device supports.

Table 8.5: Device descriptor

Offset Field Size Description
0 bLength 1 Descriptor size in bytes
1 bDescriptorType 1 Device descriptor (0x01)
2 bcdUSB 2 Highest version of USB supported
4 bDeviceClass 1 Class code
5 bDeviceSubClass 1 Subclass code
6 bDeviceProtocol 1 Protocol code
7 bMaxPacketSize0 1 Maximum packet size
8 idVendor 2 Vendor ID
10 idProduct 2 Product ID
12 bcdDevice 2 Device release number
14 iManufacturer 1 Manufacturer string descriptor
15 iProduct 1 Index of product string descriptor
16 iSerialNumber 1 Index of serial number descriptor
17 bNumConfigurations 1 Number of possible configurations

Table 8.6 shows an example device descriptor for a mouse device. The length of the descriptor is 18 bytes ( bLength =18), and the descriptor type is 0x01 ( bDescriptorType =0x01). The device supports USB 1.1 ( bcdUSB =0x0110). bDeviceClass , bDeviceSubClass , and bDeviceProtocol are set to zero to show that the class information is in the interface descriptor. bMaxPacketSize0 is set to 8 to show that the maximum input and output packet size for endpoint 0 is 8 bytes. The next three bytes identify the device by the vendor ID, product ID, and device version number. The next three items define indexes to strings about the manufacturer, product, and the serial number. Finally, we notice that the mouse device has just one configuration ( bNumConfigurations =1).

Table 8.6: Example device descriptor

Offset Field Value Description
0 bLength 18 Size is 18
1 bDescriptorType 0x01 Descriptor type
2 bcdUSB 0x0110 Highest USB supported = USB 1.1
4 bDeviceClass 0x00 Class information in interface descriptor
5 bDeviceSubClass 0x00 Class information in interface descriptor
6 bDeviceProtocol 0x00 Class information in interface descriptor
7 bMaxPacketSize0 8 Maximum packet size
8 idVendor 0x02A XYZ Co Ltd.
10 idProduct 0x1001 Mouse
12 bcdDevice 0x0011 Device release number
14 iManufacturer 0x20 Index to manufacturer string
15 iProduct 0x21 Index of product string
16 iSerialNumber 0x22 Index of serial number string
17 bNumConfigurations 1 Number of possible configurations

8.4.2 Configuration Descriptors

The configuration descriptor provides information about the power requirements of the device and how many different interfaces it supports. There may be more than one configuration for a device.

Table 8.7 shows the format of the configuration descriptor with the meaning of each field.

bLength is the length of the device descriptor.

bDescriptorType is the descriptor type.

wTotalLength is the total combined size of this set of descriptors (i.e., total of configuration descriptor + interface descriptor + HID descriptor + endpoint descriptor). When the configuration descriptor is read by the host, it returns the entire configuration information, which includes all interface and endpoint descriptors.

bNumInterfaces is the number of interfaces present for this configuration.

bConfigurationValue is used by the host (in command SetConfiguration ) to select the configuration.

iConfiguration is an index to a string descriptor describing the configuration in readable format.

bmAttributes describes the power requirements of the device. If the device is USB bus-powered, then bit D7 is set. If it is self-powered, it sets bit D6. Bit D5 specifies the remote wakeup of the device. Bits D7 and D0–D4 are reserved.

bMaxPower defines the maximum power the device will draw from the bus in 2mA units.

Table 8.7: Configuration descriptor

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Advanced PIC Microcontroller Projects in C»

Представляем Вашему вниманию похожие книги на «Advanced PIC Microcontroller Projects in C» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Advanced PIC Microcontroller Projects in C»

Обсуждение, отзывы о книге «Advanced PIC Microcontroller Projects in C» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x