From 5b4516d291aacd339375068b8a4d1ee85a6b41fe Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 8 Sep 2019 06:46:54 -0600 Subject: [PATCH] arch/arm/src/stm32/stm32_otg[fs|hs]host.c: STM32 host only initiates transfer if buflenl > 0. --- arch/arm/src/stm32/stm32_otgfshost.c | 5 ++++- arch/arm/src/stm32/stm32_otghshost.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c index 4fd3f2621f..0a89967ba8 100644 --- a/arch/arm/src/stm32/stm32_otgfshost.c +++ b/arch/arm/src/stm32/stm32_otgfshost.c @@ -2201,6 +2201,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, size_t xfrlen; ssize_t xfrd; int ret; + bool zlp; /* Loop until the transfer completes (i.e., buflen is decremented to zero) * or a fatal error occurs (any error other than a simple NAK) @@ -2209,8 +2210,9 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, chan = &priv->chan[chidx]; start = clock_systimer(); xfrd = 0; + zlp = (buflen == 0); - while (buflen > 0) + while (buflen > 0 || zlp) { /* Transfer one packet at a time. The hardware is capable of queueing * multiple OUT packets, but I just haven't figured out how to handle @@ -2287,6 +2289,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } } diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c index 22e24ac646..3b83d2cf80 100644 --- a/arch/arm/src/stm32/stm32_otghshost.c +++ b/arch/arm/src/stm32/stm32_otghshost.c @@ -2206,6 +2206,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, size_t xfrlen; ssize_t xfrd; int ret; + bool zlp; /* Loop until the transfer completes (i.e., buflen is decremented to zero) * or a fatal error occurs (any error other than a simple NAK) @@ -2214,9 +2215,11 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, chan = &priv->chan[chidx]; start = clock_systimer(); xfrd = 0; + zlp = (buflen == 0); - while (buflen > 0) + while (buflen > 0 || zlp) { + /* Transfer one packet at a time. The hardware is capable of queueing * multiple OUT packets, but I just haven't figured out how to handle * the case where a single OUT packet in the group is NAKed. @@ -2292,6 +2295,7 @@ static ssize_t stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } }