Skip to content

Commit 2e7ad10

Browse files
mathieuchopstmcfriedt
authored andcommitted
drivers: usb: udc: stm32: use addr_before_status capability
Instead of snooping SETUP packets for SET_ADDRESS request to call the HAL SetAddress() function manually, mark device with the addr_before_status capability such that the UDC stack will call udc_stm32_set_address() before submitting status by itself. Signed-off-by: Mathieu Choplain <[email protected]>
1 parent 7a593ed commit 2e7ad10

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/usb/udc/udc_stm32.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ static void handle_msg_setup(struct udc_stm32_data *priv)
609609
{
610610
struct usb_setup_packet *setup = (void *)priv->pcd.Setup;
611611
const struct device *dev = priv->dev;
612-
HAL_StatusTypeDef status;
613612
struct net_buf *buf;
614613
int err;
615614

@@ -635,15 +634,6 @@ static void handle_msg_setup(struct udc_stm32_data *priv)
635634

636635
udc_ctrl_update_stage(dev, buf);
637636

638-
if ((setup->bmRequestType == 0) && (setup->bRequest == USB_SREQ_SET_ADDRESS)) {
639-
/* HAL requires we set the address before submitting status */
640-
status = HAL_PCD_SetAddress(&priv->pcd, setup->wValue);
641-
if (status != HAL_OK) {
642-
LOG_ERR("HAL_PCD_SetAddress() failed: %d", status);
643-
__ASSERT_NO_MSG(0);
644-
}
645-
}
646-
647637
if (udc_ctrl_stage_is_data_out(dev)) {
648638
/* Allocate and feed buffer for data OUT stage */
649639
err = udc_stm32_prep_out_ep0_rx(dev, udc_data_stage_length(buf));
@@ -1544,6 +1534,7 @@ static int udc_stm32_driver_init0(const struct device *dev)
15441534

15451535
data->caps.rwup = true;
15461536
data->caps.out_ack = false;
1537+
data->caps.addr_before_status = true;
15471538
data->caps.mps0 = UDC_MPS0_64;
15481539
if (cfg->selected_speed == PCD_SPEED_HIGH) {
15491540
data->caps.hs = true;

0 commit comments

Comments
 (0)