AnsweredAssumed Answered

adding a button to the demo project

Question asked by edwards.jason on Mar 12, 2011
Latest reply on Mar 12, 2011 by Clive One
i managed to switch the LEDs around and add more LEDs to the demo code provided for hte ST32vldiscovery, but i would like some help understanding how the user button and the NISV interrupts work. What i want to do is add another button such that if i press it the program counts down - so the User button increases the LED flash rate and hte new button will decrease that rate.

the new button is added to port A bit 2

the changes i have made so far compile with the following warnings:
..\..\..\Utilities\STM32vldiscovery.h(122): warning:  #47-D: incompatible redefinition of macro "USER_BUTTON_PIN" (declared at line 113)
..\..\..\Utilities\STM32vldiscovery.h(126): warning:  #47-D: incompatible redefinition of macro "USER_BUTTON_EXTI_PIN_SOURCE" (declared at line 117)
..\..\..\Utilities\STM32vldiscovery.h(127): warning:  #47-D: incompatible redefinition of macro "USER_BUTTON_EXTI_LINE" (declared at line 118)
..\..\..\Utilities\STM32vldiscovery.h(128): warning:  #47-D: incompatible redefinition of macro "USER_BUTTON_EXTI_IRQn" (declared at line 119)
 
the changes i have made to the stm32vldiscovery.h file are as follows.

typedef enum

  BUTTON_USER = 0,
  BUTTON_USER1 = 1,   /*this is the new button name */
} Button_TypeDef;

/** @addtogroup STM32vldiscovery_LOW_LEVEL_BUTTON
  * @{
  */ 
#define BUTTONn                          2     /* changed from 1 */

/* * @brief USER push-button
 */
#define USER_BUTTON_PIN                   GPIO_Pin_0
#define USER_BUTTON_GPIO_PORT             GPIOA
#define USER_BUTTON_GPIO_CLK              RCC_APB2Periph_GPIOA
#define USER_BUTTON_EXTI_PORT_SOURCE      GPIO_PortSourceGPIOA
#define USER_BUTTON_EXTI_PIN_SOURCE       GPIO_PinSource0
#define USER_BUTTON_EXTI_LINE             EXTI_Line0
#define USER_BUTTON_EXTI_IRQn             EXTI0_IRQn

/* added by jase 5th March */
#define USER_BUTTON_PIN                      GPIO_Pin_2
#define USER_BUTTON_GPIO_PORT              GPIOA
#define USER_BUTTON_GPIO_CLK              RCC_APB2Periph_GPIOA
#define USER_BUTTON_EXTI_PORT_SOURCE      GPIO_PortSourceGPIOA
#define USER_BUTTON_EXTI_PIN_SOURCE          GPIO_PinSource2
#define USER_BUTTON_EXTI_LINE              EXTI_Line2
#define USER_BUTTON_EXTI_IRQn              EXTI2_IRQn

from reading thru the code in the stm32vldiscovery.c file i dont think i need to add code to the pin configuration part because it takes in the definitions from the h file.

any help would be much appreciated 

Outcomes