diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-07-08 08:55:05 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-07-08 08:55:05 -0600 |
commit | 8cf1b3f58d8f4150dc576b626740b9435a9a06b6 (patch) | |
tree | 217772cc29cc9af4f587aceaf57dac55e7126dca | |
parent | ffcf112bf7e2cd4060b5370ce7c77b2d6bc07f71 (diff) | |
download | nuttx-8cf1b3f58d8f4150dc576b626740b9435a9a06b6.tar.gz nuttx-8cf1b3f58d8f4150dc576b626740b9435a9a06b6.tar.bz2 nuttx-8cf1b3f58d8f4150dc576b626740b9435a9a06b6.zip |
Ticket #16: STM32 OTG FS device driver endpoint allocation. From Chia Cheng Tsao
-rw-r--r-- | nuttx/ChangeLog | 5 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_otgfsdev.c | 22 |
2 files changed, 18 insertions, 9 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 470f72fe6..8a94f7b76 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5115,4 +5115,7 @@ against re-entrancy (2013-7-5). * libc/misc/lib_crc16.c and include/crc16.h: Add CRC16 support (2013-7-7). - + * arch/arm/src/stm32/stm32_otgfsdev.c: SourceForge bug #16: Fix + endpoint allocation logic. The same endpoint can be allocated as + an IN or an OUT endpoint. The implementation only support one + allocation, either IN or OUT (From Chia Cheng Tsao, 2013-7-8). diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c index b8033fdd5..04806e70e 100644 --- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c +++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c @@ -1,5 +1,5 @@ /******************************************************************************* - * arch/arm/src/stm32/stm32_usbdev.c + * arch/arm/src/stm32/stm32_otgfsdev.c * * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -434,7 +434,7 @@ struct stm32_usbdev_s uint8_t devstate:4; /* See enum stm32_devstate_e */ uint8_t ep0state:4; /* See enum stm32_ep0state_e */ uint8_t testmode:4; /* Selected test mode */ - uint8_t epavail:4; /* Bitset of available endpoints */ + uint8_t epavail[2]; /* Bitset of available OUT/IN endpoints */ /* E0 SETUP data buffering. * @@ -1964,7 +1964,11 @@ static void stm32_usbreset(struct stm32_usbdev_s *priv) { CLASS_DISCONNECT(priv->driver, &priv->usbdev); } - priv->epavail = STM32_EP_AVAILABLE; + + /* Mark all endpoints as available */ + + priv->epavail[0] = STM32_EP_AVAILABLE; + priv->epavail[1] = STM32_EP_AVAILABLE; /* Disable all end point interrupts */ @@ -4705,10 +4709,10 @@ static FAR struct usbdev_ep_s *stm32_ep_alloc(FAR struct usbdev_s *dev, epphy = USB_EPNO(eplog); - /* Get the set of available endpoints */ + /* Get the set of available endpoints depending on the direction */ flags = irqsave(); - epavail = priv->epavail; + epavail = priv->epavail[in]; /* A physical address of 0 means that any endpoint will do */ @@ -4749,7 +4753,7 @@ static FAR struct usbdev_ep_s *stm32_ep_alloc(FAR struct usbdev_s *dev, { /* Mark the endpoint no longer available */ - priv->epavail &= ~(1 << epno); + priv->epavail[in] &= ~(1 << epno); /* And return the pointer to the standard endpoint structure */ @@ -4787,7 +4791,7 @@ static void stm32_ep_free(FAR struct usbdev_s *dev, FAR struct usbdev_ep_s *ep) /* Mark the endpoint as available */ flags = irqsave(); - priv->epavail |= (1 << privep->epphy); + priv->epavail[privep->isin] |= (1 << privep->epphy); irqrestore(flags); } } @@ -5049,7 +5053,9 @@ static void stm32_swinitialize(FAR struct stm32_usbdev_s *priv) priv->usbdev.ops = &g_devops; priv->usbdev.ep0 = &priv->epin[EP0].ep; - priv->epavail = STM32_EP_AVAILABLE; + + priv->epavail[0] = STM32_EP_AVAILABLE; + priv->epavail[1] = STM32_EP_AVAILABLE; priv->epin[EP0].ep.priv = priv; priv->epout[EP0].ep.priv = priv; |