From 726ea3c8a99d51a178bb73224347f7c2ea4d2b47 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 8 Sep 2019 06:50:47 -0600 Subject: [PATCH] stm32f7/h7/l4 OTG host: Adam porters fix for STM32 FS/HS probably should be applied to STM32 F7, H7, and L4 OTG host which are very similar. --- arch/arm/src/stm32f7/stm32_otghost.c | 5 ++++- arch/arm/src/stm32h7/stm32_otghost.c | 5 ++++- arch/arm/src/stm32l4/stm32l4_otgfshost.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c index 20e308849b..dd9992420d 100644 --- a/arch/arm/src/stm32f7/stm32_otghost.c +++ b/arch/arm/src/stm32f7/stm32_otghost.c @@ -2200,6 +2200,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) @@ -2208,8 +2209,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 @@ -2286,6 +2288,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/stm32h7/stm32_otghost.c b/arch/arm/src/stm32h7/stm32_otghost.c index 3f20583560..d7851eea0f 100644 --- a/arch/arm/src/stm32h7/stm32_otghost.c +++ b/arch/arm/src/stm32h7/stm32_otghost.c @@ -2205,6 +2205,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) @@ -2213,8 +2214,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 @@ -2291,6 +2293,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/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c index 25fb207186..719a44085c 100644 --- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c +++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c @@ -2205,6 +2205,7 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, 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) @@ -2213,8 +2214,9 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, 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 @@ -2291,6 +2293,7 @@ static ssize_t stm32l4_out_transfer(FAR struct stm32l4_usbhost_s *priv, buffer += xfrlen; buflen -= xfrlen; xfrd += chan->xfrd; + zlp = false; } }