@@ -24,6 +24,7 @@ LOG_MODULE_REGISTER(usbh_shell, CONFIG_USBH_LOG_LEVEL);
24
24
USBH_CONTROLLER_DEFINE (uhs_ctx , DEVICE_DT_GET (DT_NODELABEL (zephyr_uhc0 )));
25
25
static struct usb_device * udev ;
26
26
const static struct shell * ctx_shell ;
27
+ static uint8_t vreq_test_buf [1024 ];
27
28
28
29
static void print_dev_desc (const struct shell * sh ,
29
30
const struct usb_device_descriptor * const desc )
@@ -57,123 +58,6 @@ static void print_cfg_desc(const struct shell *sh,
57
58
shell_print (sh , "bMaxPower\t\t%u mA" , desc -> bMaxPower * 2 );
58
59
}
59
60
60
- static void print_desc (const struct shell * sh , const struct net_buf * const buf )
61
- {
62
- struct usb_desc_header * head = (void * )buf -> data ;
63
-
64
- if (buf -> len < sizeof (struct usb_desc_header )) {
65
- return ;
66
- }
67
-
68
- switch (head -> bDescriptorType ) {
69
- case USB_DESC_DEVICE : {
70
- struct usb_device_descriptor * desc = (void * )buf -> data ;
71
-
72
- if (buf -> len < sizeof (struct usb_device_descriptor )) {
73
- shell_hexdump (ctx_shell , buf -> data , buf -> len );
74
- break ;
75
- }
76
-
77
- desc -> bcdUSB = sys_le16_to_cpu (desc -> bcdUSB );
78
- desc -> idVendor = sys_le16_to_cpu (desc -> idVendor );
79
- desc -> idProduct = sys_le16_to_cpu (desc -> idProduct );
80
- desc -> bcdDevice = sys_le16_to_cpu (desc -> bcdDevice );
81
- print_dev_desc (sh , desc );
82
- break ;
83
- }
84
- case USB_DESC_CONFIGURATION : {
85
- struct usb_cfg_descriptor * desc = (void * )buf -> data ;
86
-
87
- if (buf -> len < sizeof (struct usb_cfg_descriptor )) {
88
- shell_hexdump (ctx_shell , buf -> data , buf -> len );
89
- break ;
90
- }
91
-
92
- desc -> wTotalLength = sys_le16_to_cpu (desc -> wTotalLength );
93
- print_cfg_desc (sh , desc );
94
- break ;
95
- }
96
- default :
97
- shell_hexdump (ctx_shell , buf -> data , buf -> len );
98
- break ;
99
- }
100
- }
101
-
102
- static int bazfoo_request (struct usbh_contex * const ctx ,
103
- struct uhc_transfer * const xfer ,
104
- int err )
105
- {
106
- const struct device * dev = ctx -> dev ;
107
-
108
- shell_info (ctx_shell , "host: transfer finished %p, err %d" , xfer , err );
109
-
110
- if (xfer -> buf ) {
111
- /*
112
- * FIXME: We don not distinguish the context
113
- * of the request and always try to print it
114
- * as descriptor first. If it is not a known descriptor,
115
- * we show a hexdump in any case.
116
- * This is just simple enough for first steps and will
117
- * be revised with coming peripheral device management.
118
- */
119
- if (xfer -> ep == USB_CONTROL_EP_IN ) {
120
- print_desc (ctx_shell , xfer -> buf );
121
- } else {
122
- shell_hexdump (ctx_shell , xfer -> buf -> data , xfer -> buf -> len );
123
- }
124
-
125
- uhc_xfer_buf_free (dev , xfer -> buf );
126
- }
127
-
128
- return uhc_xfer_free (dev , xfer );
129
- }
130
-
131
- static int bazfoo_connected (struct usbh_contex * const ctx )
132
- {
133
- shell_info (ctx_shell , "host: USB device connected" );
134
-
135
- return 0 ;
136
- }
137
-
138
- static int bazfoo_removed (struct usbh_contex * const ctx )
139
- {
140
- shell_info (ctx_shell , "host: USB device removed" );
141
-
142
- return 0 ;
143
- }
144
-
145
- static int bazfoo_rwup (struct usbh_contex * const ctx )
146
- {
147
- shell_info (ctx_shell , "host: Bus remote wakeup event" );
148
-
149
- return 0 ;
150
- }
151
-
152
- static int bazfoo_suspended (struct usbh_contex * const ctx )
153
- {
154
- shell_info (ctx_shell , "host: Bus suspended" );
155
-
156
- return 0 ;
157
- }
158
-
159
- static int bazfoo_resumed (struct usbh_contex * const ctx )
160
- {
161
- shell_info (ctx_shell , "host: Bus resumed" );
162
-
163
- return 0 ;
164
- }
165
-
166
- USBH_DEFINE_CLASS (bazfoo ) = {
167
- .request = bazfoo_request ,
168
- .connected = bazfoo_connected ,
169
- .removed = bazfoo_removed ,
170
- .rwup = bazfoo_rwup ,
171
- .suspended = bazfoo_suspended ,
172
- .resumed = bazfoo_resumed ,
173
- };
174
-
175
- static uint8_t vreq_test_buf [1024 ];
176
-
177
61
static int cmd_bulk (const struct shell * sh , size_t argc , char * * argv )
178
62
{
179
63
struct uhc_transfer * xfer ;
0 commit comments