From 5e3acff8c734ec4413ba12e021089dc6fea1f53e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 30 Aug 2019 01:03:28 -0400 Subject: [PATCH] stm32: No need to clear the usbotg address on reset The controller automatically clears the address. Signed-off-by: Kevin O'Connor --- src/stm32/usbotg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/stm32/usbotg.c b/src/stm32/usbotg.c index 35689afa..99837a09 100644 --- a/src/stm32/usbotg.c +++ b/src/stm32/usbotg.c @@ -245,7 +245,8 @@ usb_stall_ep0(void) void usb_set_address(uint_fast8_t addr) { - OTGD->DCFG |= addr << USB_OTG_DCFG_DAD_Pos; + OTGD->DCFG = ((OTGD->DCFG & ~USB_OTG_DCFG_DAD_Msk) + | (addr << USB_OTG_DCFG_DAD_Pos)); usb_send_ep0(NULL, 0); usb_notify_ep0(); } @@ -312,9 +313,6 @@ usb_reset(void) | (0x02 << USB_OTG_DIEPCTL_EPTYP_Pos) | USB_OTG_DIEPCTL_SD0PID_SEVNFRM | (USB_CDC_EP_BULK_IN << USB_OTG_DIEPCTL_TXFNUM_Pos) | (USB_CDC_EP_BULK_IN_SIZE << USB_OTG_DIEPCTL_MPSIZ_Pos)); - - // Set address to zero - OTGD->DCFG &= ~USB_OTG_DCFG_DAD; } // Handle a USB disconnect