summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnuttx/ChangeLog3
-rw-r--r--nuttx/configs/nucleo-f4x1re/Kconfig17
-rw-r--r--nuttx/configs/nucleo-f4x1re/README.txt33
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h107
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_adc.c24
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c89
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c15
-rw-r--r--nuttx/configs/sama5d3-xplained/src/sam_nsh.c4
-rw-r--r--nuttx/configs/stm3210e-eval/src/stm32_djoystick.c4
-rw-r--r--nuttx/drivers/eeprom/spi_xx25xx.c71
-rw-r--r--nuttx/drivers/input/ajoystick.c2
-rw-r--r--nuttx/include/nuttx/eeprom/spi_xx25xx.h17
12 files changed, 300 insertions, 86 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index e384bc08e..96aeb3354 100755
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -9137,3 +9137,6 @@
analog Joystick shield support for the Nucleo F4x1RE boards. There
are still some ADC issues to be worke through as of the initial
commit (2014-12-3).
+ * /drivers/eeprom/spi_xx25xx.c and /include/nuttx/eeprom/spi_xx25xx.h:
+ Add support for ST Micro EEPROM device geometries. From Sebastien
+ Lorquet (2014-12-5).
diff --git a/nuttx/configs/nucleo-f4x1re/Kconfig b/nuttx/configs/nucleo-f4x1re/Kconfig
index ae2bf3130..bdd5b9c3c 100644
--- a/nuttx/configs/nucleo-f4x1re/Kconfig
+++ b/nuttx/configs/nucleo-f4x1re/Kconfig
@@ -2,3 +2,20 @@
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
+
+if ARCH_BOARD_NUCLEO_F401RE
+
+config NUCLEO_F401RE_AJOY_MINBUTTONS
+ bool "Minimal Joystick Buttons"
+ default n if !STM32_USART1
+ default y if STM32_USART1
+ depends on AJOYSTICK
+ ---help---
+ The Itead Joystick shield supports analog X/Y position and up to 5
+ buttons. Some of these buttons may conflict with other resources
+ (Button F, for example, conflicts with the default USART1 pin usage).
+ Selecting this option will return the number of buttons to the
+ minimal set: SELECT (joystick down), FIRE (BUTTON B), and JUMP
+ (BUTTON A).
+
+endif # ARCH_BOARD_NUCLEO_F401RE
diff --git a/nuttx/configs/nucleo-f4x1re/README.txt b/nuttx/configs/nucleo-f4x1re/README.txt
index 835bad18b..0b89bf32b 100644
--- a/nuttx/configs/nucleo-f4x1re/README.txt
+++ b/nuttx/configs/nucleo-f4x1re/README.txt
@@ -393,8 +393,8 @@ Serial Consoles
Nucleo CN10 STM32F4x1RE
----------- ------------
- Pin 21 PA9 USART2_RX
- Pin 33 PA10 USART2_TX
+ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on
+ Pin 33 PA10 USART1_TX some RS-232 converters
Pin 20 GND
Pin 8 U5V
@@ -425,8 +425,8 @@ Serial Consoles
Nucleo CN9 STM32F4x1RE
----------- ------------
- Pin 1 PA3 USART2_RX
- Pin 2 PA2 USART2_TX
+ Pin 1 PA3 USART2_RX *Warning you make need to reverse RX/TX on
+ Pin 2 PA2 USART2_TX some RS-232 converters
Solder Bridges. This configuration requires:
@@ -529,13 +529,19 @@ Shields
D7 Button A Output PA8
D8 Button F Output PA9
D9 Button G Output PC7
- A0 Joystick Y Output PA0 ADC_IN0
- A1 Joystick X Output PA1 ADC_IN1
+ A0 Joystick Y Output PA0 ADC1_0
+ A1 Joystick X Output PA1 ADC1_1
--------- ----------------- ---------------------------------
All buttons are pulled on the shield. A sensed low value indicates
when the button is pressed.
+ NOTE: Button F cannot be used with the default USART1 configuration
+ because PA9 is configured for USART1_RX by default. Use select
+ different USART1 pins in the board.h file or select a different
+ USART or select CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS which will
+ eliminate all but buttons A, B, and C.
+
Itead Joystick Signal interpretation:
--------- ----------------------- ---------------------------
@@ -570,6 +576,17 @@ Shields
CONFIG_EXAMPLES_AJOYSTICK_DEVNAME="/dev/ajoy0"
CONFIG_EXAMPLES_AJOYSTICK_SIGNO=13
+ STATUS:
+ 2014-12-04:
+ - Without ADC DMA support, it is not possible to sample both X and Y
+ with a single ADC. Right now, only one axis is being converted.
+ - There is conflicts with some of the Arduino data pins and the
+ default USART1 configuration. I am currently running with USART1
+ but with CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS to eliminate the
+ conflict.
+ - Current showstopper: I appear to be getting infinite interrupts as
+ soon as joystick button interrupts are enabled.
+
Configurations
==============
@@ -605,8 +622,8 @@ Configurations
Nucleo CN10 STM32F4x1RE
----------- ------------
- Pin 21 PA9 USART1_RX
- Pin 33 PA10 USART1_TX
+ Pin 21 PA9 USART1_RX *Warning you make need to reverse RX/TX on
+ Pin 33 PA10 USART1_TX some RS-232 converters
Pin 20 GND
Pin 8 U5V
diff --git a/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h b/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
index d2138260a..3a92a8763 100644
--- a/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
+++ b/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
@@ -51,7 +51,8 @@
/* Configuration ********************************************************************/
#define HAVE_MMCSD 1
-#if !defined(CONFIG_STM32_SDIO) || !defined(CONFIG_MMCSD) || !defined(CONFIG_MMCSD_SDIO)
+#if !defined(CONFIG_STM32_SDIO) || !defined(CONFIG_MMCSD) || \
+ !defined(CONFIG_MMCSD_SDIO)
# undef HAVE_MMCSD
#endif
@@ -102,49 +103,67 @@
*/
#ifdef CONFIG_WL_CC3000
-# define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI)
-# define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_D14 (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_D15 (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | GPIO_PULLUP )
-# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | GPIO_PULLUP )
-# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-
-# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
-# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | GPIO_PULLUP )
-# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | GPIO_PULLUP )
+# define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | \
+ GPIO_PULLUP | GPIO_EXTI)
+# define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_D14 (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_D15 (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | \
+ GPIO_PULLUP)
+# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | \
+ GPIO_PULLUP)
+# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | \
+ GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
+# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | \
+ GPIO_PULLUP)
+# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | \
+ GPIO_PULLUP)
#endif
/* SPI1 off */
-#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN7)
-#define GPIO_SPI1_MISO_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN6)
-#define GPIO_SPI1_SCK_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN5)
+#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
+ GPIO_PORTA | GPIO_PIN7)
+#define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
+ GPIO_PORTA | GPIO_PIN6)
+#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
+ GPIO_PORTA | GPIO_PIN5)
/* SPI1 chip selects off */
#ifdef CONFIG_WL_CC3000
# define GPIO_SPI_CS_WIFI_OFF \
- (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTB|GPIO_PIN6)
+ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
+ GPIO_PORTB | GPIO_PIN6)
#endif
#ifdef HAVE_MMCSD
# define GPIO_SPI_CS_SD_CARD_OFF \
- (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTB|GPIO_PIN5)
+ (GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
+ GPIO_PORTB | GPIO_PIN5)
#endif
/* SPI chip selects */
#ifdef CONFIG_WL_CC3000
# define GPIO_SPI_CS_WIFI \
- (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN6)
+ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6)
#endif
#ifdef HAVE_MMCSD
# define GPIO_SPI_CS_SD_CARD \
- (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN5)
+ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
+ GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5)
#endif
/* Devices on the onboard bus.
@@ -162,13 +181,15 @@
#ifdef CONFIG_WL_CC3000
# define GPIO_GPIO0_INPUT \
- (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTB|GPIO_PIN8)
+ (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN8)
# define GPIO_GPIO1_INPUT \
- (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTB|GPIO_PIN9)
+ (GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN9)
# define GPIO_GPIO0_OUTPUT \
- (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN8)
+ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
+ GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN8)
# define GPIO_GPIO1_OUTPUT \
- (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN9)
+ (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
+ GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN9)
#endif
/* Itead Joystick Shield
@@ -187,31 +208,37 @@
* D7 Button A Output PA8
* D8 Button F Output PA9
* D9 Button G Output PC7
- * A0 Joystick Y Output PA0 ADC_IN0
- * A1 Joystick X Output PA1 ADC_IN1
+ * A0 Joystick Y Output PA0 ADC1_0
+ * A1 Joystick X Output PA1 ADC1_1
* --------- ----------------- ---------------------------------
*
* All buttons are pulled on the shield. A sensed low value indicates
* when the button is pressed.
+ *
+ * NOTE: Button F cannot be used with the default USART1 configuration
+ * because PA9 is configured for USART1_RX by default. Use select
+ * different USART1 pins in the board.h file or select a different
+ * USART or select CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS which will
+ * eliminate all but buttons A, B, and C.
*/
#define ADC_XOUPUT 1 /* X output is on ADC channel 1 */
#define ADC_YOUPUT 0 /* Y output is on ADC channel 0 */
#define GPIO_BUTTON_A \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTB | GPIO_PIN3)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN8)
#define GPIO_BUTTON_B \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTB | GPIO_PIN5)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN10)
#define GPIO_BUTTON_C \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTB | GPIO_PIN4)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN4)
#define GPIO_BUTTON_D \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTB | GPIO_PIN10)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN5)
#define GPIO_BUTTON_E \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTA | GPIO_PIN8)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN3)
#define GPIO_BUTTON_F \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTA | GPIO_PIN9)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN9)
#define GPIO_BUTTON_G \
- (GPIO_INPUT | GPIO_FLOAT |GPIO_EXTI | GPIO_PORTC | GPIO_PIN7)
+ (GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTC | GPIO_PIN7)
/* Itead Joystick Signal interpretation:
*
@@ -304,4 +331,16 @@ void board_led_initialize(void);
int board_adc_initialize(void);
#endif
+/****************************************************************************
+ * Name: board_ajoy_initialize
+ *
+ * Description:
+ * Initialize and register the button joystick driver
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_AJOYSTICK
+int board_ajoy_initialize(void);
+#endif
+
#endif /* __CONFIGS_NUCLEO_F401RE_SRC_NUCLEO_F401RE_H */
diff --git a/nuttx/configs/nucleo-f4x1re/src/stm32_adc.c b/nuttx/configs/nucleo-f4x1re/src/stm32_adc.c
index 6d0515e38..f1b1ffa7a 100644
--- a/nuttx/configs/nucleo-f4x1re/src/stm32_adc.c
+++ b/nuttx/configs/nucleo-f4x1re/src/stm32_adc.c
@@ -59,7 +59,11 @@
/* The number of ADC channels in the conversion list */
-#define ADC1_NCHANNELS 2
+#ifdef CONFIG_ADC_DMA
+# define ADC1_NCHANNELS 2
+#else
+# define ADC1_NCHANNELS 1
+#endif
/************************************************************************************
* Private Data
@@ -68,6 +72,7 @@
#ifdef CONFIG_STM32_ADC1
#ifdef CONFIG_AJOYSTICK
+#ifdef CONFIG_ADC_DMA
/* The Itead analog joystick gets inputs on ADC_IN0 and ADC_IN1 */
static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0, 1};
@@ -75,8 +80,21 @@ static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0, 1};
/* Configurations of pins used byte each ADC channels */
static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN0, GPIO_ADC1_IN0};
-#endif
-#endif
+
+#else
+/* Without DMA, only a single channel can be supported */
+
+/* The Itead analog joystick gets input on ADC_IN0 */
+
+static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0};
+
+/* Configurations of pins used byte each ADC channels */
+
+static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN0};
+
+#endif /* CONFIG_ADC_DMA */
+#endif /* CONFIG_AJOYSTICK */
+#endif /* CONFIG_STM32_ADC1*/
/************************************************************************************
* Private Functions
diff --git a/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c b/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
index 4a3de9033..17b01193e 100644
--- a/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
+++ b/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
@@ -69,20 +69,43 @@
#ifdef CONFIG_AJOYSTICK
+/* A no-ADC, buttons only version can be built for testing */
+
+#undef NO_JOYSTICK_ADC
+
/* Maximum number of ADC channels */
#define MAX_ADC_CHANNELS 8
+/* Dual channel ADC support requires DMA */
+
+#ifdef CONFIG_ADC_DMA
+# define NJOYSTICK_CHANNELS 2
+#else
+# define NJOYSTICK_CHANNELS 1
+#endif
+
+#ifdef CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS
+/* Number of Joystick buttons */
+
+# define AJOY_NGPIOS 3
+
+/* Bitset of supported Joystick buttons */
+
+# define AJOY_SUPPORTED (AJOY_BUTTON_1_BIT | AJOY_BUTTON_2_BIT | \
+ AJOY_BUTTON_3_BIT)
+#else
/* Number of Joystick buttons */
-#define AJOY_NGPIOS 7
+# define AJOY_NGPIOS 7
/* Bitset of supported Joystick buttons */
-#define AJOY_SUPPORTED (AJOY_BUTTON_1_BIT | AJOY_BUTTON_2_BIT | \
- AJOY_BUTTON_3_BIT | AJOY_BUTTON_4_BIT | \
- AJOY_BUTTON_5_BIT | AJOY_BUTTON_6_BIT | \
- AJOY_BUTTON_7_BIT )
+# define AJOY_SUPPORTED (AJOY_BUTTON_1_BIT | AJOY_BUTTON_2_BIT | \
+ AJOY_BUTTON_3_BIT | AJOY_BUTTON_4_BIT | \
+ AJOY_BUTTON_5_BIT | AJOY_BUTTON_6_BIT | \
+ AJOY_BUTTON_7_BIT )
+#endif
/****************************************************************************
* Private Types
@@ -110,11 +133,18 @@ static int ajoy_interrupt(int irq, FAR void *context);
* button definitions in include/nuttx/input/ajoystick.h.
*/
+#ifdef CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS
+static const uint32_t g_joygpio[AJOY_NGPIOS] =
+{
+ GPIO_BUTTON_1, GPIO_BUTTON_2, GPIO_BUTTON_3
+};
+#else
static const uint32_t g_joygpio[AJOY_NGPIOS] =
{
GPIO_BUTTON_1, GPIO_BUTTON_2, GPIO_BUTTON_3, GPIO_BUTTON_4,
- GPIO_BUTTON_5, GPIO_BUTTON_6, GPIO_BUTTON_6
+ GPIO_BUTTON_5, GPIO_BUTTON_6, GPIO_BUTTON_7
};
+#endif
/* This is the button joystick lower half driver interface */
@@ -126,9 +156,11 @@ static const struct ajoy_lowerhalf_s g_ajoylower =
.al_enable = ajoy_enable,
};
+#ifndef NO_JOYSTICK_ADC
/* Descriptor for the open ADC driver */
static int g_adcfd = -1;
+#endif
/* Current interrupt handler and argument */
@@ -164,6 +196,7 @@ static ajoy_buttonset_t ajoy_supported(FAR const struct ajoy_lowerhalf_s *lower)
static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
FAR struct ajoy_sample_s *sample)
{
+#ifndef NO_JOYSTICK_ADC
struct adc_msg_s adcmsg[MAX_ADC_CHANNELS];
FAR struct adc_msg_s *ptr;
ssize_t nread;
@@ -186,7 +219,7 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
return -errcode;
}
- else if (nread < 2 * sizeof(struct adc_msg_s))
+ else if (nread < NJOYSTICK_CHANNELS * sizeof(struct adc_msg_s))
{
idbg("ERROR: read too small: %ld\n", (long)nread);
return -EIO;
@@ -194,7 +227,17 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
/* Sample and the raw analog inputs */
- for (i = 0, offset = 0, have = 0;
+#ifdef CONFIG_ADC_DMA
+ have = 0;
+
+#else
+ /* If DMA is not supported, then we will have only a single ADC channel */
+
+ have = 2;
+ sample->as_y = 0;
+#endif
+
+ for (i = 0, offset = 0;
i < MAX_ADC_CHANNELS && offset < nread && have != 3;
i++, offset += sizeof(struct adc_msg_s))
{
@@ -211,6 +254,7 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
ivdbg("X sample: %ld -> %d\n", (long)tmp, (int)sample->as_x);
}
+#ifdef CONFIG_ADC_DMA
if ((have & 2) == 0 && ptr->am_channel == 1)
{
int32_t tmp = ptr->am_data;
@@ -219,19 +263,26 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
ivdbg("Y sample: %ld -> %d\n", (long)tmp, (int)sample->as_y);
}
+#endif
}
if (have != 3)
{
- idbg("ERROR: Could not find joystack channels\n");
+ idbg("ERROR: Could not find joystick channels\n");
return -EIO;
}
+#else
+ /* ADC support is disabled */
+
+ sample->as_x = 0;
+ sample->as_y = 0;
+#endif
/* Sample the discrete button inputs */
sample->as_buttons = ajoy_buttons(lower);
- ivdbg("Returning: %02x\n", AJOY_SUPPORTED);
+ ivdbg("Returning: %02x\n", sample->as_buttons);
return OK;
}
@@ -375,6 +426,7 @@ static void ajoy_disable(void)
static int ajoy_interrupt(int irq, FAR void *context)
{
DEBUGASSERT(g_ajoyhandler);
+
if (g_ajoyhandler)
{
g_ajoyhandler(&g_ajoylower, g_ajoyarg);
@@ -388,18 +440,21 @@ static int ajoy_interrupt(int irq, FAR void *context)
****************************************************************************/
/****************************************************************************
- * Name: stm32_ajoy_initialization
+ * Name: board_ajoy_initialize
*
* Description:
* Initialize and register the button joystick driver
*
****************************************************************************/
-int stm32_ajoy_initialization(void)
+int board_ajoy_initialize(void)
{
int ret;
int i;
+#ifndef NO_JOYSTICK_ADC
+ ivdbg("Initialize ADC driver: /dev/adc0\n");
+
/* Initialize ADC. We will need this to read the ADC inputs */
ret = board_adc_initialize();
@@ -418,8 +473,12 @@ int stm32_ajoy_initialization(void)
idbg("ERROR: Failed to open /dev/adc0: %d\n", errcode);
return -errcode;
}
+#endif
- /* Configure the GPIO pins as interrupting inputs. */
+ /* Configure the GPIO pins as interrupting inputs. NOTE: This is
+ * unnecessary for interrupting pins since it will also be done by
+ * stm32_gpiosetevent().
+ */
for (i = 0; i < AJOY_NGPIOS; i++)
{
@@ -430,12 +489,16 @@ int stm32_ajoy_initialization(void)
/* Register the joystick device as /dev/ajoy0 */
+ ivdbg("Initialize joystick driver: /dev/ajoy0\n");
+
ret = ajoy_register("/dev/ajoy0", &g_ajoylower);
if (ret < 0)
{
idbg("ERROR: ajoy_register failed: %d\n", ret);
+#ifndef NO_JOYSTICK_ADC
close(g_adcfd);
g_adcfd = -1;
+#endif
}
return ret;
diff --git a/nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c b/nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c
index 458c87988..36337d41a 100644
--- a/nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c
+++ b/nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c
@@ -94,7 +94,7 @@ void up_netinitialize(void)
int nsh_archinitialize(void)
{
-#ifdef HAVE_MMCSD
+#if defined(HAVE_MMCSD) || defined(CONFIG_AJOYSTICK)
int ret;
#endif
@@ -135,5 +135,18 @@ int nsh_archinitialize(void)
syslog(LOG_INFO, "[boot] Initialized SDIO\n");
#endif
+#ifdef CONFIG_AJOYSTICK
+ /* Initialize and register the joystick driver */
+
+ ret = board_ajoy_initialize();
+ if (ret != OK)
+ {
+ syslog(LOG_ERR,
+ "ERROR: Failed to register the joystick driver: %d\n",
+ ret);
+ return ret;
+ }
+#endif
+
return OK;
}
diff --git a/nuttx/configs/sama5d3-xplained/src/sam_nsh.c b/nuttx/configs/sama5d3-xplained/src/sam_nsh.c
index aad5b8ad2..9f71b59f3 100644
--- a/nuttx/configs/sama5d3-xplained/src/sam_nsh.c
+++ b/nuttx/configs/sama5d3-xplained/src/sam_nsh.c
@@ -152,7 +152,9 @@ int nsh_archinitialize(void)
ret = sam_ajoy_initialization();
if (ret != OK)
{
- syslog(LOG_ERR, "ERROR: Failed to register the joystick driver: %d\n", ret);
+ syslog(LOG_ERR,
+ "ERROR: Failed to register the joystick driver: %d\n",
+ ret);
return ret;
}
#endif
diff --git a/nuttx/configs/stm3210e-eval/src/stm32_djoystick.c b/nuttx/configs/stm3210e-eval/src/stm32_djoystick.c
index d0c8925c7..06add950a 100644
--- a/nuttx/configs/stm3210e-eval/src/stm32_djoystick.c
+++ b/nuttx/configs/stm3210e-eval/src/stm32_djoystick.c
@@ -284,8 +284,8 @@ int stm32_djoy_initialization(void)
{
int i;
- /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are
- * configured for some pins but NOT yet set up.
+ /* Configure the GPIO pins as inputs. NOTE: This is unnecessary for
+ * interrupting pins since it will also be done by stm32_gpiosetevent().
*/
for (i = 0; i < DJOY_NGPIOS; i++)
diff --git a/nuttx/drivers/eeprom/spi_xx25xx.c b/nuttx/drivers/eeprom/spi_xx25xx.c
index 95d86603a..e8c520d90 100644
--- a/nuttx/drivers/eeprom/spi_xx25xx.c
+++ b/nuttx/drivers/eeprom/spi_xx25xx.c
@@ -46,6 +46,12 @@
* 20 MHz for 25AA512, 25LC512, 25xx1024
* 20 MHz for Atmel devices (>4.5V)
* 10 MHz for Atmel devices (>2.5V)
+ * 20 MHz for <1Mbit STM devices (>4.5V)
+ * 16 MHz for 1Mbit STM devices (>4.5V)
+ * 10 MHz for all STM devices (>2.5V)
+ * 5 MHz for 1Mbit STM devices (>1.8V)
+ * 2 MHz for 1Mbit STM devices (>1.7V)
+ * 5 MHz for 2Mbit STM devices
* All devices have the same instruction set.
*
* The following devices should be supported:
@@ -89,6 +95,19 @@
* AT25256B 32768 64 2
* AT25512 65536 128 2
* AT25M01 131072 256 3
+ * ST Microelectronics
+ * M95010 128 16 1
+ * M95020 256 16 1
+ * M95040 512 16 1+bit
+ * M95080 1024 32 2
+ * M95160 2048 32 2
+ * M95320 4096 32 2
+ * M95640 8192 32 2
+ * M95128 16384 64 2
+ * M95256 32768 64 2
+ * M95512 65536 128 2
+ * M95M01 131072 256 3
+ * M95M02 262144 256 3
*/
/****************************************************************************
@@ -125,11 +144,15 @@
#define EE25XX_CMD_WREN 0x06
/* Following commands will be available some day via IOCTLs
- * PE 0x42 Page erase (25xx512/1024)
- * SE 0xD8 Sector erase (25xx512/1024)
- * CE 0xC7 Chip erase (25xx512/1024)
- * RDID 0xAB Wake up and read electronic signature (25xx512/1024)
- * DPD 0xB9 Sleep (25xx512/1024)
+ * PE 0x42 Page erase (25xx512/1024)
+ * SE 0xD8 Sector erase (25xx512/1024)
+ * CE 0xC7 Chip erase (25xx512/1024)
+ * RDID 0xAB Wake up and read electronic signature (25xx512/1024)
+ * DPD 0xB9 Sleep (25xx512/1024)
+ *
+ * Identification page access for ST devices
+ * RDID/RDLS 0x83 Read identification page / Read ID page lock status
+ * WRID/LID 0x82 Write identification page / Lock ID page
*/
/* SR bits definitions */
@@ -160,7 +183,7 @@ struct ee25xx_geom_s
struct ee25xx_dev_s
{
- struct spi_dev_s *spi; /* spi device where the EEPROM is attached */
+ struct spi_dev_s *spi; /* SPI device where the EEPROM is attached */
uint32_t size; /* in bytes, expanded from geometry */
uint16_t pgsize; /* write block size, in bytes, expanded from geometry */
uint16_t addrlen; /* number of BITS in data addresses */
@@ -196,25 +219,29 @@ static const struct ee25xx_geom_s g_ee25xx_devices[] =
{
/* Microchip devices */
- { 0, 1, 1, 0}, /*25xx010A 128 16 1*/
- { 1, 1, 1, 0}, /*25xx020A 256 16 1*/
- { 2, 1, 1, 1}, /*25xx040 512 16 1+bit*/
- { 3, 1, 1, 0}, /*25xx080 1024 16 1*/
- { 3, 2, 2, 0}, /*25xx080B 1024 32 2*/
- { 4, 1, 2, 0}, /*25xx160 2048 16 2*/
- { 4, 2, 2, 0}, /*25xx160B/D 2048 32 2*/
- { 5, 2, 2, 0}, /*25xx320 4096 32 2*/
- { 6, 2, 2, 0}, /*25xx640 8192 32 2*/
- { 7, 3, 2, 0}, /*25xx128 16384 64 2*/
- { 8, 3, 2, 0}, /*25xx256 32768 64 2*/
- { 9, 4, 2, 0}, /*25xx512 65536 128 2*/
- {10, 5, 3, 0}, /*25xx1024 131072 256 3*/
+ { 0, 1, 1, 0}, /* 25xx010A 128 16 1*/
+ { 1, 1, 1, 0}, /* 25xx020A 256 16 1*/
+ { 2, 1, 1, 1}, /* 25xx040 512 16 1+bit*/
+ { 3, 1, 1, 0}, /* 25xx080 1024 16 1*/
+ { 3, 2, 2, 0}, /* 25xx080B 1024 32 2*/
+ { 4, 1, 2, 0}, /* 25xx160 2048 16 2*/
+ { 4, 2, 2, 0}, /* 25xx160B/D 2048 32 2*/
+ { 5, 2, 2, 0}, /* 25xx320 4096 32 2*/
+ { 6, 2, 2, 0}, /* 25xx640 8192 32 2*/
+ { 7, 3, 2, 0}, /* 25xx128 16384 64 2*/
+ { 8, 3, 2, 0}, /* 25xx256 32768 64 2*/
+ { 9, 4, 2, 0}, /* 25xx512 65536 128 2*/
+ {10, 5, 3, 0}, /* 25xx1024 131072 256 3*/
/* Atmel devices */
- { 0, 0, 1, 0}, /*AT25010B 128 8 1*/
- { 1, 0, 1, 0}, /*AT25020B 256 8 1*/
- { 2, 0, 1, 1}, /*AT25040B 512 8 1+bit*/
+ { 0, 0, 1, 0}, /* AT25010B 128 8 1*/
+ { 1, 0, 1, 0}, /* AT25020B 256 8 1*/
+ { 2, 0, 1, 1}, /* AT25040B 512 8 1+bit*/
+
+ /* STM devices */
+
+ {11, 5, 3, 0}, /* M95M02 262144 256 3*/
};
/* Driver operations */
diff --git a/nuttx/drivers/input/ajoystick.c b/nuttx/drivers/input/ajoystick.c
index 9f2416c46..de4d52f40 100644
--- a/nuttx/drivers/input/ajoystick.c
+++ b/nuttx/drivers/input/ajoystick.c
@@ -706,7 +706,7 @@ static int ajoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
opriv->ao_notify.an_press = notify->an_press;
opriv->ao_notify.an_release = notify->an_release;
- opriv->ao_notify.an_signo = notify->an_signo;
+ opriv->ao_notify.an_signo = notify->an_signo;
opriv->ao_pid = getpid();
/* Enable/disable interrupt handling */
diff --git a/nuttx/include/nuttx/eeprom/spi_xx25xx.h b/nuttx/include/nuttx/eeprom/spi_xx25xx.h
index ec3fcaa2a..4f01a3aab 100644
--- a/nuttx/include/nuttx/eeprom/spi_xx25xx.h
+++ b/nuttx/include/nuttx/eeprom/spi_xx25xx.h
@@ -66,7 +66,11 @@ enum eeprom_25xx_e
EEPROM_AT25020B,
EEPROM_AT25040B,
- /* Aliases (devices similar to previously defined ones)*/
+ /* STM geometries */
+
+ EEPROM_M95M02,
+
+ /* Aliases (devices similar to previously defined ones) */
EEPROM_AT25080B = EEPROM_25xx080B,
EEPROM_AT25160B = EEPROM_25xx160B,
@@ -76,6 +80,17 @@ enum eeprom_25xx_e
EEPROM_AT225256B = EEPROM_25xx256,
EEPROM_AT25512 = EEPROM_25xx512,
EEPROM_AT25M02 = EEPROM_25xx1024,
+ EEPROM_M95010 = EEPROM_25xx010,
+ EEPROM_M95020 = EEPROM_25xx020,
+ EEPROM_M95040 = EEPROM_25xx040,
+ EEPROM_M95080 = EEPROM_25xx080B,
+ EEPROM_M95160 = EEPROM_25xx160B,
+ EEPROM_M95320 = EEPROM_25xx320,
+ EEPROM_M95640 = EEPROM_25xx640,
+ EEPROM_M95128 = EEPROM_25xx128,
+ EEPROM_M95256 = EEPROM_25xx256,
+ EEPROM_M95512 = EEPROM_25xx512,
+ EEPROM_M95M01 = EEPROM_25xx1024,
};
/****************************************************************************