mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
A little more work (but not much progress) on the PIC32 USB device driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4440 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -118,7 +118,7 @@
|
|||||||
|
|
||||||
/* Endpoint Definitions */
|
/* Endpoint Definitions */
|
||||||
|
|
||||||
#ifndef CONFIG_USB_PINGPONG
|
#ifndef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
# define USB_NEXT_PINGPONG (0)
|
# define USB_NEXT_PINGPONG (0)
|
||||||
# define EP0_OUT_EVEN (0)
|
# define EP0_OUT_EVEN (0)
|
||||||
# define EP0_OUT_ODD (0)
|
# define EP0_OUT_ODD (0)
|
||||||
@@ -221,20 +221,21 @@
|
|||||||
#define PIC32MX_TRACEINTID_GETSTATUS 0x0013
|
#define PIC32MX_TRACEINTID_GETSTATUS 0x0013
|
||||||
#define PIC32MX_TRACEINTID_IFGETSTATUS 0x0014
|
#define PIC32MX_TRACEINTID_IFGETSTATUS 0x0014
|
||||||
#define PIC32MX_TRACEINTID_TRNC 0x0015
|
#define PIC32MX_TRACEINTID_TRNC 0x0015
|
||||||
#define PIC32MX_TRACEINTID_INTERRUPT 0x0016
|
#define PIC32MX_TRACEINTID_TRNCS 0x0016
|
||||||
#define PIC32MX_TRACEINTID_NOSTDREQ 0x0017
|
#define PIC32MX_TRACEINTID_INTERRUPT 0x0017
|
||||||
#define PIC32MX_TRACEINTID_RESET 0x0018
|
#define PIC32MX_TRACEINTID_NOSTDREQ 0x0018
|
||||||
#define PIC32MX_TRACEINTID_SETCONFIG 0x0019
|
#define PIC32MX_TRACEINTID_RESET 0x0019
|
||||||
#define PIC32MX_TRACEINTID_SETFEATURE 0x001a
|
#define PIC32MX_TRACEINTID_SETCONFIG 0x001a
|
||||||
#define PIC32MX_TRACEINTID_IDLE 0x001b
|
#define PIC32MX_TRACEINTID_SETFEATURE 0x001b
|
||||||
#define PIC32MX_TRACEINTID_SYNCHFRAME 0x001c
|
#define PIC32MX_TRACEINTID_IDLE 0x001c
|
||||||
#define PIC32MX_TRACEINTID_WKUP 0x001d
|
#define PIC32MX_TRACEINTID_SYNCHFRAME 0x001d
|
||||||
#define PIC32MX_TRACEINTID_T1MSEC 0x001e
|
#define PIC32MX_TRACEINTID_WKUP 0x001e
|
||||||
#define PIC32MX_TRACEINTID_OTGID 0x001f
|
#define PIC32MX_TRACEINTID_T1MSEC 0x001f
|
||||||
#define PIC32MX_TRACEINTID_STALL 0x0020
|
#define PIC32MX_TRACEINTID_OTGID 0x0020
|
||||||
#define PIC32MX_TRACEINTID_UERR 0x0021
|
#define PIC32MX_TRACEINTID_STALL 0x0021
|
||||||
#define PIC32MX_TRACEINTID_SUSPENDED 0x0022
|
#define PIC32MX_TRACEINTID_UERR 0x0022
|
||||||
#define PIC32MX_TRACEINTID_WAITRESET 0x0023
|
#define PIC32MX_TRACEINTID_SUSPENDED 0x0023
|
||||||
|
#define PIC32MX_TRACEINTID_WAITRESET 0x0024
|
||||||
|
|
||||||
/* Misc Helper Macros *******************************************************/
|
/* Misc Helper Macros *******************************************************/
|
||||||
|
|
||||||
@@ -351,20 +352,17 @@ struct pic32mx_ep_s
|
|||||||
* to struct pic32mx_ep_s.
|
* to struct pic32mx_ep_s.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct usbdev_ep_s ep; /* Standard endpoint structure */
|
struct usbdev_ep_s ep; /* Standard endpoint structure */
|
||||||
|
|
||||||
/* PIC32MX-specific fields */
|
/* PIC32MX-specific fields */
|
||||||
|
|
||||||
struct pic32mx_usbdev_s *dev; /* Reference to private driver data */
|
struct pic32mx_usbdev_s *dev; /* Reference to private driver data */
|
||||||
struct pic32mx_req_s *head; /* Request list for this endpoint */
|
struct pic32mx_req_s *head; /* Request list for this endpoint */
|
||||||
struct pic32mx_req_s *tail;
|
struct pic32mx_req_s *tail;
|
||||||
uint8_t stalled:1; /* true: Endpoint is stalled */
|
uint8_t stalled:1; /* true: Endpoint is stalled */
|
||||||
uint8_t halted:1; /* true: Endpoint feature halted */
|
uint8_t halted:1; /* true: Endpoint feature halted */
|
||||||
uint8_t txbusy:1; /* true: TX endpoint FIFO full */
|
uint8_t txbusy:1; /* true: TX endpoint FIFO full */
|
||||||
uint8_t txnullpkt:1; /* Null packet needed at end of transfer */
|
uint8_t txnullpkt:1; /* Null packet needed at end of transfer */
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
|
||||||
uint8_t ep0ready:1 /* EP0 OUT already prepared */
|
|
||||||
#endif
|
|
||||||
volatile struct usbotg_bdtentry_s *bdtin; /* BDT entry for the IN transaction*/
|
volatile struct usbotg_bdtentry_s *bdtin; /* BDT entry for the IN transaction*/
|
||||||
volatile struct usbotg_bdtentry_s *bdtout; /* BDT entry for the OUT transaction */
|
volatile struct usbotg_bdtentry_s *bdtout; /* BDT entry for the OUT transaction */
|
||||||
};
|
};
|
||||||
@@ -389,6 +387,9 @@ struct pic32mx_usbdev_s
|
|||||||
uint8_t ctrlstate; /* Control EP state (see enum pic32mx_ctrlstate_e) */
|
uint8_t ctrlstate; /* Control EP state (see enum pic32mx_ctrlstate_e) */
|
||||||
uint8_t selfpowered:1; /* 1: Device is self powered */
|
uint8_t selfpowered:1; /* 1: Device is self powered */
|
||||||
uint8_t rwakeup:1; /* 1: Device supports remote wakeup */
|
uint8_t rwakeup:1; /* 1: Device supports remote wakeup */
|
||||||
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
|
uint8_t ep0ready:1; /* EP0 OUT already prepared */
|
||||||
|
#endif
|
||||||
uint16_t epavail; /* Bitset of available endpoints */
|
uint16_t epavail; /* Bitset of available endpoints */
|
||||||
|
|
||||||
/* The endpoint list */
|
/* The endpoint list */
|
||||||
@@ -535,7 +536,7 @@ static const struct usbdev_ops_s g_devops =
|
|||||||
|
|
||||||
/* Buffer Descriptor Table */
|
/* Buffer Descriptor Table */
|
||||||
|
|
||||||
#ifndef CONFIG_USB_PINGPONG
|
#ifndef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
volatile struct usbotg_bdtentry_s
|
volatile struct usbotg_bdtentry_s
|
||||||
g_bdt[(PIC32MX_NENDPOINTS + 1) * 2] __attribute__ ((aligned(512)));
|
g_bdt[(PIC32MX_NENDPOINTS + 1) * 2] __attribute__ ((aligned(512)));
|
||||||
#else
|
#else
|
||||||
@@ -747,7 +748,7 @@ static void pic32mx_epwrite(struct pic32mx_ep_s *privep, const uint8_t *src,
|
|||||||
|
|
||||||
/* Clear status and toggle the DTS bit if required */
|
/* Clear status and toggle the DTS bit if required */
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
/* Clear all bits in the status but preserve the data toggle bit */
|
/* Clear all bits in the status but preserve the data toggle bit */
|
||||||
|
|
||||||
status = bdt->status & USB_BDT_DATA01;
|
status = bdt->status & USB_BDT_DATA01;
|
||||||
@@ -779,7 +780,7 @@ static void pic32mx_epwrite(struct pic32mx_ep_s *privep, const uint8_t *src,
|
|||||||
|
|
||||||
/* Point to the next ping pong buffer. */
|
/* Point to the next ping pong buffer. */
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1044,7 +1045,9 @@ static int pic32mx_ep0rdsetup(struct pic32mx_usbdev_s *priv, uint8_t *dest,
|
|||||||
* else.
|
* else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = bdt->status & ~(USB_BDT_UOWN|USB_BDT_BYTECOUNT_MASK|USB_BDT_DATA01);
|
status = bdt->status;
|
||||||
|
status &= ~(USB_BDT_BSTALL | USB_BDT_NINC | USB_BDT_KEEP| USB_BDT_UOWN |
|
||||||
|
USB_BDT_BYTECOUNT_MASK | USB_BDT_DATA01);
|
||||||
bdt->status = status;
|
bdt->status = status;
|
||||||
|
|
||||||
/* Set the data pointer, data length, and enable the endpoint */
|
/* Set the data pointer, data length, and enable the endpoint */
|
||||||
@@ -1091,7 +1094,7 @@ static int pic32mx_rdsetup(struct pic32mx_usbdev_s *priv,
|
|||||||
|
|
||||||
/* Toggle the DATA01 bit if required for ping pong support */
|
/* Toggle the DATA01 bit if required for ping pong support */
|
||||||
|
|
||||||
#ifndef CONFIG_USB_PINGPONG
|
#ifndef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_BDT_DATA01;
|
status ^= USB_BDT_DATA01;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1105,7 +1108,7 @@ static int pic32mx_rdsetup(struct pic32mx_usbdev_s *priv,
|
|||||||
|
|
||||||
/* Point to the next ping pong buffer. */
|
/* Point to the next ping pong buffer. */
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1332,7 +1335,7 @@ static void pic32mx_ep0nextsetup(struct pic32mx_usbdev_s *priv)
|
|||||||
|
|
||||||
status = bdt->status & ~USB_BDT_UOWN;
|
status = bdt->status & ~USB_BDT_UOWN;
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
status &= ~USB_BDT_UOWN;
|
status &= ~USB_BDT_UOWN;
|
||||||
@@ -1351,7 +1354,7 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv,
|
|||||||
{
|
{
|
||||||
struct pic32mx_ep_s *ep0 = &priv->eplist[EP0];
|
struct pic32mx_ep_s *ep0 = &priv->eplist[EP0];
|
||||||
volatile struct usbotg_bdtentry_s *bdtout;
|
volatile struct usbotg_bdtentry_s *bdtout;
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
volatile struct usbotg_bdtentry_s *bdtnext;
|
volatile struct usbotg_bdtentry_s *bdtnext;
|
||||||
#endif
|
#endif
|
||||||
uint16_t status;
|
uint16_t status;
|
||||||
@@ -1359,15 +1362,15 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv,
|
|||||||
/* Which BDT are we working on new? Which one will be next */
|
/* Which BDT are we working on new? Which one will be next */
|
||||||
|
|
||||||
bdtout = ep0->bdtout;
|
bdtout = ep0->bdtout;
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
if (bdtout == &g_bdt[EP0_OUT_EVEN])
|
if (bdtout == &g_bdt[EP0_OUT_EVEN])
|
||||||
{
|
{
|
||||||
btdnext = &g_bdt[EP0_OUT_ODD]
|
bdtnext = &g_bdt[EP0_OUT_ODD];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUGASSERT(bdtout == &g_bdt[EP0_OUT_ODD]);
|
DEBUGASSERT(bdtout == &g_bdt[EP0_OUT_ODD]);
|
||||||
btdnext = &g_bdt[EP0_OUT_EVEN]
|
bdtnext = &g_bdt[EP0_OUT_EVEN];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1384,26 +1387,34 @@ static void pic32mx_ep0done(struct pic32mx_usbdev_s *priv,
|
|||||||
* buffer address should be pointed to priv->ctrl.
|
* buffer address should be pointed to priv->ctrl.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = bdtout->status & ~(USB_BDT_BYTECOUNT_MASK | USB_BDT_DTS);
|
status = bdtout->status;
|
||||||
|
status &= ~(USB_BDT_BSTALL | USB_BDT_NINC | USB_BDT_KEEP |
|
||||||
|
USB_BDT_BYTECOUNT_MASK | USB_BDT_DTS);
|
||||||
status |= (USB_SIZEOF_CTRLREQ << USB_BDT_BYTECOUNT_SHIFT);
|
status |= (USB_SIZEOF_CTRLREQ << USB_BDT_BYTECOUNT_SHIFT);
|
||||||
status |= USB_BDT_UOWN; /* Note: DTSEN is 0 */
|
status |= USB_BDT_UOWN; /* Note: DTSEN is 0 */
|
||||||
|
|
||||||
bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
||||||
|
|
||||||
bdtdbg("EP0 BDT OUT (Next) {%08x, %08x}\n", status, bdtout->addr);
|
bdtdbg("EP0 BDT OUT {%08x, %08x}\n", status, bdtout->addr);
|
||||||
|
|
||||||
bdtout->status = status;
|
bdtout->status = status;
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
/* In ping-pong mode, force a STALL if there is any access to the
|
||||||
status = btdnext->status & ~USB_BDT_BYTECOUNT_MASK;
|
* other buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
|
status = bdtnext->status;
|
||||||
|
status &= ~USB_BDT_BYTECOUNT_MASK;
|
||||||
status |= (USB_SIZEOF_CTRLREQ << USB_BDT_BYTECOUNT_SHIFT);
|
status |= (USB_SIZEOF_CTRLREQ << USB_BDT_BYTECOUNT_SHIFT);
|
||||||
status |= USB_BDT_UOWN | USB_BDT_BSTALL;
|
status |= (USB_BDT_UOWN | USB_BDT_BSTALL);
|
||||||
|
|
||||||
btdnext->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
bdtnext->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
||||||
|
|
||||||
bdtdbg("EP0 BDT OUT {%08x, %08x}\n", status, btdnext->addr);
|
bdtdbg("EP0 BDT OUT (Next) {%08x, %08x}\n", status, bdtnext->addr);
|
||||||
|
|
||||||
btdnext->status = status;
|
bdtnext->status = status;
|
||||||
|
priv->ep0ready = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1451,11 +1462,10 @@ static void pic32mx_ep0setup(struct pic32mx_usbdev_s *priv)
|
|||||||
* ownership after a stall.
|
* ownership after a stall.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bdtdbg("EP0 BDT IN {%08x, %08x}\n", ep0->bdtin->status, ep0->bdtin->addr);
|
||||||
ep0->bdtin->status &= ~USB_BDT_UOWN;
|
ep0->bdtin->status &= ~USB_BDT_UOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdtdbg("EP0 BDT IN {%08x, %08x}\n", ep0->bdtin->status, ep0->bdtin->addr);
|
|
||||||
|
|
||||||
/* Assume NOT stalled; no TX in progress */
|
/* Assume NOT stalled; no TX in progress */
|
||||||
|
|
||||||
ep0->stalled = 0;
|
ep0->stalled = 0;
|
||||||
@@ -1987,7 +1997,7 @@ static void pic32mx_ep0in(struct pic32mx_usbdev_s *priv)
|
|||||||
/* Switch to the next ping pong buffer */
|
/* Switch to the next ping pong buffer */
|
||||||
|
|
||||||
status = bdt->status;
|
status = bdt->status;
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2085,7 +2095,9 @@ static void pic32mx_ep0out(struct pic32mx_usbdev_s *priv)
|
|||||||
{
|
{
|
||||||
/* Prepare EP0 OUT for the next SETUP transaction. */
|
/* Prepare EP0 OUT for the next SETUP transaction. */
|
||||||
|
|
||||||
status = ep0->bdtout->status & ~(USB_BDT_BYTECOUNT_MASK|USB_BDT_DATA01);
|
status = ep0->bdtout->status;
|
||||||
|
status &= ~(USB_BDT_BSTALL | USB_BDT_NINC | USB_BDT_KEEP |
|
||||||
|
USB_BDT_BYTECOUNT_MASK | USB_BDT_DATA01);
|
||||||
ep0->bdtout->status = status;
|
ep0->bdtout->status = status;
|
||||||
|
|
||||||
ep0->bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
ep0->bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
||||||
@@ -2122,11 +2134,13 @@ static void pic32mx_ep0out(struct pic32mx_usbdev_s *priv)
|
|||||||
|
|
||||||
pic32mx_ep0nextsetup(priv);
|
pic32mx_ep0nextsetup(priv);
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
if (!priv->ep0ready)
|
if (!priv->ep0ready)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
status = ep0->bdtout->status & ~(USB_BDT_BYTECOUNT_MASK|USB_BDT_DATA01);
|
status = ep0->bdtout->status;
|
||||||
|
status &= ~(USB_BDT_BSTALL | USB_BDT_NINC | USB_BDT_KEEP |
|
||||||
|
USB_BDT_BYTECOUNT_MASK | USB_BDT_DATA01);
|
||||||
ep0->bdtout->status = status;
|
ep0->bdtout->status = status;
|
||||||
|
|
||||||
ep0->bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
ep0->bdtout->addr = (uint8_t *)PHYS_ADDR(&priv->ctrl);
|
||||||
@@ -2140,8 +2154,8 @@ static void pic32mx_ep0out(struct pic32mx_usbdev_s *priv)
|
|||||||
ep0->bdtout->status = status;
|
ep0->bdtout->status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
priv->ep0ready = 0;
|
priv->ep0ready = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2182,7 +2196,7 @@ static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, uint16_t status)
|
|||||||
|
|
||||||
/* It was an EP0 OUT transaction. Get the index to the BDT. */
|
/* It was an EP0 OUT transaction. Get the index to the BDT. */
|
||||||
|
|
||||||
#if CONFIG_USB_PINGPONG
|
#if CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
index = ((status & USB_STAT_PPBI) == 0 ? EP0_OUT_EVEN : EP0_OUT_ODD);
|
index = ((status & USB_STAT_PPBI) == 0 ? EP0_OUT_EVEN : EP0_OUT_ODD);
|
||||||
#else
|
#else
|
||||||
index = EP0_OUT_EVEN;
|
index = EP0_OUT_EVEN;
|
||||||
@@ -2469,13 +2483,15 @@ static int pic32mx_interrupt(int irq, void *context)
|
|||||||
{
|
{
|
||||||
uint8_t epno;
|
uint8_t epno;
|
||||||
|
|
||||||
/* Is token processing complete */
|
/* Check the pending interrupt register. Is token processing complete. */
|
||||||
|
|
||||||
if ((pic32mx_getreg(PIC32MX_USB_IR) & USB_INT_TRN) != 0)
|
if ((pic32mx_getreg(PIC32MX_USB_IR) & USB_INT_TRN) != 0)
|
||||||
{
|
{
|
||||||
regval = pic32mx_getreg(PIC32MX_USB_STAT);
|
regval = pic32mx_getreg(PIC32MX_USB_STAT);
|
||||||
pic32mx_putreg(USB_INT_TRN, PIC32MX_USB_IR);
|
pic32mx_putreg(USB_INT_TRN, PIC32MX_USB_IR);
|
||||||
|
|
||||||
|
usbtrace(TRACE_INTDECODE(PIC32MX_TRACEINTID_TRNCS), regval);
|
||||||
|
|
||||||
/* Handle the endpoint tranfer complete event. */
|
/* Handle the endpoint tranfer complete event. */
|
||||||
|
|
||||||
epno = (regval & USB_STAT_ENDPT_MASK) >> USB_STAT_ENDPT_SHIFT;
|
epno = (regval & USB_STAT_ENDPT_MASK) >> USB_STAT_ENDPT_SHIFT;
|
||||||
@@ -2759,7 +2775,7 @@ static int pic32mx_epconfigure(struct usbdev_ep_s *ep,
|
|||||||
* The only difference is the we clear DATA1 (making it DATA0)
|
* The only difference is the we clear DATA1 (making it DATA0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
bdt = &g_bdt[index+1];
|
bdt = &g_bdt[index+1];
|
||||||
status = bdt->status & ~USB_BDT_UOWN;
|
status = bdt->status & ~USB_BDT_UOWN;
|
||||||
|
|
||||||
@@ -2793,7 +2809,7 @@ static int pic32mx_epconfigure(struct usbdev_ep_s *ep,
|
|||||||
* The only difference is the we clear DATA1 (making it DATA0)
|
* The only difference is the we clear DATA1 (making it DATA0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
bdt = &g_bdt[index+1];
|
bdt = &g_bdt[index+1];
|
||||||
status = bdt->status & ~USB_BDT_UOWN;
|
status = bdt->status & ~USB_BDT_UOWN;
|
||||||
|
|
||||||
@@ -2863,7 +2879,7 @@ static int pic32mx_epdisable(struct usbdev_ep_s *ep)
|
|||||||
/* Reset the BDTs */
|
/* Reset the BDTs */
|
||||||
|
|
||||||
ptr = (uint32_t*)&g_bdt[EP(epno, 0, 0)];
|
ptr = (uint32_t*)&g_bdt[EP(epno, 0, 0)];
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
for (i = 0; i < (4 * sizeof(struct usbotg_bdtentry_s) / sizeof(uint32_t)); i++)
|
for (i = 0; i < (4 * sizeof(struct usbotg_bdtentry_s) / sizeof(uint32_t)); i++)
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < (2 * sizeof(struct usbotg_bdtentry_s) / sizeof(uint32_t)); i++)
|
for (i = 0; i < (2 * sizeof(struct usbotg_bdtentry_s) / sizeof(uint32_t)); i++)
|
||||||
@@ -3089,7 +3105,7 @@ static int pic32mx_epbdtstall(struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Toggle over the to the next buffer */
|
/* Toggle over the to the next buffer */
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
status |= (USB_BDT_UOWN | USB_BDT_DATA1);
|
status |= (USB_BDT_UOWN | USB_BDT_DATA1);
|
||||||
@@ -3117,7 +3133,7 @@ static int pic32mx_epbdtstall(struct usbdev_ep_s *ep,
|
|||||||
|
|
||||||
/* Toggle over the to the next buffer */
|
/* Toggle over the to the next buffer */
|
||||||
|
|
||||||
#ifdef CONFIG_USB_PINGPONG
|
#ifdef CONFIG_PIC32MX_USBDEV_PINGPONG
|
||||||
status ^= USB_NEXT_PINGPONG;
|
status ^= USB_NEXT_PINGPONG;
|
||||||
#endif
|
#endif
|
||||||
status |= (USB_BDT_UOWN | USB_BDT_DATA1 | USB_BDT_DTS);
|
status |= (USB_BDT_UOWN | USB_BDT_DATA1 | USB_BDT_DTS);
|
||||||
@@ -3561,6 +3577,7 @@ static void pic32mx_detach(struct pic32mx_usbdev_s *priv)
|
|||||||
|
|
||||||
static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv)
|
static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv)
|
||||||
{
|
{
|
||||||
|
uint32_t physaddr;
|
||||||
uint16_t regval;
|
uint16_t regval;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -3581,10 +3598,17 @@ static void pic32mx_hwreset(struct pic32mx_usbdev_s *priv)
|
|||||||
regval |= USB_PWRC_USBPWR;
|
regval |= USB_PWRC_USBPWR;
|
||||||
pic32mx_putreg(regval, PIC32MX_USB_PWRC);
|
pic32mx_putreg(regval, PIC32MX_USB_PWRC);
|
||||||
|
|
||||||
/* Set the address of the buffer descriptor table (BDT) */
|
/* Set the address of the buffer descriptor table (BDT)
|
||||||
|
*
|
||||||
|
* BDTP1: Bit 1-7: Bits 9-15 of the BDT base address
|
||||||
|
* BDTP2: Bit 0-7: Bits 16-23 of the BDT base address
|
||||||
|
* BDTP3: Bit 0-7: Bits 24-31 of the BDT base address
|
||||||
|
*/
|
||||||
|
|
||||||
regval = (uint16_t)((PHYS_ADDR(g_bdt)) >> 8);
|
physaddr = (PHYS_ADDR(g_bdt)) >> 8;
|
||||||
pic32mx_putreg(regval, PIC32MX_USB_BDTP1);
|
pic32mx_putreg((uint16_t)((regval >> 8) & USB_BDTP1_MASK), PIC32MX_USB_BDTP1);
|
||||||
|
pic32mx_putreg((uint16_t)((regval >> 16) & USB_BDTP2_MASK), PIC32MX_USB_BDTP2);
|
||||||
|
pic32mx_putreg((uint16_t)((regval >> 24) & USB_BDTP3_MASK), PIC32MX_USB_BDTP3);
|
||||||
|
|
||||||
/* Assert reset request to all of the Ping Pong buffer pointers */
|
/* Assert reset request to all of the Ping Pong buffer pointers */
|
||||||
|
|
||||||
|
|||||||
@@ -459,8 +459,32 @@ Where <subdir> is one of the following:
|
|||||||
Configures the NuttShell (nsh) located at apps/examples/nsh. The
|
Configures the NuttShell (nsh) located at apps/examples/nsh. The
|
||||||
Configuration enables only the serial NSH interface.
|
Configuration enables only the serial NSH interface.
|
||||||
|
|
||||||
The examples/usbterm program can be included as an NSH built-in
|
Several USB device configurations can be enabled and included
|
||||||
function by defined the following in your .config file:
|
as NSH built-in built in functions. All require the following
|
||||||
|
basic setup in your .config to enable USB device support:
|
||||||
|
|
||||||
|
CONFIG_USBEV=y : Enable basic USB device support
|
||||||
|
CONFIG_PIC32MX_USBDEV=y : Enable PIC32 USB device support
|
||||||
|
|
||||||
CONFIG_USBEV=y : Enable basic USB device support
|
examples/usbterm - This option can be enabled by uncommenting
|
||||||
CONFIG_PIC32MX_USBDEV=y : Enable PIC32 USB device support
|
the following line in the appconfig file:
|
||||||
|
|
||||||
|
CONFIGURED_APPS += examples/usbterm
|
||||||
|
|
||||||
|
And by enabling one of the USB serial devices:
|
||||||
|
|
||||||
|
CONFIG_PL2303=y : Enable the Prolifics PL2303 emulation
|
||||||
|
CONFIG_CDCACM=y : or the CDC/ACM serial driver (not both)
|
||||||
|
|
||||||
|
examples/cdcacm - The examples/cdcacm program can be included as an
|
||||||
|
function by uncommenting the following line in the appconfig file:
|
||||||
|
|
||||||
|
CONFIGURED_APPS += examples/cdcacm
|
||||||
|
|
||||||
|
and defining the following in your .config file:
|
||||||
|
|
||||||
|
CONFIG_CDCACM=y : Enable the CDCACM device
|
||||||
|
|
||||||
|
examples/usbstorage - There are some hooks in the appconfig file
|
||||||
|
to enable the USB mass storage device. However, this device cannot
|
||||||
|
work until support for the SD card is also incorporated.
|
||||||
|
|||||||
@@ -33,32 +33,45 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
############################################################################
|
||||||
# Path to example in apps/examples containing the user_start entry point
|
# Path to example in apps/examples containing the user_start entry point
|
||||||
|
############################################################################
|
||||||
|
|
||||||
CONFIGURED_APPS += examples/nsh
|
CONFIGURED_APPS += examples/nsh
|
||||||
|
|
||||||
|
############################################################################
|
||||||
# The NSH application library
|
# The NSH application library
|
||||||
|
############################################################################
|
||||||
|
|
||||||
CONFIGURED_APPS += system/readline
|
CONFIGURED_APPS += system/readline
|
||||||
CONFIGURED_APPS += nshlib
|
CONFIGURED_APPS += nshlib
|
||||||
|
|
||||||
# Applications configured as an NX built-in commands
|
############################################################################
|
||||||
|
# USB device configurations
|
||||||
ifeq ($(CONFIG_NET),y)
|
############################################################################
|
||||||
CONFIGURED_APPS += netutils/uiplib
|
|
||||||
CONFIGURED_APPS += netutils/resolv
|
|
||||||
CONFIGURED_APPS += netutils/webclient
|
|
||||||
CONFIGURED_APPS += netutils/tftpc
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_PWM),y)
|
|
||||||
CONFIGURED_APPS += examples/pwm
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CAN),y)
|
|
||||||
CONFIGURED_APPS += examples/can
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
|
ifeq ($(CONFIG_PIC32MX_USBDEV),y)
|
||||||
CONFIGURED_APPS += examples/usbterm
|
|
||||||
|
# USB Mass Storage Class device configurations
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USBMSC),y)
|
||||||
|
# Uncomment to enable the examples/usbstorage built-in
|
||||||
|
# CONFIGURED_APPS += examples/usbstorage
|
||||||
|
endif
|
||||||
|
|
||||||
|
# USB CDC/ACM serial device configurations
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CDCACM),y)
|
||||||
|
# Uncomment to enable the examples/cdcacm built-in
|
||||||
|
# CONFIGURED_APPS += examples/cdcacm
|
||||||
|
# Uncomment the following to enable the examples/usbterm built-in
|
||||||
|
# CONFIGURED_APPS += examples/usbterm
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Prolifics PL2303 emulation configurations
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PL2303),y)
|
||||||
|
# Uncomment the following to enable the examples/usbterm built-in
|
||||||
|
# CONFIGURED_APPS += examples/usbterm
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -225,6 +225,13 @@ CONFIG_UART2_PARITY=0
|
|||||||
CONFIG_UART1_2STOP=0
|
CONFIG_UART1_2STOP=0
|
||||||
CONFIG_UART2_2STOP=0
|
CONFIG_UART2_2STOP=0
|
||||||
|
|
||||||
|
#
|
||||||
|
# PIC32MX-specific USB device setup
|
||||||
|
#
|
||||||
|
CONFIG_PIC32MX_USBDEV_REGDEBUG=n
|
||||||
|
CONFIG_PIC32MX_USBDEV_BDTDEBUG=n
|
||||||
|
CONFIG_PIC32MX_USBDEV_PINGPONG=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# General build options
|
# General build options
|
||||||
#
|
#
|
||||||
@@ -349,7 +356,6 @@ CONFIG_DEBUG_VERBOSE=n
|
|||||||
CONFIG_DEBUG_SYMBOLS=n
|
CONFIG_DEBUG_SYMBOLS=n
|
||||||
CONFIG_DEBUG_SCHED=n
|
CONFIG_DEBUG_SCHED=n
|
||||||
CONFIG_DEBUG_USB=n
|
CONFIG_DEBUG_USB=n
|
||||||
CONFIG_PIC32MX_USBDEV_REGDEBUG=n
|
|
||||||
|
|
||||||
CONFIG_HAVE_CXX=n
|
CONFIG_HAVE_CXX=n
|
||||||
CONFIG_HAVE_CXXINITIALIZE=n
|
CONFIG_HAVE_CXXINITIALIZE=n
|
||||||
@@ -1031,6 +1037,37 @@ CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS=n
|
|||||||
CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER=n
|
CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER=n
|
||||||
CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS=n
|
CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS=n
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings for examples/cdcacm
|
||||||
|
#
|
||||||
|
# Configuration prequisites:
|
||||||
|
#
|
||||||
|
# CONFIG_USBDEV=y : USB device support must be enabled
|
||||||
|
# CONFIG_CDCACM=y : The CDC/ACM driver must be built
|
||||||
|
# CONFIG_NSH_BUILTIN_APPS : NSH built-in application support must be enabled
|
||||||
|
#
|
||||||
|
# Configuration options specific to this example:
|
||||||
|
#
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_DEVMINOR
|
||||||
|
# The minor number of the CDC/ACM device.
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_TRACEINIT
|
||||||
|
# Show initialization events
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_TRACECLASS
|
||||||
|
# Show class driver events
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_TRACETRANSFERS
|
||||||
|
# Show data transfer events
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_TRACECONTROLLER
|
||||||
|
# Show controller events
|
||||||
|
# CONFIG_EXAMPLES_CDCACM_TRACEINTERRUPTS
|
||||||
|
# Show interrupt-related events.
|
||||||
|
#
|
||||||
|
CONFIG_EXAMPLES_CDCACM_DEVMINOR=0
|
||||||
|
CONFIG_EXAMPLES_CDCACM_TRACEINIT=n
|
||||||
|
CONFIG_EXAMPLES_CDCACM_TRACECLASS=n
|
||||||
|
CONFIG_EXAMPLES_CDCACM_TRACETRANSFERS=n
|
||||||
|
CONFIG_EXAMPLES_CDCACM_TRACECONTROLLER=n
|
||||||
|
CONFIG_EXAMPLES_CDCACM_TRACEINTERRUPTS=n
|
||||||
|
|
||||||
#
|
#
|
||||||
# Stack and heap information
|
# Stack and heap information
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user