summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-29 12:52:15 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-29 12:52:15 +0000
commitfb7d51e41ba6acd21e511a25f1a2e5102d3d8095 (patch)
tree39a24c0f788e5439a598b20bce102bcf471d44f2 /nuttx
parentcca080df11ff398f86eed1c0b83fc572e5d69bb8 (diff)
downloadpx4-nuttx-fb7d51e41ba6acd21e511a25f1a2e5102d3d8095.tar.gz
px4-nuttx-fb7d51e41ba6acd21e511a25f1a2e5102d3d8095.tar.bz2
px4-nuttx-fb7d51e41ba6acd21e511a25f1a2e5102d3d8095.zip
Correct last set of changes to configuration logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4237 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog6
-rw-r--r--nuttx/TODO17
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_gpio.c30
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c9
-rw-r--r--nuttx/include/nuttx/usb/usb.h30
-rwxr-xr-xnuttx/tools/configure.sh4
6 files changed, 84 insertions, 12 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index c0a71d83a..42f87a846 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2302,4 +2302,8 @@
* tools/Makefile.txport, mkexport.sh, and configure.sh. Changes submitted
by Mike Smith to support configuration and 'make export' on MAC OS.
-
+ * arch/arm/src/stm32/stm32_gpio.c. Disabled interrupts while configuring
+ GPIO pins so that we have exclusive access to the GPIO configuration
+ registers.
+ * arch/mips/src/pic32mx/pic32mx_usbdev.c. Add a USB device-side driver
+ for the PIC32MX family.
diff --git a/nuttx/TODO b/nuttx/TODO
index 4d65e6ce8..a4e9f1174 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -94,6 +94,23 @@ o Task/Scheduler (sched/)
next interesting event time. That is one way to both reduce the
timer interrupt overhead and also to increase the accuracy of
delays.
+
+ Current timer processing is in sched/sched_processtimer.c:
+
+ 1) Calls clock_timer() which just increments a counter (the system
+ timer -- basically "up-time"). This is only used when code asks
+ for the current time. In a tickless OS, some substitute answer
+ for the question "What time is it?" would need to be developed.
+ You could use an RTC? Or maybe logic that gets the time until the
+ next interval expiration and computes the current time. The
+ solution is not too difficult, but depends on a hardware solution.
+
+ 2) Calls wd_timer() which handles the link list of ordered events:
+ Each timer event is saved with the delta time to the next event
+ in the list. So an interval timer would be perfect to implement this.
+
+ 3) sched_process_timeslice(). Then there is round-robin time-slicing.
+
Status: Open
Priority: Low
diff --git a/nuttx/arch/arm/src/stm32/stm32_gpio.c b/nuttx/arch/arm/src/stm32/stm32_gpio.c
index 309df3520..6787c5777 100644
--- a/nuttx/arch/arm/src/stm32/stm32_gpio.c
+++ b/nuttx/arch/arm/src/stm32/stm32_gpio.c
@@ -47,6 +47,8 @@
#include <errno.h>
#include <debug.h>
+#include <arch/irq.h>
+
#include "up_arch.h"
#include "chip.h"
@@ -202,7 +204,12 @@ static inline void stm32_gpioremap(void)
* Based on configuration within the .config file, it does:
* - Remaps positions of alternative functions.
*
- * Typically called from stm32_start().
+ * Typically called from stm32_start().
+ *
+ * Assumptions:
+ * This function is called early in the initialization sequence so that
+ * no mutual exlusion is necessary.
+ *
****************************************************************************/
void stm32_gpioinit(void)
@@ -244,6 +251,7 @@ int stm32_configgpio(uint32_t cfgset)
unsigned int pin;
unsigned int pos;
unsigned int modecnf;
+ irqstate_t flags;
bool input;
/* Verify that this hardware supports the select GPIO port */
@@ -278,6 +286,12 @@ int stm32_configgpio(uint32_t cfgset)
input = ((cfgset & GPIO_INPUT) != 0);
+ /* Interrupts must be disabled from here on out so that we have mutually
+ * exclusive access to all of the GPIO configuration registers.
+ */
+
+ flags = irqsave();
+
/* Decode the mode and configuration */
regval = getreg32(cr);
@@ -316,6 +330,7 @@ int stm32_configgpio(uint32_t cfgset)
{
/* Its an alternate function pin... we can return early */
+ irqrestore(flags);
return OK;
}
}
@@ -342,6 +357,7 @@ int stm32_configgpio(uint32_t cfgset)
{
/* Neither... we can return early */
+ irqrestore(flags);
return OK;
}
}
@@ -367,6 +383,8 @@ int stm32_configgpio(uint32_t cfgset)
regval = getreg32(regaddr);
regval |= (1 << pin);
putreg32(regval, regaddr);
+
+ irqrestore(flags);
return OK;
}
#endif
@@ -386,6 +404,7 @@ int stm32_configgpio(uint32_t cfgset)
unsigned int pin;
unsigned int pos;
unsigned int pinmode;
+ irqstate_t flags;
/* Verify that this hardware supports the select GPIO port */
@@ -427,6 +446,14 @@ int stm32_configgpio(uint32_t cfgset)
break;
}
+ /* Interrupts must be disabled from here on out so that we have mutually
+ * exclusive access to all of the GPIO configuration registers.
+ */
+
+ flags = irqsave();
+
+ /* Now apply the configuration to the mode register */
+
regval = getreg32(base + STM32_GPIO_MODER_OFFSET);
regval &= ~GPIO_MODER_MASK(pin);
regval |= ((uint32_t)pinmode << GPIO_MODER_SHIFT(pin));
@@ -572,6 +599,7 @@ int stm32_configgpio(uint32_t cfgset)
stm32_gpiowrite(cfgset, value);
}
+ irqrestore(flags);
return OK;
}
#endif
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
index a857ac162..bc0f450e4 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
@@ -5,9 +5,12 @@
* Author: Gregory Nutt <gnutt@nuttx.orgr>
*
* References:
- * - This file derives from the STM32 USB device driver
+ * This file derives from the STM32 USB device driver with modifications
+ * based on additional information from:
+ *
* - "USB On-The-Go (OTG)", DS61126E, Microchip Technology Inc., 2009
- * - Sample code provided with the Sure Electronics PIC32 board.
+ * - Sample code provided with the Sure Electronics PIC32 board
+ * (which seems to have derived from Microchip PICDEM PIC18 code).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -2010,7 +2013,7 @@ static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, uint16_t status)
/* Check the current EP0 OUT buffer contains a SETUP packet */
- if (((bdt->status & USB_BDT_PID_MASK) >> USB_BDT_PID_SHIFT) == USB_SETUP_TOKEN)
+ if (((bdt->status & USB_BDT_PID_MASK) >> USB_BDT_PID_SHIFT) == USB_PID_SETUP_TOKEN)
{
/* Check if the SETUP transaction data went into the priv->ctrl
* buffer. If not, then we will need to copy it.
diff --git a/nuttx/include/nuttx/usb/usb.h b/nuttx/include/nuttx/usb/usb.h
index c05f25c50..2c20c69fc 100644
--- a/nuttx/include/nuttx/usb/usb.h
+++ b/nuttx/include/nuttx/usb/usb.h
@@ -47,11 +47,31 @@
/************************************************************************************
* Preprocessor Definitions
************************************************************************************/
-/* USB Tokens (See chapter 8 in the USB specification) */
-
-#define USB_SETUP_TOKEN 0x0d
-#define USB_OUT_TOKEN 0x01
-#define USB_IN_TOKEN 0x09
+/* A packet identifier (PID) immediately follows the SYNC field of every USB packet.
+ * A PID consists of a four-bit packet type field followed by a four-bit check field
+ * USB Tokens (See Table 8-1 in the USB specification)
+ */
+
+#define USB_PID_OUT_TOKEN (0x01) /* Tokens */
+#define USB_PID_IN_TOKEN (0x09)
+#define USB_PID_SOF_TOKEN (0x05)
+#define USB_PID_SETUP_TOKEN (0x0d)
+
+#define USB_PID_DATA0 (0x03) /* Data */
+#define USB_PID_DATA1 (0x0b)
+#define USB_PID_DATA2 (0x07)
+#define USB_PID_MDATA (0x0f)
+
+#define USB_PID_ACK (0x02) /* Handshake */
+#define USB_PID_NAK (0x0a)
+#define USB_PID_STALL (0x0e)
+#define USB_PID_NYET (0x06)
+
+#define USB_PID_PRE_TOKEN (0x0c) /* Special */
+#define USB_PID_ERR (0x0c)
+#define USB_PID_SPLIT_TOKEN (0x08)
+#define USB_PID_PING_TOKEN (0x04)
+#define USB_PID_RESERVED (0x00)
/* All 16-bit values must be little-endian */
diff --git a/nuttx/tools/configure.sh b/nuttx/tools/configure.sh
index 84a9acb43..3aaed0681 100755
--- a/nuttx/tools/configure.sh
+++ b/nuttx/tools/configure.sh
@@ -156,7 +156,7 @@ if [ ! -z "${appdir}" ]; then
if [ ! -r "${configpath}/appconfig" ]; then
echo "NOTE: No readable appconfig file found in ${configpath}"
else
- install -C "${configpath}/appconfig" "${TOPDIR}/${appdir}/.configX" || \
+ install -C "${configpath}/appconfig" "${TOPDIR}/${appdir}/.config" || \
{ echo "Failed to copy ${configpath}/appconfig" ; exit 10 ; }
echo "" >> "${TOPDIR}/.configX"
@@ -166,7 +166,7 @@ if [ ! -z "${appdir}" ]; then
fi
fi
-# install the final .configX only if it differs from the existing
+# install the final .configX only if it differs from any existing
# .config file.
install -C "${TOPDIR}/.configX" "${TOPDIR}/.config"