diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -16,7 +16,7 @@ int main(void) STM_EVAL_LEDInit(LED4); /* Initialize User_Button on STM32L100C-Discovery */ - STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); + //STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); /* SysTick end of count event each 1ms */ RCC_GetClocksFreq(&RCC_Clocks); @@ -27,55 +27,25 @@ int main(void) /* Init lcd driver */ u8g_t u8g; - u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_hw_spi, u8g_com_hw_spi_fn); + //u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_hw_spi, u8g_com_hw_spi_fn); + STM_EVAL_LEDOn(LED4); + Delay(1000); + STM_EVAL_LEDOff(LED4); + Delay(1000); + while(1) { - /* Check if the user button is pressed */ - if(STM_EVAL_PBGetState(BUTTON_USER)== SET) - { - /* BlinkSpeed: 1 -> 2 -> 0, then re-cycle */ /* Turn on LD4 Blue LED during 1s each time User button is pressed */ STM_EVAL_LEDOn(LED4); + //STM_EVAL_LEDOn(LED3); /* wait for 1s */ - Delay(1000); + Delay(300); /* Turn off LD4 Blue LED after 1s each time User button is pressed */ STM_EVAL_LEDOff(LED4); - - /* Increment the blink speed counter */ - BlinkSpeed++; - - /* Default value for blink speed counter */ - if(BlinkSpeed == 3) - { - BlinkSpeed = 0; - } - } - - /* Test on blink speed */ - if(BlinkSpeed == 2) - { - /* LED3 toggles each 100 ms */ - STM_EVAL_LEDToggle(LED3); - - /* maintain LED3 status for 100ms */ - Delay(100); - } - else if(BlinkSpeed == 1) - { - /* LED3 toggles each 200 ms */ - STM_EVAL_LEDToggle(LED3); - - /* maintain LED3 status for 200ms */ - Delay(200); - } - else - { - /* LED3 Off */ - STM_EVAL_LEDOff(LED3); - } + Delay(300); } } diff --git a/stm32l100c_discovery.h b/stm32l100c_discovery.h --- a/stm32l100c_discovery.h +++ b/stm32l100c_discovery.h @@ -27,20 +27,20 @@ typedef enum #define LEDn 2 #define LED3_PIN GPIO_Pin_9 -#define LED3_GPIO_PORT GPIOC -#define LED3_GPIO_CLK RCC_AHBPeriph_GPIOC +#define LED3_GPIO_PORT GPIOB +#define LED3_GPIO_CLK RCC_AHBPeriph_GPIOB -#define LED4_PIN GPIO_Pin_8 -#define LED4_GPIO_PORT GPIOC -#define LED4_GPIO_CLK RCC_AHBPeriph_GPIOC +#define LED4_PIN GPIO_Pin_15 +#define LED4_GPIO_PORT GPIOA +#define LED4_GPIO_CLK RCC_AHBPeriph_GPIOA #define BUTTONn 1 -#define USER_BUTTON_PIN GPIO_Pin_0 -#define USER_BUTTON_GPIO_PORT GPIOA -#define USER_BUTTON_GPIO_CLK RCC_AHBPeriph_GPIOA +#define USER_BUTTON_PIN GPIO_Pin_3 +#define USER_BUTTON_GPIO_PORT GPIOB +#define USER_BUTTON_GPIO_CLK RCC_AHBPeriph_GPIOB #define USER_BUTTON_EXTI_LINE EXTI_Line0 -#define USER_BUTTON_EXTI_PORT_SOURCE EXTI_PortSourceGPIOA +#define USER_BUTTON_EXTI_PORT_SOURCE EXTI_PortSourceGPIOB #define USER_BUTTON_EXTI_PIN_SOURCE EXTI_PinSource0 #define USER_BUTTON_EXTI_IRQn EXTI0_IRQn