summaryrefslogtreecommitdiff
path: root/nuttx/arch/mips/src/pic32mx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-05-28 13:36:01 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-05-28 13:36:01 -0600
commit1a74256ee53b36e73f0d2afa4d9e8b7199be2a10 (patch)
treed2aefd57856c849d84f214bdc9c139cb4f9b484f /nuttx/arch/mips/src/pic32mx
parent0e779830120932500dee6b192b553562b6958a9b (diff)
downloadpx4-nuttx-1a74256ee53b36e73f0d2afa4d9e8b7199be2a10.tar.gz
px4-nuttx-1a74256ee53b36e73f0d2afa4d9e8b7199be2a10.tar.bz2
px4-nuttx-1a74256ee53b36e73f0d2afa4d9e8b7199be2a10.zip
Fix null packet handling in the PIC32 USB device driver. This is a critical bug fix for PIC32. Add support for the USB monitor to the Sure-PIC32MX configuration
Diffstat (limited to 'nuttx/arch/mips/src/pic32mx')
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
index c82470be2..ed90edac3 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
@@ -1154,7 +1154,7 @@ static int pic32mx_wrstart(struct pic32mx_usbdev_s *priv,
/* Even if the request is incomplete, transfer of all the requested
* bytes may already been started. NOTE: inflight[1] should be zero
- * because we know that there is a BDT availalbe.
+ * because we know that there is a BDT available.
*/
#ifdef CONFIG_USBDEV_NOWRITEAHEAD
@@ -1169,10 +1169,20 @@ static int pic32mx_wrstart(struct pic32mx_usbdev_s *priv,
xfrd += privreq->inflight[0];
bytesleft -= privreq->inflight[0];
}
+
+ /* Do we need to send a null packet after this packet? */
+
+ else if (privep->txnullpkt)
+ {
+ /* Yes... set up for the NULL packet transfer */
+
+ xfrd = privreq->req.len;
+ bytesleft = 0;
+ }
else
{
- /* Yes.. we need to get the next request from the head of the
- * pending request list.
+ /* No.. We are finished with this request. We need to get the
+ * next request from the head of the pending request list.
*/
privreq = NULL;
@@ -1220,7 +1230,7 @@ static int pic32mx_wrstart(struct pic32mx_usbdev_s *priv,
/* Get the number of bytes left to be sent in the packet */
nbytes = bytesleft;
- if (nbytes > 0)
+ if (nbytes > 0 || privep->txnullpkt)
{
/* Either send the maxpacketsize or all of the remaining data in
* the request.