You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/06/11 23:05:21 UTC

[incubator-nuttx] branch master updated (48dffbb -> 6c68c2b)

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 48dffbb  boards: spresense: Add nxrecorder to wifi/defconfig
     new 72ff383  boards/arm/stm32/stm3210e-eval/include/board.h: Fix buttons bits when CONFIG_DJOYSTICK is enabled.
     new fe7dfec  include/nuttx/input/djoystick.h: Fix some trivial typos and nxstyle issues.
     new c3ba603  boards/arm/stm32/olimex-stm32-p407: Add joystick support.
     new 6c68c2b  boards/arm/stm32/stm3210e-eval/include/board.h: Fix nxstyle issues.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 boards/arm/stm32/olimex-stm32-p407/include/board.h |  42 +++++---
 boards/arm/stm32/olimex-stm32-p407/src/Make.defs   |   4 +
 .../olimex-stm32-p407/src/olimex-stm32-p407.h      |  35 +++++--
 .../stm32/olimex-stm32-p407/src/stm32_bringup.c    |  10 +-
 .../stm32/olimex-stm32-p407/src/stm32_buttons.c    |  40 ++++---
 .../src/stm32_djoystick.c                          | 116 ++++++++++-----------
 boards/arm/stm32/stm3210e-eval/include/board.h     |  38 ++++---
 include/nuttx/input/djoystick.h                    |  24 +++--
 8 files changed, 181 insertions(+), 128 deletions(-)
 copy boards/arm/stm32/{stm3210e-eval => olimex-stm32-p407}/src/stm32_djoystick.c (67%)


[incubator-nuttx] 02/04: include/nuttx/input/djoystick.h: Fix some trivial typos and nxstyle issues.

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fe7dfec37ded04e5f6a002597c209a308190c10f
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Wed Jun 10 21:35:16 2020 +0100

    include/nuttx/input/djoystick.h: Fix some trivial typos and nxstyle
    issues.
---
 include/nuttx/input/djoystick.h | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/nuttx/input/djoystick.h b/include/nuttx/input/djoystick.h
index 885065a..d59eb5e 100644
--- a/include/nuttx/input/djoystick.h
+++ b/include/nuttx/input/djoystick.h
@@ -63,6 +63,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
 
 #ifndef CONFIG_DJOYSTICK_NPOLLWAITERS
@@ -70,6 +71,7 @@
 #endif
 
 /* Joystick Interface *******************************************************/
+
 /* These definitions provide the meaning of all of the bits that may be
  * reported in the djoy_buttonset_t bitset.
  */
@@ -114,8 +116,8 @@
  * seek() methods.  The remaining driver methods behave as follows:
  *
  * 1) The read() method will always return a single value of size
- *    djoy_buttonset_t represent the current state of the joystick buttons.
- *    read() never blocks.
+ *    djoy_buttonset_t that represents the current state of the joystick
+ *    buttons.  read() never blocks.
  * 2) The poll() method can be used to notify a client if there is a change
  *    in any of the joystick discrete inputs.  This feature, of course,
  *    depends upon interrupt GPIO support from the platform.  NOTE: that
@@ -140,7 +142,8 @@
  * Description: Specify the set of button events that can cause a poll()
  *              to awaken.  The default is all button depressions and all
  *              button releases (all supported buttons);
- * Argument:    A read-only pointer to an instance of struct djoy_pollevents_s
+ * Argument:    A read-only pointer to an instance of struct
+ *              djoy_pollevents_s
  * Return:      Zero (OK) on success.  Minus one will be returned on failure
  *              with the errno value set appropriately.
  */
@@ -162,15 +165,16 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* This type is a bit set that contains the state of all discrete joystick
  * buttons.
  */
 
 typedef uint8_t djoy_buttonset_t;
 
-/* A reference to this structure is provided with the DJOYIOC_POLLEVENTS IOCTL
- * command and describes the conditions under which the client would like
- * to receive notification.
+/* A reference to this structure is provided with the DJOYIOC_POLLEVENTS
+ * IOCTL command and describes the conditions under which the client would
+ * like to receive notification.
  */
 
 struct djoy_pollevents_s
@@ -216,13 +220,15 @@ struct djoy_lowerhalf_s
 {
   /* Return the set of buttons supported on the discrete joystick device */
 
-  CODE djoy_buttonset_t (*dl_supported)(FAR const struct djoy_lowerhalf_s *lower);
+  CODE djoy_buttonset_t (*dl_supported)
+    (FAR const struct djoy_lowerhalf_s *lower);
 
   /* Return the current state of all discrete joystick buttons */
 
-  CODE djoy_buttonset_t (*dl_sample)(FAR const struct djoy_lowerhalf_s *lower);
+  CODE djoy_buttonset_t (*dl_sample)
+    (FAR const struct djoy_lowerhalf_s *lower);
 
-  /* Enable interrupts on the selected set of joystick buttons.  And empty
+  /* Enable interrupts on the selected set of joystick buttons.  An empty
    * set will disable all interrupts.
    */
 


[incubator-nuttx] 04/04: boards/arm/stm32/stm3210e-eval/include/board.h: Fix nxstyle issues.

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 6c68c2b8920183bb5f73b32d5a16edbbc7033675
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Thu Jun 11 21:08:10 2020 +0100

    boards/arm/stm32/stm3210e-eval/include/board.h: Fix nxstyle issues.
---
 boards/arm/stm32/stm3210e-eval/include/board.h | 36 ++++++++++++++++----------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/boards/arm/stm32/stm3210e-eval/include/board.h b/boards/arm/stm32/stm3210e-eval/include/board.h
index 6a77ad8..e58ad10 100644
--- a/boards/arm/stm32/stm3210e-eval/include/board.h
+++ b/boards/arm/stm32/stm3210e-eval/include/board.h
@@ -46,22 +46,24 @@
 #endif
 
 /* Logic in arch/arm/src and boards/ may need to include these file prior to
- * including board.h:  stm32_rcc.h, stm32_sdio.h, stm32.h.  They cannot be included
- * here because board.h is used in other contexts where the STM32 internal header
- * files are not available.
+ * including board.h:  stm32_rcc.h, stm32_sdio.h, stm32.h.  They cannot be
+ * included here because board.h is used in other contexts where the STM32
+ * internal header files are not available.
  */
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Clocking *************************************************************************/
+/* Clocking *****************************************************************/
 
 /* On-board crystal frequency is 8MHz (HSE) */
 
 #define STM32_BOARD_XTAL        8000000ul
 
-/* PLL source is HSE/1, PLL multipler is 9: PLL frequency is 8MHz (XTAL) x 9 = 72MHz */
+/* PLL source is HSE/1, PLL multipler is 9:
+ *      PLL frequency is 8MHz (XTAL) x 9 = 72MHz
+ */
 
 #define STM32_CFGR_PLLSRC       RCC_CFGR_PLLSRC
 #define STM32_CFGR_PLLXTPRE     0
@@ -111,7 +113,8 @@
 
 /* Timer Frequencies, if APBx is set to 1, frequency is same to APBx
  * otherwise frequency is 2xAPBx.
- * Note: TIM1,8 are on APB2, others on APB1 */
+ * Note: TIM1,8 are on APB2, others on APB1
+ */
 
 #define BOARD_TIM1_FREQUENCY    STM32_HCLK_FREQUENCY
 #define BOARD_TIM2_FREQUENCY    STM32_HCLK_FREQUENCY
@@ -152,15 +155,18 @@
 #  define SDIO_SDXFR_CLKDIV     (3 << SDIO_CLKCR_CLKDIV_SHIFT)
 #endif
 
-/* SRAM definitions *****************************************************************/
-/* The 8 Mbit SRAM is provided on the PT3 board using the FSMC_NE3 chip select. */
+/* SRAM definitions *********************************************************/
+
+/* The 8 Mbit SRAM is provided on the PT3 board using the FSMC_NE3 chip
+ * select.
+ */
 
 /* This is the Bank1 SRAM3 address: */
 
 #define BOARD_SRAM_BASE    0x68000000     /* Bank2 SRAM3 base address */
 #define BOARD_SRAM_SIZE    (1*1024*1024)  /* 8-Mbit = 1-Mbyte */
 
-/* LED definitions ******************************************************************/
+/* LED definitions **********************************************************/
 
 /* The STM3210E-EVAL board has 4 LEDs that we will encode as: */
 
@@ -244,10 +250,11 @@ extern "C"
  * Name:  stm3210e_lcdclear
  *
  * Description:
- *   This is a non-standard LCD interface just for the STM3210E-EVAL board.  Because
- *   of the various rotations, clearing the display in the normal way by writing a
- *   sequences of runs that covers the entire display can be very slow.  Here the
- *   display is cleared by simply setting all GRAM memory to the specified color.
+ *   This is a non-standard LCD interface just for the STM3210E-EVAL board.
+ *   Because of the various rotations, clearing the display in the normal
+ *   way by writing a sequences of runs that covers the entire display can
+ *   be very slow.  Here the display is cleared by simply setting all GRAM
+ *   memory to the specified color.
  *
  ****************************************************************************/
 
@@ -284,7 +291,8 @@ int stm32_lm75initialize(FAR const char *devpath);
  *   arg        - The argument that will accompany the interrupt
  *
  * Returned Value:
- *   Zero (OK) returned on success; a negated errno value is returned on failure.
+ *   Zero (OK) returned on success; a negated errno value is returned on
+ *   failure.
  *
  ****************************************************************************/
 


[incubator-nuttx] 01/04: boards/arm/stm32/stm3210e-eval/include/board.h: Fix buttons bits when CONFIG_DJOYSTICK is enabled.

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 72ff383265e1bec2a84684d9049b884e2c18d1e2
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Wed Jun 10 21:33:43 2020 +0100

    boards/arm/stm32/stm3210e-eval/include/board.h: Fix buttons bits when
    CONFIG_DJOYSTICK is enabled.
---
 boards/arm/stm32/stm3210e-eval/include/board.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boards/arm/stm32/stm3210e-eval/include/board.h b/boards/arm/stm32/stm3210e-eval/include/board.h
index 0d33672..6a77ad8 100644
--- a/boards/arm/stm32/stm3210e-eval/include/board.h
+++ b/boards/arm/stm32/stm3210e-eval/include/board.h
@@ -213,7 +213,7 @@
 #define BUTTON_TAMPER_BIT    (1 << BUTTON_TAMPER)
 #define BUTTON_KEY_BIT       (1 << BUTTON_KEY)
 
-#ifdef CONFIG_DJOYSTICK
+#ifndef CONFIG_DJOYSTICK
 #  define JOYSTICK_SEL_BIT   (1 << JOYSTICK_SEL)
 #  define JOYSTICK_DOWN_BIT  (1 << JOYSTICK_DOWN)
 #  define JOYSTICK_LEFT_BIT  (1 << JOYSTICK_LEFT)


[incubator-nuttx] 03/04: boards/arm/stm32/olimex-stm32-p407: Add joystick support.

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c3ba6031349cad8a86c69abbe4b3438bbfd07e7d
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Wed Jun 10 22:31:33 2020 +0100

    boards/arm/stm32/olimex-stm32-p407: Add joystick support.
---
 boards/arm/stm32/olimex-stm32-p407/include/board.h |  42 +--
 boards/arm/stm32/olimex-stm32-p407/src/Make.defs   |   4 +
 .../olimex-stm32-p407/src/olimex-stm32-p407.h      |  35 ++-
 .../stm32/olimex-stm32-p407/src/stm32_bringup.c    |  10 +-
 .../stm32/olimex-stm32-p407/src/stm32_buttons.c    |  40 +--
 .../stm32/olimex-stm32-p407/src/stm32_djoystick.c  | 296 +++++++++++++++++++++
 6 files changed, 386 insertions(+), 41 deletions(-)

diff --git a/boards/arm/stm32/olimex-stm32-p407/include/board.h b/boards/arm/stm32/olimex-stm32-p407/include/board.h
index e5f5992..6d20355 100644
--- a/boards/arm/stm32/olimex-stm32-p407/include/board.h
+++ b/boards/arm/stm32/olimex-stm32-p407/include/board.h
@@ -209,23 +209,31 @@
 
 /* The Olimex STM32-P407 supports seven buttons: */
 
-#define BUTTON_TAMPER     0
-#define BUTTON_WKUP       1
-#define BUTTON_RIGHT      2
-#define BUTTON_UP         3
-#define BUTTON_LEFT       4
-#define BUTTON_DOWN       5
-#define BUTTON_CENTER     6
-
-#define NUM_BUTTONS       7
-
-#define BUTTON_TAMPER_BIT (1 << BUTTON_TAMPER)
-#define BUTTON_WKUP_BIT   (1 << BUTTON_WKUP)
-#define BUTTON_RIGHT_BIT  (1 << BUTTON_RIGHT)
-#define BUTTON_UP_BIT     (1 << BUTTON_UP)
-#define BUTTON_LEFT_BIT   (1 << BUTTON_LEFT)
-#define BUTTON_DOWN_BIT   (1 << BUTTON_DOWN)
-#define BUTTON_CENTER_BIT (1 << BUTTON_CENTER)
+#define BUTTON_TAMPER         0
+#define BUTTON_WKUP           1
+
+#ifdef CONFIG_DJOYSTICK
+#  define NUM_BUTTONS         2
+#else
+#  define JOYSTICK_RIGHT      2
+#  define JOYSTICK_UP         3
+#  define JOYSTICK_LEFT       4
+#  define JOYSTICK_DOWN       5
+#  define JOYSTICK_CENTER     6
+
+#  define NUM_BUTTONS         7
+#endif
+
+#define BUTTON_TAMPER_BIT     (1 << BUTTON_TAMPER)
+#define BUTTON_WKUP_BIT       (1 << BUTTON_WKUP)
+
+#ifndef CONFIG_DJOYSTICK
+#  define JOYSTICK_RIGHT_BIT  (1 << JOYSTICK_RIGHT)
+#  define JOYSTICK_UP_BIT     (1 << JOYSTICK_UP)
+#  define JOYSTICK_LEFT_BIT   (1 << JOYSTICK_LEFT)
+#  define JOYSTICK_DOWN_BIT   (1 << JOYSTICK_DOWN)
+#  define JOYSTICK_CENTER_BIT (1 << JOYSTICK_CENTER)
+#endif
 
 /* Alternate function pin selections ****************************************/
 
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/Make.defs b/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
index 7274cc9..d6a2691 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
+++ b/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
@@ -71,6 +71,10 @@ ifeq ($(CONFIG_AUDIO_CS4344),y)
   CSRCS += stm32_cs4344.c
 endif
 
+ifeq ($(CONFIG_DJOYSTICK),y)
+  CSRCS += stm32_djoystick.c
+endif
+
 DEPPATH += --dep-path board
 VPATH += :board
 CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
index c5e380a..0f25f50 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
+++ b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
@@ -159,17 +159,24 @@
 
 /* BUTTONS -- NOTE that all have EXTI interrupts configured */
 
-#define MIN_IRQBUTTON     BUTTON_TAMPER
-#define MAX_IRQBUTTON     BUTTON_CENTER
-#define NUM_IRQBUTTONS    7
+#ifdef CONFIG_DJOYSTICK
+#  define MIN_IRQBUTTON     BUTTON_TAMPER
+#  define MAX_IRQBUTTON     BUTTON_WKUP
+#  define NUM_IRQBUTTONS    2
+#else
+#  define MIN_IRQBUTTON     BUTTON_TAMPER
+#  define MAX_IRQBUTTON     JOYSTICK_CENTER
+#  define NUM_IRQBUTTONS    7
+#endif
 
 #define GPIO_BTN_TAMPER   (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN13)
 #define GPIO_BTN_WKUP     (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN0)
-#define GPIO_BTN_RIGHT    (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN6)
-#define GPIO_BTN_UP       (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
-#define GPIO_BTN_LEFT     (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN11)
-#define GPIO_BTN_DOWN     (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
-#define GPIO_BTN_CENTER   (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
+
+#define GPIO_JOY_RIGHT    (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN6)
+#define GPIO_JOY_UP       (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
+#define GPIO_JOY_LEFT     (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN11)
+#define GPIO_JOY_DOWN     (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
+#define GPIO_JOY_CENTER   (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
 
 /* USB OTG FS
  *
@@ -324,5 +331,17 @@ int stm32_can_setup(void);
 int stm32_cs4344_initialize(int minor);
 #endif
 
+/****************************************************************************
+ * Name: stm32_djoy_initialize
+ *
+ * Description:
+ *   Initialize and register the discrete joystick driver
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DJOYSTICK
+int stm32_djoy_initialize(void);
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* __BOARDS_ARM_STM32_OLIMEX_STM32_P407_SRC_H */
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
index 7431d87..9be0369 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
+++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
@@ -219,7 +219,15 @@ int stm32_bringup(void)
   ret = stm32_cs4344_initialize(1);
   if (ret != OK)
     {
-      serr("Failed to initialize CS43L22 audio: %d\n", ret);
+      syslog(LOG_ERR, "Failed to initialize CS4344 audio: %d\n", ret);
+    }
+#endif
+
+#ifdef CONFIG_DJOYSTICK
+  ret = stm32_djoy_initialize();
+  if (ret != OK)
+    {
+      syslog(LOG_ERR, "Failed to register djoystick driver: %d\n", ret);
     }
 #endif
 
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_buttons.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_buttons.c
index 2a3c0f9..12cf7ac 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_buttons.c
+++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_buttons.c
@@ -64,11 +64,19 @@ static const uint32_t g_buttons[NUM_BUTTONS] =
 {
   GPIO_BTN_TAMPER,
   GPIO_BTN_WKUP,
-  GPIO_BTN_RIGHT,
-  GPIO_BTN_UP,
-  GPIO_BTN_LEFT,
-  GPIO_BTN_DOWN,
-  GPIO_BTN_CENTER
+
+  /* The Joystick is treated like the other buttons unless CONFIG_DJOYSTICK
+   * is defined, then it is assumed that they should be used by the discrete
+   * joystick driver.
+   */
+
+#ifndef CONFIG_DJOYSTICK
+  GPIO_JOY_RIGHT,
+  GPIO_JOY_UP,
+  GPIO_JOY_LEFT,
+  GPIO_JOY_DOWN,
+  GPIO_JOY_CENTER
+#endif
 };
 
 /****************************************************************************
@@ -122,30 +130,32 @@ uint32_t board_buttons(void)
       ret |= BUTTON_WKUP_BIT;
     }
 
-  if (stm32_gpioread(g_buttons[BUTTON_RIGHT]))
+#ifndef CONFIG_DJOYSTICK
+  if (stm32_gpioread(g_buttons[JOYSTICK_RIGHT]))
     {
-      ret |= BUTTON_RIGHT_BIT;
+      ret |= JOYSTICK_RIGHT_BIT;
     }
 
-  if (stm32_gpioread(g_buttons[BUTTON_UP]))
+  if (stm32_gpioread(g_buttons[JOYSTICK_UP]))
     {
-      ret |= BUTTON_UP_BIT;
+      ret |= JOYSTICK_UP_BIT;
     }
 
-  if (stm32_gpioread(g_buttons[BUTTON_LEFT]))
+  if (stm32_gpioread(g_buttons[JOYSTICK_LEFT]))
     {
-      ret |= BUTTON_LEFT_BIT;
+      ret |= JOYSTICK_LEFT_BIT;
     }
 
-  if (stm32_gpioread(g_buttons[BUTTON_DOWN]))
+  if (stm32_gpioread(g_buttons[JOYSTICK_DOWN]))
     {
-      ret |= BUTTON_DOWN_BIT;
+      ret |= JOYSTICK_DOWN_BIT;
     }
 
-  if (stm32_gpioread(g_buttons[BUTTON_CENTER]))
+  if (stm32_gpioread(g_buttons[JOYSTICK_CENTER]))
     {
-      ret |= BUTTON_CENTER_BIT;
+      ret |= JOYSTICK_CENTER_BIT;
     }
+#endif
 
   return ret;
 }
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_djoystick.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_djoystick.c
new file mode 100644
index 0000000..28c717e
--- /dev/null
+++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_djoystick.c
@@ -0,0 +1,296 @@
+/****************************************************************************
+ * boards/arm/stm32/olimex-stm32-p407/src/stm32_djoystick.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <debug.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/input/djoystick.h>
+
+#include "stm32_gpio.h"
+#include "olimex-stm32-p407.h"
+
+#ifdef CONFIG_DJOYSTICK
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Number of Joystick discretes */
+
+#define DJOY_NGPIOS  5
+
+/* Bitset of supported Joystick discretes */
+
+#define DJOY_SUPPORTED (DJOY_UP_BIT | DJOY_DOWN_BIT | DJOY_LEFT_BIT | \
+                        DJOY_RIGHT_BIT | DJOY_BUTTON_SELECT_BIT)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static djoy_buttonset_t
+  djoy_supported(FAR const struct djoy_lowerhalf_s *lower);
+static djoy_buttonset_t
+  djoy_sample(FAR const struct djoy_lowerhalf_s *lower);
+static void djoy_enable(FAR const struct djoy_lowerhalf_s *lower,
+                        djoy_buttonset_t press, djoy_buttonset_t release,
+                        djoy_interrupt_t handler, FAR void *arg);
+
+static void djoy_disable(void);
+static int djoy_interrupt(int irq, FAR void *context, FAR void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Pin configuration for each Olimex-P407 joystick "button."  Index using
+ * DJOY_* definitions in include/nuttx/input/djoystick.h.
+ */
+
+static const uint16_t g_joygpio[DJOY_NGPIOS] =
+{
+  GPIO_JOY_UP, GPIO_JOY_DOWN, GPIO_JOY_LEFT, GPIO_JOY_RIGHT, GPIO_JOY_CENTER
+};
+
+/* Current interrupt handler and argument */
+
+static djoy_interrupt_t g_djoyhandler;
+static FAR void *g_djoyarg;
+
+/* This is the discrete joystick lower half driver interface */
+
+static const struct djoy_lowerhalf_s g_djoylower =
+{
+  .dl_supported  = djoy_supported,
+  .dl_sample     = djoy_sample,
+  .dl_enable     = djoy_enable,
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: djoy_supported
+ *
+ * Description:
+ *   Return the set of buttons supported on the discrete joystick device
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t
+  djoy_supported(FAR const struct djoy_lowerhalf_s *lower)
+{
+  iinfo("Supported: %02x\n", DJOY_SUPPORTED);
+  return (djoy_buttonset_t)DJOY_SUPPORTED;
+}
+
+/****************************************************************************
+ * Name: djoy_sample
+ *
+ * Description:
+ *   Return the current state of all discrete joystick buttons
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t djoy_sample(FAR const struct djoy_lowerhalf_s *lower)
+{
+  djoy_buttonset_t ret = 0;
+  int i;
+
+  /* Read each joystick GPIO value */
+
+  for (i = 0; i < DJOY_NGPIOS; i++)
+    {
+      bool released = stm32_gpioread(g_joygpio[i]);
+      if (!released)
+        {
+           ret |= (1 << i);
+        }
+    }
+
+  iinfo("Retuning: %02x\n", DJOY_SUPPORTED);
+  return ret;
+}
+
+/****************************************************************************
+ * Name: djoy_enable
+ *
+ * Description:
+ *   Enable interrupts on the selected set of joystick buttons.  And empty
+ *   set will disable all interrupts.
+ *
+ ****************************************************************************/
+
+static void djoy_enable(FAR const struct djoy_lowerhalf_s *lower,
+                         djoy_buttonset_t press, djoy_buttonset_t release,
+                         djoy_interrupt_t handler, FAR void *arg)
+{
+  irqstate_t flags;
+  djoy_buttonset_t either = press | release;
+  djoy_buttonset_t bit;
+  bool rising;
+  bool falling;
+  int i;
+
+  /* Start with all interrupts disabled */
+
+  flags = enter_critical_section();
+  djoy_disable();
+
+  iinfo("press: %02x release: %02x handler: %p arg: %p\n",
+        press, release, handler, arg);
+
+  /* If no events are indicated or if no handler is provided, then this
+   * must really be a request to disable interrupts.
+   */
+
+  if (either && handler)
+    {
+      /* Save the new the handler and argument */
+
+      g_djoyhandler = handler;
+      g_djoyarg     = arg;
+
+      /* Check each GPIO. */
+
+      for (i = 0; i < DJOY_NGPIOS; i++)
+        {
+          /* Enable interrupts on each pin that has either a press or
+           * release event associated with it.
+           */
+
+          bit = (1 << i);
+          if ((either & bit) != 0)
+            {
+              /* Active low so a press corresponds to a falling edge and
+               * a release corresponds to a rising edge.
+               */
+
+              falling = ((press & bit) != 0);
+              rising  = ((release & bit) != 0);
+
+              iinfo("GPIO %d: rising: %d falling: %d\n",
+                     i, rising, falling);
+
+              stm32_gpiosetevent(g_joygpio[i], rising, falling,
+                                 true, djoy_interrupt, NULL);
+            }
+        }
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Name: djoy_disable
+ *
+ * Description:
+ *   Disable all joystick interrupts
+ *
+ ****************************************************************************/
+
+static void djoy_disable(void)
+{
+  irqstate_t flags;
+  int i;
+
+  /* Disable each joystick interrupt */
+
+  flags = enter_critical_section();
+  for (i = 0; i < DJOY_NGPIOS; i++)
+    {
+      stm32_gpiosetevent(g_joygpio[i], false, false, false, NULL, NULL);
+    }
+
+  leave_critical_section(flags);
+
+  /* Nullify the handler and argument */
+
+  g_djoyhandler = NULL;
+  g_djoyarg     = NULL;
+}
+
+/****************************************************************************
+ * Name: djoy_interrupt
+ *
+ * Description:
+ *   Discrete joystick interrupt handler
+ *
+ ****************************************************************************/
+
+static int djoy_interrupt(int irq, FAR void *context, FAR void *arg)
+{
+  DEBUGASSERT(g_djoyhandler);
+  if (g_djoyhandler)
+    {
+      g_djoyhandler(&g_djoylower, g_djoyarg);
+    }
+
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_djoy_initialize
+ *
+ * Description:
+ *   Initialize and register the discrete joystick driver
+ *
+ ****************************************************************************/
+
+int stm32_djoy_initialize(void)
+{
+  int i;
+
+  /* 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++)
+    {
+      stm32_configgpio(g_joygpio[i]);
+    }
+
+  /* Make sure that all interrupts are disabled */
+
+  djoy_disable();
+
+  /* Register the joystick device as /dev/djoy0 */
+
+  return djoy_register("/dev/djoy0", &g_djoylower);
+}
+
+#endif /* CONFIG_DJOYSTICK */