Nucleo-F4x1RE: Fix some joystick shield logic
This commit is contained in:
parent
ae3f05066a
commit
c0c455a7c9
@ -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
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -152,7 +152,9 @@ int nsh_archinitialize(void)
|
||||
ret = sam_ajoy_initialization();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to register the joystick driver: %d\n", ret);
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to register the joystick driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user