Board logo

标题: libusb在arm上的编译(2) [打印本页]

作者: yuyang911220    时间: 2014-9-26 21:06     标题: libusb在arm上的编译(2)

#include <stdio.h>
#include
<stdlib.h>
#include
<usb.h>
void print_endpoint(struct usb_endpoint_descriptor *endpoint)
{
printf(
" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
printf(
" bmAttributes: %02xh\n", endpoint->bmAttributes);
printf(
" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize);
printf(
" bInterval: %d\n", endpoint->bInterval);
printf(
" bRefresh: %d\n", endpoint->bRefresh);
printf(
" bSynchAddress: %d\n", endpoint->bSynchAddress);
}


void print_altsetting(struct usb_interface_descriptor *interface)
{
int i;

printf(
" bInterfaceNumber: %d\n", interface->bInterfaceNumber);
printf(
" bAlternateSetting: %d\n", interface->bAlternateSetting);
printf(
" bNumEndpoints: %d\n", interface->bNumEndpoints);
printf(
" bInterfaceClass: %d\n", interface->bInterfaceClass);
printf(
" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass);
printf(
" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol);
printf(
" iInterface: %d\n", interface->iInterface);

for (i =
0; i <
interface->bNumEndpoints; i++)
print_endpoint(
&interface->endpoint);
}


void print_interface(struct usb_interface *interface)
{
int i;

for (i =
0; i <
interface->num_altsetting; i++)
print_altsetting(
&interface->altsetting);
}


void print_configuration(struct usb_config_descriptor *config)
{
int i;

printf(
" wTotalLength: %d\n", config->wTotalLength);
printf(
" bNumInterfaces: %d\n", config->bNumInterfaces);
printf(
" bConfigurationValue: %d\n", config->bConfigurationValue);
printf(
" iConfiguration: %d\n", config->iConfiguration);
printf(
" bmAttributes: %02xh\n", config->bmAttributes);
printf(
" MaxPower: %d\n", config->MaxPower);

for (i =
0; i < config->bNumInterfaces; i++)
print_interface(
&config->interface);
}





欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0