From e46fa4a0b2af4d59669469f2b350e2208ef1fc90 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sat, 15 Apr 2023 12:13:24 +0200 Subject: [PATCH] sys/usbus: use USBDEV_SET_ADDR_AFTER_STATUS Use symbol `USBDEV_SET_ADDR_AFTER_STATUS` to determine whether the device address has to be set directly after SETUP stage or after the associated STATUS stage. --- sys/usb/usbus/usbus_control.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/usb/usbus/usbus_control.c b/sys/usb/usbus/usbus_control.c index 77e5ca4f99..4f669b67d6 100644 --- a/sys/usb/usbus/usbus_control.c +++ b/sys/usb/usbus/usbus_control.c @@ -241,6 +241,10 @@ static int _recv_dev_setup(usbus_t *usbus, usb_setup_t *pkt) case USB_SETUP_REQ_SET_ADDRESS: DEBUG("usbus_control: Setting address\n"); usbus->addr = (uint8_t)pkt->value; + if (!USBDEV_CPU_SET_ADDR_AFTER_STATUS) { + usbdev_set(usbus->dev, USBOPT_ADDRESS, &usbus->addr, + sizeof(usbus->addr)); + } res = 1; break; case USB_SETUP_REQ_SET_CONFIGURATION: @@ -401,8 +405,10 @@ static int _handle_tr_complete(usbus_t *usbus, case USBUS_CONTROL_REQUEST_STATE_INACK: if (ep->dir == USB_EP_DIR_IN) { if (usbus->addr && usbus->state == USBUS_STATE_RESET) { - usbdev_set(usbus->dev, USBOPT_ADDRESS, &usbus->addr, - sizeof(usbus->addr)); + if (USBDEV_CPU_SET_ADDR_AFTER_STATUS) { + usbdev_set(usbus->dev, USBOPT_ADDRESS, &usbus->addr, + sizeof(usbus->addr)); + } /* Address configured */ usbus->state = USBUS_STATE_ADDR; }