summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-21 02:05:59 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-06-21 02:05:59 +0000
commit45d04be87af60e5f002c0539ac87181c7583cdab (patch)
tree599fea72ab3154bdb24a477b731e46e1a01828d1
parentd30d34a6c826747aa920cb5495a635cb758858a0 (diff)
downloadpx4-nuttx-45d04be87af60e5f002c0539ac87181c7583cdab.tar.gz
px4-nuttx-45d04be87af60e5f002c0539ac87181c7583cdab.tar.bz2
px4-nuttx-45d04be87af60e5f002c0539ac87181c7583cdab.zip
AVR build warnings; minor USB fix
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3729 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/avr/src/at90usb/at90usb_usbdev.c64
-rw-r--r--nuttx/configs/teensy/README.txt7
-rw-r--r--nuttx/fs/fat/fs_fat32.h12
3 files changed, 49 insertions, 34 deletions
diff --git a/nuttx/arch/avr/src/at90usb/at90usb_usbdev.c b/nuttx/arch/avr/src/at90usb/at90usb_usbdev.c
index 721aaa254..deac78beb 100644
--- a/nuttx/arch/avr/src/at90usb/at90usb_usbdev.c
+++ b/nuttx/arch/avr/src/at90usb/at90usb_usbdev.c
@@ -1102,6 +1102,7 @@ static void avr_dispatchrequest(FAR const struct usb_ctrlreq_s *ctrl)
static int avr_ep0configure(void)
{
+ FAR struct avr_ep_s *privep = &g_usbdev.eplist[AVR_EP0];
uint8_t regval;
/* Configure endpoint 0 */
@@ -1121,6 +1122,16 @@ static int avr_ep0configure(void)
return -EINVAL;
}
+ /* Initialize the endpoint data structure. Mark EP0 as an IN endpoint so
+ * that the submit() logic will know that any enqueue packets are to be
+ * sent.
+ */
+
+ memset(privep, 0, sizeof(struct avr_ep_s));
+ privep->ep.ops = &g_epops;
+ privep->ep.maxpacket = AVR_CTRLEP_SIZE;
+ privep->epin = 1;
+
/* Enable OUT interrupts */
UEIENX |= (1 << RXOUTE);
@@ -2090,6 +2101,7 @@ static int avr_geninterrupt(int irq, FAR void *context)
static int avr_epconfigure(FAR struct usbdev_ep_s *ep,
FAR const struct usb_epdesc_s *desc, bool last)
{
+ FAR struct avr_ep_s *privep = (FAR struct avr_ep_s *)ep;
uint16_t maxpacket = GETUINT16(desc->mxpacketsize);
uint8_t uecfg0x;
uint8_t uecfg1x;
@@ -2097,7 +2109,7 @@ static int avr_epconfigure(FAR struct usbdev_ep_s *ep,
uint8_t regval;
usbtrace(TRACE_EPCONFIGURE, ep->eplog);
- DEBUGASSERT(desc->addr == ep->eplog);
+ DEBUGASSERT(ep->eplog != 0 && desc->addr == ep->eplog);
/* Configure the endpoint */
@@ -2133,16 +2145,18 @@ static int avr_epconfigure(FAR struct usbdev_ep_s *ep,
if (USB_ISEPIN(desc->addr))
{
+ DEBUGASSERT(privep->epin != 0);
uecfg0x |= AVR_DIR_IN;
ueienx = (1 << RXOUTE);
}
+ else
+ {
+ DEBUGASSERT(privep->epin == 0);
+ }
/* Handle banking (this needs to be revisited... Always double bank?) */
- if (ep->eplog != 0)
- {
- uecfg1x |= AVR_DOUBLE_BANK;
- }
+ uecfg1x |= AVR_DOUBLE_BANK;
/* Handle the maximum packet size */
@@ -2191,9 +2205,10 @@ static int avr_epconfigure(FAR struct usbdev_ep_s *ep,
return -EINVAL;
}
- /* Reset endpoint status */
+ /* Save the new max packet size and reset endpoint status */
- g_usbdev.stalled = false;
+ privep->ep.maxpacket = maxpacket;
+ privep->stalled = 0;
/* Enable interrupts as appropriate for this endpoint */
@@ -2518,6 +2533,7 @@ static FAR struct usbdev_ep_s *avr_allocep(FAR struct usbdev_s *dev,
uint8_t epno, bool in,
uint8_t eptype)
{
+ FAR struct avr_ep_s *privep;
irqstate_t flags;
uint8_t epset = g_usbdev.epavail;
uint8_t epmask;
@@ -2567,22 +2583,33 @@ static FAR struct usbdev_ep_s *avr_allocep(FAR struct usbdev_s *dev,
epmask = 1 << epndx;
if ((epset & epmask) != 0)
{
+ /* Initialize the endpoint structure */
+
+ privep = &g_usbdev.eplist[epndx];
+ memset(privep, 0, sizeof(struct avr_ep_s));
+
+ privep->ep.ops = &g_epops;
+ privep->ep.eplog = epndx;
+ privep->ep.maxpacket = (epndx == 1) ? 256 : 64;
+
/* Mark the IN/OUT endpoint no longer available */
g_usbdev.epavail &= ~epmask;
if (in)
{
g_usbdev.epinset |= epmask;
+ privep->epin = 1;
}
else
{
g_usbdev.epoutset |= epmask;
+ privep->epin = 0;
}
/* And return the pointer to the standard endpoint structure */
irqrestore(flags);
- return &g_usbdev.eplist[epndx].ep;
+ return &privep->ep;
}
}
@@ -2716,8 +2743,6 @@ static int avr_pullup(struct usbdev_s *dev, bool enable)
void up_usbinitialize(void)
{
- int i;
-
usbtrace(TRACE_DEVINIT, 0);
/* Shutdown the USB interface to put it in a known initial state */
@@ -2735,25 +2760,6 @@ void up_usbinitialize(void)
g_usbdev.usbdev.ep0 = &g_usbdev.eplist[AVR_EP0].ep;
g_usbdev.epavail = AVR_ALL_EPS & ~(1 << AVR_EP0);
- /* Initialize the endpoint list */
-
- for (i = 0; i < AVR_NENDPOINTS; i++)
- {
- /* Set endpoint operations, reference to driver structure (not really
- * necessary because there is only one controller), and the physical
- * endpoint number (which is just the index to the endpoint).
- */
-
- g_usbdev.eplist[i].ep.ops = &g_epops;
- g_usbdev.eplist[i].ep.eplog = i;
-
- /* The maximum packet size may depend on the endpoint. Endpoint 1 has
- * a larger maximum packet size than the other endpoints.
- */
-
- g_usbdev.eplist[i].ep.maxpacket = (i == 1) ? 256 : 64;
- }
-
/* Reset the interface to force re-enumeration */
avr_usbreset();
diff --git a/nuttx/configs/teensy/README.txt b/nuttx/configs/teensy/README.txt
index 4d8843385..24579e82c 100644
--- a/nuttx/configs/teensy/README.txt
+++ b/nuttx/configs/teensy/README.txt
@@ -529,3 +529,10 @@ Where <subdir> is one of the following:
apps/examples/ostest. NOTE: The OS test is quite large. In order
to get it to fit within AVR memory constraints, it will probably be
necessary to disable some OS features.
+
+ usbstorage:
+ This configuration directory exercises the USB mass storage
+ class driver at apps/examples/usbstorage. See apps/examples/README.txt
+ for more information. NOTE: THIS CONFIGURATION HAS NOT YET BEEN
+ DEBUGGED AND DOES NOT WORK!!! ISSUES: (1) THE SPI DRIVER IS UNTESTED,
+ (2) THE USB DRIVER IS UNTESTED, AND (3) THE RAM USAGE MIGHT BE EXCESSIVE.
diff --git a/nuttx/fs/fat/fs_fat32.h b/nuttx/fs/fat/fs_fat32.h
index 59dbb1f8b..ca5915098 100644
--- a/nuttx/fs/fat/fs_fat32.h
+++ b/nuttx/fs/fat/fs_fat32.h
@@ -235,19 +235,21 @@
#define FAT_MAXCLUST12 ((1 << 12) - 16)
-/* FAT16: For M$, the calculation is ((1 << 16) - 19). */
+/* FAT16: For M$, the calculation is ((1 << 16) - 19). (The uint32_t cast is
+ * needed for architectures where int is only 16 bits).
+ */
#define FAT_MINCLUST16 (FAT_MAXCLUST12 + 1)
-#define FAT_MAXCLUST16 ((1 << 16) - 16)
+#define FAT_MAXCLUST16 (((uint32_t)1 << 16) - 16)
/* FAT32: M$ reserves the MS 4 bits of a FAT32 FAT entry so only 18 bits are
- * available. For M$, the calculation is ((1 << 28) - 19).
+ * available. For M$, the calculation is ((1 << 28) - 19). (The uint32_t cast
+ * is needed for architectures where int is only 16 bits).
*/
#define FAT_MINCLUST32 65524
/* #define FAT_MINCLUST32 (FAT_MAXCLUST16 + 1) */
-#define FAT_MAXCLUST32 ((1 << 28) - 16)
-
+#define FAT_MAXCLUST32 (((uint32_t)1 << 28) - 16)
/****************************************************************************
* Access to data in raw sector data */