From 9d7301f47408b2d663c8551c0501d6094a807357 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 15 Aug 2015 10:41:15 -0600 Subject: [PATCH] SAMV7 USBHS device: Need to enable endpoint before configuring it; Check for USB suspended backward --- arch/arm/src/samv7/sam_usbdevhs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c index d1965a532f..c40932f75c 100644 --- a/arch/arm/src/samv7/sam_usbdevhs.c +++ b/arch/arm/src/samv7/sam_usbdevhs.c @@ -3081,7 +3081,7 @@ static void sam_ep_reset(struct sam_usbdev_s *priv, uint8_t epno) sam_putreg(USBHS_DEVINT_PEP(epno), SAM_USBHS_DEVIDR); - /* Cancel any queued requests. Since they are canceled with status + /* Cancel any queued requests. Since they are cancelled with status * -ESHUTDOWN, then will not be requeued until the configuration is reset. * NOTE: This should not be necessary... the CLASS_DISCONNECT above * should result in the class implementation calling sam_ep_disable @@ -3326,9 +3326,15 @@ static int sam_ep_configure_internal(struct sam_ep_s *privep, if (eptype == USB_EP_ATTR_XFER_CONTROL) { - sam_putreg(USBHS_DEVINT_PEP(epno), SAM_USBHS_DEVIDR); + sam_putreg(USBHS_DEVINT_PEP(epno), SAM_USBHS_DEVIDR); } + /* Enable the endpoint */ + + regval = sam_getreg(SAM_USBHS_DEVEPT); + regval |= USBHS_DEVEPT_EPEN(epno); + sam_putreg(regval, SAM_USBHS_DEVEPT); + /* Configure the endpoint */ regval = USBHS_DEVEPTCFG_ALLOC | @@ -3411,12 +3417,6 @@ static int sam_ep_configure_internal(struct sam_ep_s *privep, sam_putreg(regval, SAM_USBHS_DEVEPTIER(epno)); } - /* Enable the endpoint */ - - regval = sam_getreg(SAM_USBHS_DEVEPT); - regval |= USBHS_DEVEPT_EPEN(epno); - sam_putreg(regval, SAM_USBHS_DEVEPT); - /* If this is EP0, enable interrupts now */ if (eptype == USB_EP_ATTR_XFER_CONTROL) @@ -4180,7 +4180,7 @@ static int sam_pullup(FAR struct usbdev_s *dev, bool enable) */ regval = sam_getreg(SAM_USBHS_DEVISR); - if ((regval & USBHS_DEVINT_SUSPD) != 0) + if ((regval & USBHS_DEVINT_SUSPD) == 0) { /* If the USBHS detects activity on the BUS, then it will not be * suspended. In that case, next event that we expect to see is a @@ -4319,7 +4319,7 @@ static void sam_reset(struct sam_usbdev_s *priv) priv->devstate = USBHS_DEVSTATE_DEFAULT; - /* Reset and disable all endpoints other. Then re-configure EP0 */ + /* Reset and disable all endpoints. Then re-configure EP0 */ sam_epset_reset(priv, SAM_EPSET_ALL); sam_ep0_configure(priv);