summaryrefslogtreecommitdiff
path: root/nuttx/configs/nucleo-f4x1re
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-04 09:37:46 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-04 09:37:46 -0600
commit59a65f8512aa66ee532283e11d6026a1086305d0 (patch)
treea4337248918a202c1dad1f6fa19ea65f7b3dad9f /nuttx/configs/nucleo-f4x1re
parent03af5a6188c0a61ef1913d1e3a1adec276ae7e7a (diff)
downloadnuttx-59a65f8512aa66ee532283e11d6026a1086305d0.tar.gz
nuttx-59a65f8512aa66ee532283e11d6026a1086305d0.tar.bz2
nuttx-59a65f8512aa66ee532283e11d6026a1086305d0.zip
Nucleo-F4x1RE: Fix some joystick shield logic
Diffstat (limited to 'nuttx/configs/nucleo-f4x1re')
-rw-r--r--nuttx/configs/nucleo-f4x1re/README.txt12
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h12
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_adc.c24
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c28
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_nsh.c15
5 files changed, 77 insertions, 14 deletions
diff --git a/nuttx/configs/nucleo-f4x1re/README.txt b/nuttx/configs/nucleo-f4x1re/README.txt
index 835bad18b..4b40e4ac4 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:
@@ -605,8 +605,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..90896fd11 100644
--- a/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
+++ b/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
@@ -304,4 +304,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..69e0c209d 100644
--- a/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
+++ b/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
@@ -73,6 +73,14 @@
#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
+
/* Number of Joystick buttons */
#define AJOY_NGPIOS 7
@@ -186,7 +194,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 +202,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 +229,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,6 +238,7 @@ 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)
@@ -388,14 +408,14 @@ 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;
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;
}