| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

usbh_debug.c
Go to the documentation of this file.
1/*
2 * debug.c - USB debug helper routines.
3 *
4 * I just want these out of the way where they aren't in your
5 * face, but so that you can still use them..
6 */
7
8/**************************************************************************/
18#include <stdio.h>
19#include <string.h>
20
21#include "NUC472_442.h"
22#include "usbh_core.h"
23
25
26/*
27 * Parse and show the different USB descriptors.
28 */
29 void usbh_dump_device_descriptor(USB_DEV_DESC_T *desc)
30{
31 if (!desc)
32 {
33 USB_debug("Invalid USB device descriptor (NULL POINTER)\n");
34 return;
35 }
36 USB_debug(" Length = %2d%s\n", desc->bLength,
37 desc->bLength == USB_DT_DEVICE_SIZE ? "" : " (!!!)");
38 USB_debug(" DescriptorType = %02x\n", desc->bDescriptorType);
39 USB_debug(" USB version = %x.%02x\n",
40 desc->bcdUSB >> 8, desc->bcdUSB & 0xff);
41 USB_debug(" Vendor:Product = %04x:%04x\n",
42 desc->idVendor, desc->idProduct);
43 USB_debug(" MaxPacketSize0 = %d\n", desc->bMaxPacketSize0);
44 USB_debug(" NumConfigurations = %d\n", desc->bNumConfigurations);
45 USB_debug(" Device version = %x.%02x\n",
46 desc->bcdDevice >> 8, desc->bcdDevice & 0xff);
47 USB_debug(" Device Class:SubClass:Protocol = %02x:%02x:%02x\n",
48 desc->bDeviceClass, desc->bDeviceSubClass, desc->bDeviceProtocol);
49 switch (desc->bDeviceClass)
50 {
51 case 0:
52 USB_debug(" Per-interface classes\n");
53 break;
54 case USB_CLASS_AUDIO:
55 USB_debug(" Audio device class\n");
56 break;
57 case USB_CLASS_COMM:
58 USB_debug(" Communications class\n");
59 break;
60 case USB_CLASS_HID:
61 USB_debug(" Human Interface Devices class\n");
62 break;
63 case USB_CLASS_PRINTER:
64 USB_debug(" Printer device class\n");
65 break;
66 case USB_CLASS_MASS_STORAGE:
67 USB_debug(" Mass Storage device class\n");
68 break;
69 case USB_CLASS_HUB:
70 USB_debug(" Hub device class\n");
71 break;
72 case USB_CLASS_VENDOR_SPEC:
73 USB_debug(" Vendor class\n");
74 break;
75 default:
76 USB_debug(" Unknown class\n");
77 }
78}
79
80
81
82 void usbh_dump_config_descriptor(USB_CONFIG_DESC_T *desc)
83{
84 USB_debug("Configuration:\n");
85 USB_debug(" bLength = %4d%s\n", desc->bLength,
86 desc->bLength == USB_DT_CONFIG_SIZE ? "" : " (!!!)");
87 USB_debug(" bDescriptorType = %02x\n", desc->bDescriptorType);
88 USB_debug(" wTotalLength = %04x\n", desc->wTotalLength);
89 USB_debug(" bNumInterfaces = %02x\n", desc->bNumInterfaces);
90 USB_debug(" bConfigurationValue = %02x\n", desc->bConfigurationValue);
91 USB_debug(" iConfiguration = %02x\n", desc->iConfiguration);
92 USB_debug(" bmAttributes = %02x\n", desc->bmAttributes);
93 USB_debug(" MaxPower = %4dmA\n", desc->MaxPower * 2);
94}
95
96
97
98 void usbh_dump_iface_descriptor(USB_IF_DESC_T *desc)
99{
100 USB_debug(" Interface: %d\n", desc->bInterfaceNumber);
101 USB_debug(" Alternate Setting: %2d\n", desc->bAlternateSetting);
102 USB_debug(" bLength = %4d%s\n", desc->bLength,
103 desc->bLength == USB_DT_INTERFACE_SIZE ? "" : " (!!!)");
104 USB_debug(" bDescriptorType = %02x\n", desc->bDescriptorType);
105 USB_debug(" bInterfaceNumber = %02x\n", desc->bInterfaceNumber);
106 USB_debug(" bAlternateSetting = %02x\n", desc->bAlternateSetting);
107 USB_debug(" bNumEndpoints = %02x\n", desc->bNumEndpoints);
108 USB_debug(" bInterface Class:SubClass:Protocol = %02x:%02x:%02x\n",
109 desc->bInterfaceClass, desc->bInterfaceSubClass, desc->bInterfaceProtocol);
110 USB_debug(" iInterface = %02x\n", desc->iInterface);
111}
112
113
114
115 void usbh_dump_ep_descriptor(USB_EP_DESC_T *desc)
116{
117#ifdef USB_DEBUG
118 char *LengthCommentString = (desc->bLength ==
119 USB_DT_ENDPOINT_AUDIO_SIZE) ? " (Audio)" : (desc->bLength ==
120 USB_DT_ENDPOINT_SIZE) ? "" : " (!!!)";
121 char *EndpointType[4] = { "Control", "Isochronous", "Bulk", "Interrupt" };
122
123 USB_debug(" Endpoint:\n");
124 USB_debug(" bLength = %4d%s\n",
125 desc->bLength, LengthCommentString);
126 USB_debug(" bDescriptorType = %02x\n", desc->bDescriptorType);
127 USB_debug(" bEndpointAddress = %02x (%s)\n", desc->bEndpointAddress,
128 (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
129 USB_ENDPOINT_XFER_CONTROL ? "i/o" :
130 (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? "in" : "out");
131 USB_debug(" bmAttributes = %02x (%s)\n", desc->bmAttributes,
132 EndpointType[USB_ENDPOINT_XFERTYPE_MASK & desc->bmAttributes]);
133 USB_debug(" wMaxPacketSize = %04x\n", desc->wMaxPacketSize);
134 USB_debug(" bInterval = %02x\n", desc->bInterval);
135
136 /* Audio extensions to the endpoint descriptor */
137 if (desc->bLength == USB_DT_ENDPOINT_AUDIO_SIZE)
138 {
139 USB_debug(" bRefresh = %02x\n", desc->bRefresh);
140 USB_debug(" bSynchAddress = %02x\n", desc->bSynchAddress);
141 }
142#endif
143}
144
145
146
147 void usbh_print_usb_string(USB_DEV_T *dev, char *id, int index)
148{
149 char buf[256];
150
151 if (!index)
152 return;
153 if (usbh_translate_string(dev, index, buf, 256) > 0)
154 USB_debug("%s: %s\n", id, buf);
155}
156
157
158
159 void usbh_dump_urb(URB_T *purb)
160{
161 USB_debug ("urb :0x%x\n", (int)purb);
162 USB_debug ("next :0x%x\n", (int)purb->next);
163 USB_debug ("dev :0x%x\n", (int)purb->dev);
164 USB_debug ("pipe :0x%08x\n", purb->pipe);
165 USB_debug ("status :%d\n", purb->status);
166 USB_debug ("transfer_flags :0x%08x\n", purb->transfer_flags);
167 USB_debug ("transfer_buffer :0x%x\n", (int)purb->transfer_buffer);
168 USB_debug ("transfer_buffer_length:%d\n", purb->transfer_buffer_length);
169 USB_debug ("actual_length :%d\n", purb->actual_length);
170 USB_debug ("setup_packet :0x%x\n", (int)purb->setup_packet);
171 USB_debug ("start_frame :%d\n", purb->start_frame);
172 USB_debug ("number_of_packets :%d\n", purb->number_of_packets);
173 USB_debug ("interval :%d\n", purb->interval);
174 USB_debug ("error_count :%d\n", purb->error_count);
175 USB_debug ("complete :0x%x\n", (int)purb->complete);
176}
177
179
180
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
urb_t::setup_packet
uint8_t * setup_packet
Definition: usbh_core.h:548
urb_t::status
int status
Definition: usbh_core.h:543
urb_t::transfer_buffer
void * transfer_buffer
Definition: usbh_core.h:545
urb_t::start_frame
int start_frame
Definition: usbh_core.h:549
urb_t::actual_length
int actual_length
Definition: usbh_core.h:547
urb_t::transfer_buffer_length
int transfer_buffer_length
Definition: usbh_core.h:546
urb_t::pipe
uint32_t pipe
Definition: usbh_core.h:542
urb_t::dev
struct usb_device * dev
Definition: usbh_core.h:541
urb_t::number_of_packets
int number_of_packets
Definition: usbh_core.h:550
urb_t::transfer_flags
uint32_t transfer_flags
Definition: usbh_core.h:544
urb_t::error_count
int error_count
Definition: usbh_core.h:552
urb_t::next
struct urb_t * next
Definition: usbh_core.h:540
urb_t::complete
void(* complete)(struct urb_t *)
Definition: usbh_core.h:555
urb_t::interval
int interval
Definition: usbh_core.h:551
USB_IF_DESC_T
USB_IF_DESC_T
Definition: usbh_core.h:335
USB_CONFIG_DESC_T
USB_CONFIG_DESC_T
Definition: usbh_core.h:366
USB_DEV_DESC_T
USB_DEV_DESC_T
Definition: usbh_core.h:270
USB_DEV_T
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
USB_EP_DESC_T
USB_EP_DESC_T
Definition: usbh_core.h:300
urb_t
Definition: usbh_core.h:537
usbh_core.h
USB Host core driver header file.