summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/configs/stm3210e-eval/include/board.h62
-rw-r--r--nuttx/configs/stm3210e-eval/src/stm3210e-eval.h67
-rw-r--r--nuttx/configs/stm3210e-eval/src/stm32_buttons.c13
-rw-r--r--nuttx/configs/stm3210e-eval/src/stm32_pmbuttons.c14
4 files changed, 94 insertions, 62 deletions
diff --git a/nuttx/configs/stm3210e-eval/include/board.h b/nuttx/configs/stm3210e-eval/include/board.h
index e13495403..25cbcd402 100644
--- a/nuttx/configs/stm3210e-eval/include/board.h
+++ b/nuttx/configs/stm3210e-eval/include/board.h
@@ -167,41 +167,51 @@
/* The STM3210E-EVAL supports several buttons
*
- * Reset -- Connected to NRST
- * Wakeup -- Connected to PA.0
- * Tamper -- Connected to PC.13
- * Key -- Connected to PG.8
+ * Reset -- Connected to NRST
+ * Wakeup -- Connected to PA.0
+ * Tamper -- Connected to PC.13
+ * Key -- Connected to PG.8
*
* And a Joystick
*
- * Joystick center -- Connected to PG.7
- * Joystick down -- Connected to PD.3
- * Joystick left -- Connected to PG.14
- * Joystick right -- Connected to PG.13
- * Joystick up -- Connected to PG.15
+ * Joystick center -- Connected to PG.7
+ * Joystick down -- Connected to PD.3
+ * Joystick left -- Connected to PG.14
+ * Joystick right -- Connected to PG.13
+ * Joystick up -- Connected to PG.15
+ *
+ * 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.
*/
-#define BUTTON_WAKEUP 0
-#define BUTTON_TAMPER 1
-#define BUTTON_KEY 2
+#define BUTTON_WAKEUP 0
+#define BUTTON_TAMPER 1
+#define BUTTON_KEY 2
-#define JOYSTICK_SEL 3
-#define JOYSTICK_DOWN 4
-#define JOYSTICK_LEFT 5
-#define JOYSTICK_RIGHT 6
-#define JOYSTICK_UP 7
+#ifdef CONFIG_DJOYSTICK
+# define NUM_BUTTONS 3
+#else
+# define JOYSTICK_SEL 3
+# define JOYSTICK_DOWN 4
+# define JOYSTICK_LEFT 5
+# define JOYSTICK_RIGHT 6
+# define JOYSTICK_UP 7
-#define NUM_BUTTONS 8
+# define NUM_BUTTONS 8
+#endif
-#define BUTTON_WAKEUP_BIT (1 << BUTTON_WAKEUP)
-#define BUTTON_TAMPER_BIT (1 << BUTTON_TAMPER)
-#define BUTTON_KEY_BIT (1 << BUTTON_KEY)
+#define BUTTON_WAKEUP_BIT (1 << BUTTON_WAKEUP)
+#define BUTTON_TAMPER_BIT (1 << BUTTON_TAMPER)
+#define BUTTON_KEY_BIT (1 << BUTTON_KEY)
-#define JOYSTICK_SEL_BIT (1 << JOYSTICK_SEL)
-#define JOYSTICK_DOWN_BIT (1 << JOYSTICK_DOWN)
-#define JOYSTICK_LEFT_BIT (1 << JOYSTICK_LEFT)
-#define JOYSTICK_RIGHT_BIT (1 << JOYSTICK_RIGHT)
-#define JOYSTICK_UP_BIT (1 << JOYSTICK_UP)
+#ifdef CONFIG_DJOYSTICK
+# define JOYSTICK_SEL_BIT (1 << JOYSTICK_SEL)
+# define JOYSTICK_DOWN_BIT (1 << JOYSTICK_DOWN)
+# define JOYSTICK_LEFT_BIT (1 << JOYSTICK_LEFT)
+# define JOYSTICK_RIGHT_BIT (1 << JOYSTICK_RIGHT)
+# define JOYSTICK_UP_BIT (1 << JOYSTICK_UP)
+#endif
/************************************************************************************
* Public Data
diff --git a/nuttx/configs/stm3210e-eval/src/stm3210e-eval.h b/nuttx/configs/stm3210e-eval/src/stm3210e-eval.h
index a210def03..ed46aeb2c 100644
--- a/nuttx/configs/stm3210e-eval/src/stm3210e-eval.h
+++ b/nuttx/configs/stm3210e-eval/src/stm3210e-eval.h
@@ -68,42 +68,49 @@
/* STM3210E-EVAL GPIOs **************************************************************/
/* LEDs */
-#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN6)
-#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN7)
-#define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN8)
-#define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN9)
+#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
+ GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN6)
+#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
+ GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN7)
+#define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
+ GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN8)
+#define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
+ GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN9)
/* BUTTONS -- NOTE that some have EXTI interrupts configured */
-#define MIN_IRQBUTTON BUTTON_KEY
-#define MAX_IRQBUTTON JOYSTICK_UP
-#define NUM_IRQBUTTONS (JOYSTICK_UP - BUTTON_KEY + 1)
-
-#define GPIO_BTN_WAKEUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_PORTA|GPIO_PIN0)
-#define GPIO_BTN_TAMPER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_PORTC|GPIO_PIN13)
-#define GPIO_BTN_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
-#define GPIO_JOY_SEL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
-#define GPIO_JOY_DOWN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTD|GPIO_PIN3)
-#define GPIO_JOY_LEFT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTG|GPIO_PIN14)
-#define GPIO_JOY_RIGHT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTG|GPIO_PIN13)
-#define GPIO_JOY_UP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
+#ifdef CONFIG_DJOYSTICK
+# define MIN_IRQBUTTON BUTTON_KEY
+# define MAX_IRQBUTTON BUTTON_KEY
+# define NUM_IRQBUTTONS (1)
+#else
+# define MIN_IRQBUTTON BUTTON_KEY
+# define MAX_IRQBUTTON JOYSTICK_UP
+# define NUM_IRQBUTTONS (JOYSTICK_UP - BUTTON_KEY + 1)
+#endif
+
+#define GPIO_BTN_WAKEUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_PORTA|GPIO_PIN0)
+#define GPIO_BTN_TAMPER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_PORTC|GPIO_PIN13)
+#define GPIO_BTN_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
+
+#define GPIO_JOY_SEL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
+#define GPIO_JOY_DOWN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTD|GPIO_PIN3)
+#define GPIO_JOY_LEFT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTG|GPIO_PIN14)
+#define GPIO_JOY_RIGHT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTG|GPIO_PIN13)
+#define GPIO_JOY_UP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
/* SPI FLASH chip select: PA.4 */
-#define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2)
+#define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
+ GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2)
/* Backlight control: PA.8
*
diff --git a/nuttx/configs/stm3210e-eval/src/stm32_buttons.c b/nuttx/configs/stm3210e-eval/src/stm32_buttons.c
index 845eb5436..cb155feab 100644
--- a/nuttx/configs/stm3210e-eval/src/stm32_buttons.c
+++ b/nuttx/configs/stm3210e-eval/src/stm32_buttons.c
@@ -61,8 +61,16 @@
static const uint16_t g_buttons[NUM_BUTTONS] =
{
- GPIO_BTN_WAKEUP, GPIO_BTN_TAMPER, GPIO_BTN_KEY, GPIO_JOY_SEL,
- GPIO_JOY_DOWN, GPIO_JOY_LEFT, GPIO_JOY_RIGHT, GPIO_JOY_UP
+ GPIO_BTN_WAKEUP, GPIO_BTN_TAMPER, GPIO_BTN_KEY,
+
+ /* 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_SEL, GPIO_JOY_DOWN, GPIO_JOY_LEFT, GPIO_JOY_RIGHT, GPIO_JOY_UP
+#endif
};
/****************************************************************************
@@ -166,6 +174,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler);
}
+
return oldhandler;
}
#endif
diff --git a/nuttx/configs/stm3210e-eval/src/stm32_pmbuttons.c b/nuttx/configs/stm3210e-eval/src/stm32_pmbuttons.c
index a042a54e6..6b7677aca 100644
--- a/nuttx/configs/stm3210e-eval/src/stm32_pmbuttons.c
+++ b/nuttx/configs/stm3210e-eval/src/stm32_pmbuttons.c
@@ -63,8 +63,11 @@
# error "CONFIG_ARCH_BUTTONS is not defined in the configuration"
#endif
-#define BUTTON_MIN 0
-#define BUTTON_MAX 7
+#define BUTTON_MIN 0
+#ifdef CONFIG_DJOYSTICK
+# define BUTTON_MAX 2
+# define BUTTON_MAX 7
+#endif
#ifndef CONFIG_PM_BUTTONS_MIN
# define CONFIG_PM_BUTTONS_MIN BUTTON_MIN
@@ -76,8 +79,9 @@
#if CONFIG_PM_BUTTONS_MIN > CONFIG_PM_BUTTONS_MAX
# error "CONFIG_PM_BUTTONS_MIN > CONFIG_PM_BUTTONS_MAX"
#endif
-#if CONFIG_PM_BUTTONS_MAX > 7
-# error "CONFIG_PM_BUTTONS_MAX > 7"
+
+#if CONFIG_PM_BUTTONS_MAX > BUTTON_MAX
+# error "CONFIG_PM_BUTTONS_MAX > BUTTON_MAX"
#endif
#ifndef CONFIG_ARCH_IRQBUTTONS
@@ -87,6 +91,7 @@
#ifndef CONFIG_PM_IRQBUTTONS_MIN
# define CONFIG_PM_IRQBUTTONS_MIN CONFIG_PM_BUTTONS_MIN
#endif
+
#ifndef CONFIG_PM_IRQBUTTONS_MAX
# define CONFIG_PM_IRQBUTTONS_MAX CONFIG_PM_BUTTONS_MAX
#endif
@@ -94,6 +99,7 @@
#if CONFIG_PM_IRQBUTTONS_MIN > CONFIG_PM_IRQBUTTONS_MAX
# error "CONFIG_PM_IRQBUTTONS_MIN > CONFIG_PM_IRQBUTTONS_MAX"
#endif
+
#if CONFIG_PM_IRQBUTTONS_MAX > 7
# error "CONFIG_PM_IRQBUTTONS_MAX > 7"
#endif