2013-01-17 07:33 PM
Hi guyz simple question..
Im trying to get my way in stm32 platform and I am playing around with the samples. I have this typedef enum { LEd3 = 1, LED4 = 0, c0=1, c1=3, c2=4, c3=5, c4=6, c5=7, c6=8, c7=9 } Led_TypeDef; #define LEDn 10 #define LED4_PIN GPIO_Pin_8 #define LED4_GPIO_PORT GPIOC #define LED4_GPIO_CLK RCC_APB2Periph_GPIOC #define LED3_PIN GPIO_Pin_9 #define LED3_GPIO_PORT GPIOC #define LED3_GPIO_CLK RCC_APB2Periph_GPIOC #define c0_PIN GPIO_Pin_0 #define c0_GPIO_PORT GPIOC #define c0_GPIO_CLK RCC_APB2Periph_GPIOC #define c1_PIN GPIO_Pin_1 #define c1_GPIO_PORT GPIOC #define c1_GPIO_CLK RCC_APB2Periph_GPIOC #define c2_PIN GPIO_Pin_2 #define c2_GPIO_PORT GPIOC #define c2_GPIO_CLK RCC_APB2Periph_GPIOC #define c3_PIN GPIO_Pin_3 #define c3_GPIO_PORT GPIOC #define c3_GPIO_CLK RCC_APB2Periph_GPIOC #define c4_PIN GPIO_Pin_4 #define c4_GPIO_PORT GPIOC #define c4_GPIO_CLK RCC_APB2Periph_GPIOC #define c5_PIN GPIO_Pin_5 #define c5_GPIO_PORT GPIOC #define c5_GPIO_CLK RCC_APB2Periph_GPIOC #define c6_PIN GPIO_Pin_6 #define c6_GPIO_PORT GPIOC #define c6_GPIO_CLK RCC_APB2Periph_GPIOC #define c7_PIN GPIO_Pin_7 #define c7_GPIO_PORT GPIOC #define c7_GPIO_CLK RCC_APB2Periph_GPIOC void STM32vldiscovery_LEDInit(Led_TypeDef Led); void STM32vldiscovery_LEDOn(Led_TypeDef Led); void STM32vldiscovery_LEDOff(Led_TypeDef Led); void STM32vldiscovery_LEDToggle(Led_TypeDef Led); void STM32vldiscovery_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); uint32_t STM32vldiscovery_PBGetState(Button_TypeDef Button); and in my main i have this /* Turn on LD2 and LD3 */ STM32vldiscovery_LEDOn(LEd3); STM32vldiscovery_LEDOn(LED4); /* Insert delay */ Delay(0xAFFFF); /* Turn off LD3 and LD4 */ STM32vldiscovery_LEDOff(LEd3); STM32vldiscovery_LEDOff(LED4); /* Insert delay */ Delay(0xAFFFF); STM32vldiscovery_LEDOn(c0); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c0); STM32vldiscovery_LEDOn(c1); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c1); STM32vldiscovery_LEDOn(c2); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c2); STM32vldiscovery_LEDOn(c3); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c3); STM32vldiscovery_LEDOn(c4); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c4); STM32vldiscovery_LEDOn(c5); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c5); STM32vldiscovery_LEDOn(c6); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c6); STM32vldiscovery_LEDOn(c7); Delay(0xAFFFF); STM32vldiscovery_LEDOff(c7); it would stop on led 3 and led 4 my suspicion is i did something wrong in the enum....2013-01-17 09:39 PM
Ah I understood it now.. thanks to clive previous guidance... the enum was for the array
GPIO_TypeDef* GPIO_PORT[LEDn] = {LED3_GPIO_PORT, LED4_GPIO_PORT, c0_GPIO_PORT, c1_GPIO_PORT, c2_GPIO_PORT, c3_GPIO_PORT, c4_GPIO_PORT, c5_GPIO_PORT, c6_GPIO_PORT, c7_GPIO_PORT}; from STM32vldiscovery.c ... I'm starting to get hand of this new platform...