summaryrefslogtreecommitdiff
path: root/nuttx/configs
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-04 10:15:36 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-04 10:15:36 -0600
commit68510160cd614b39f412a58941e342a80ac4d5a9 (patch)
treeb3674c6f1f51232d5b2a10f6aa208a03e8b76bda /nuttx/configs
parent59a65f8512aa66ee532283e11d6026a1086305d0 (diff)
downloadnuttx-68510160cd614b39f412a58941e342a80ac4d5a9.tar.gz
nuttx-68510160cd614b39f412a58941e342a80ac4d5a9.tar.bz2
nuttx-68510160cd614b39f412a58941e342a80ac4d5a9.zip
Nucleo-f4x1re: Add comments about pin conflicts; Fix GPIO configuration
Diffstat (limited to 'nuttx/configs')
-rw-r--r--nuttx/configs/nucleo-f4x1re/README.txt5
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h5
-rw-r--r--nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c25
3 files changed, 33 insertions, 2 deletions
diff --git a/nuttx/configs/nucleo-f4x1re/README.txt b/nuttx/configs/nucleo-f4x1re/README.txt
index 4b40e4ac4..2d836583c 100644
--- a/nuttx/configs/nucleo-f4x1re/README.txt
+++ b/nuttx/configs/nucleo-f4x1re/README.txt
@@ -536,6 +536,11 @@ Shields
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
+
Itead Joystick Signal interpretation:
--------- ----------------------- ---------------------------
diff --git a/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h b/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
index 90896fd11..880d1748a 100644
--- a/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
+++ b/nuttx/configs/nucleo-f4x1re/src/nucleo-f4x1re.h
@@ -193,6 +193,11 @@
*
* 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
*/
#define ADC_XOUPUT 1 /* X output is on ADC channel 1 */
diff --git a/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c b/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
index 69e0c209d..37c2eead3 100644
--- a/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
+++ b/nuttx/configs/nucleo-f4x1re/src/stm32_ajoystick.c
@@ -69,6 +69,10 @@
#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
@@ -121,7 +125,7 @@ static int ajoy_interrupt(int irq, FAR void *context);
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
};
/* This is the button joystick lower half driver interface */
@@ -134,9 +138,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 */
@@ -172,6 +178,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;
@@ -243,10 +250,16 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower,
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 */
@@ -420,6 +433,9 @@ 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();
@@ -438,6 +454,7 @@ int board_ajoy_initialize(void)
idbg("ERROR: Failed to open /dev/adc0: %d\n", errcode);
return -errcode;
}
+#endif
/* Configure the GPIO pins as interrupting inputs. */
@@ -450,12 +467,16 @@ int board_ajoy_initialize(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;