diff --git a/configs/nucleo-f4x1re/Kconfig b/configs/nucleo-f4x1re/Kconfig index ae2bf31307d..bdd5b9c3c56 100644 --- a/configs/nucleo-f4x1re/Kconfig +++ b/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/configs/nucleo-f4x1re/README.txt b/configs/nucleo-f4x1re/README.txt index 2d836583c35..46c1275364d 100644 --- a/configs/nucleo-f4x1re/README.txt +++ b/configs/nucleo-f4x1re/README.txt @@ -539,7 +539,8 @@ Shields 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 + USART or select CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS which will + eliminate all but buttons A, B, and C. Itead Joystick Signal interpretation: diff --git a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h index 880d1748ae0..808659c9f52 100644 --- a/configs/nucleo-f4x1re/src/nucleo-f4x1re.h +++ b/configs/nucleo-f4x1re/src/nucleo-f4x1re.h @@ -197,7 +197,8 @@ * 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 + * 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 */ diff --git a/configs/nucleo-f4x1re/src/stm32_ajoystick.c b/configs/nucleo-f4x1re/src/stm32_ajoystick.c index 37c2eead31a..c05049dba17 100644 --- a/configs/nucleo-f4x1re/src/stm32_ajoystick.c +++ b/configs/nucleo-f4x1re/src/stm32_ajoystick.c @@ -85,16 +85,27 @@ # define NJOYSTICK_CHANNELS 1 #endif +#ifdef CONFIG_NUCLEO_F401RE_AJOY_MINBUTTONS /* Number of Joystick buttons */ -#define AJOY_NGPIOS 7 +# define AJOY_NGPIOS 3 /* 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) +#else +/* Number of Joystick buttons */ + +# 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 ) +#endif /**************************************************************************** * Private Types @@ -122,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_7 }; +#endif /* This is the button joystick lower half driver interface */