STM32 OTG FS host driver: Fix some bad NAK handling

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5049 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-08-23 21:13:24 +00:00
parent 73220bb854
commit 1dff49d24f
1 changed files with 21 additions and 8 deletions

View File

@ -1538,11 +1538,12 @@ static inline void stm32_gint_hcinisr(FAR struct stm32_usbhost_s *priv,
/* Set the request I/O error result */
chan->result = EIO;
}
else /* if (chan->chreason == CHREASON_FRMOR) */
else if (chan->chreason == CHREASON_NAK)
{
/* Fetch the HCCHAR register and check for an interrupt endpoint. */
/* Halt on NAK only happens on an INTR channel. Fetch the HCCHAR register
* and check for an interrupt endpoint.
*/
regval = stm32_getreg(STM32_OTGFS_HCCHAR(chidx));
if ((regval & OTGFS_HCCHAR_EPTYP_MASK) == OTGFS_HCCHAR_EPTYP_INTR)
@ -1552,6 +1553,12 @@ static inline void stm32_gint_hcinisr(FAR struct stm32_usbhost_s *priv,
chan->indata1 ^= true;
}
/* Set the NAK error result */
chan->result = EAGAIN;
}
else /* if (chan->chreason == CHREASON_FRMOR) */
{
/* Set the frame overrun error result */
chan->result = EPIPE;
@ -1581,9 +1588,19 @@ static inline void stm32_gint_hcinisr(FAR struct stm32_usbhost_s *priv,
else if ((pending & OTGFS_HCINT_NAK) != 0)
{
/* Halt the interrupt channel */
if (chan->eptype == OTGFS_EPTYPE_CTRL)
{
/* Halt the channel -- the CHH interrrupt is expected next */
stm32_chan_halt(priv, chidx, CHREASON_NAK);
}
/* Re-activate CTRL and BULK channels */
if (chan->eptype == OTGFS_EPTYPE_CTRL || chan->eptype == OTGFS_EPTYPE_BULK)
else if (chan->eptype == OTGFS_EPTYPE_CTRL ||
chan->eptype == OTGFS_EPTYPE_BULK)
{
/* Re-activate the channel by clearing CHDIS and assuring that
* CHENA is set
@ -1595,10 +1612,6 @@ static inline void stm32_gint_hcinisr(FAR struct stm32_usbhost_s *priv,
stm32_putreg(STM32_OTGFS_HCCHAR(chidx), regval);
}
/* Halt the channel -- the CHH interrrupt is expected next */
stm32_chan_halt(priv, chidx, CHREASON_NAK);
/* Clear the NAK condition */
stm32_putreg(STM32_OTGFS_HCINT(chidx), OTGFS_HCINT_NAK);