2011-03-11 06:25 PM
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: &sharp47-D: incompatible redefinition of macro ''USER_BUTTON_PIN'' (declared at line 113) ..\..\..\Utilities\STM32vldiscovery.h(126): warning: &sharp47-D: incompatible redefinition of macro ''USER_BUTTON_EXTI_PIN_SOURCE'' (declared at line 117) ..\..\..\Utilities\STM32vldiscovery.h(127): warning: &sharp47-D: incompatible redefinition of macro ''USER_BUTTON_EXTI_LINE'' (declared at line 118) ..\..\..\Utilities\STM32vldiscovery.h(128): warning: &sharp47-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 * @{ */ &sharpdefine BUTTONn 2 /* changed from 1 */ /* * @brief USER push-button */ &sharpdefine USER_BUTTON_PIN GPIO_Pin_0 &sharpdefine USER_BUTTON_GPIO_PORT GPIOA &sharpdefine USER_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOA &sharpdefine USER_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOA &sharpdefine USER_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource0 &sharpdefine USER_BUTTON_EXTI_LINE EXTI_Line0 &sharpdefine USER_BUTTON_EXTI_IRQn EXTI0_IRQn /* added by jase 5th March */ &sharpdefine USER_BUTTON_PIN GPIO_Pin_2 &sharpdefine USER_BUTTON_GPIO_PORT GPIOA &sharpdefine USER_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOA &sharpdefine USER_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOA &sharpdefine USER_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource2 &sharpdefine USER_BUTTON_EXTI_LINE EXTI_Line2 &sharpdefine 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 #external-interrupts-button2011-03-11 07:57 PM
You're second set of #define's basically reassign the first set, because they have the same names, but with different content/assignments.
You need something like #define USER_BUTTON0_PIN GPIO_Pin_0 #define USER_BUTTON1_PIN GPIO_Pin_2 #define USER_BUTTONx_PIN ...