Skip to content

Commit 1813f81

Browse files
JulienBernard3383279kilograham
authored andcommitted
Respond to other OUT control requests with a ZLP
1 parent 6c6881a commit 1813f81

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

usb/device/dev_lowlevel/dev_lowlevel.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ void usb_handle_string_descriptor(volatile struct usb_setup_packet *pkt) {
340340
usb_start_transfer(usb_get_endpoint_configuration(EP0_IN_ADDR), &ep0_buf[0], len);
341341
}
342342

343+
/**
344+
* @brief Sends a zero length status packet back to the host.
345+
*/
346+
void usb_acknowledge_out_request(void) {
347+
usb_start_transfer(usb_get_endpoint_configuration(EP0_IN_ADDR), NULL, 0);
348+
}
349+
343350
/**
344351
* @brief Handles a SET_ADDR request from the host. The actual setting of the device address in
345352
* hardware is done in ep0_in_handler. This is because we have to acknowledge the request first
@@ -354,7 +361,7 @@ void usb_set_device_address(volatile struct usb_setup_packet *pkt) {
354361
printf("Set address %d\r\n", dev_addr);
355362
// Will set address in the callback phase
356363
should_set_address = true;
357-
usb_start_transfer(usb_get_endpoint_configuration(EP0_IN_ADDR), NULL, 0);
364+
usb_acknowledge_out_request();
358365
}
359366

360367
/**
@@ -366,7 +373,7 @@ void usb_set_device_address(volatile struct usb_setup_packet *pkt) {
366373
void usb_set_device_configuration(volatile struct usb_setup_packet *pkt) {
367374
// Only one configuration so just acknowledge the request
368375
printf("Device Enumerated\r\n");
369-
usb_start_transfer(usb_get_endpoint_configuration(EP0_IN_ADDR), NULL, 0);
376+
usb_acknowledge_out_request();
370377
configured = true;
371378
}
372379

@@ -388,6 +395,7 @@ void usb_handle_setup_packet(void) {
388395
} else if (req == USB_REQUEST_SET_CONFIGURATION) {
389396
usb_set_device_configuration(pkt);
390397
} else {
398+
usb_acknowledge_out_request();
391399
printf("Other OUT request (0x%x)\r\n", pkt->bRequest);
392400
}
393401
} else if (req_direction == USB_DIR_IN) {

0 commit comments

Comments
 (0)