Changeset - 08d36c537581
[Not reviewed]
default
0 2 0
Ethan Zonca - 10 years ago 2014-07-02 22:35:57
ez@ethanzonca.com
Blinky lights on the therm board
2 files changed with 19 insertions and 49 deletions:
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -7,84 +7,54 @@ uint8_t BlinkSpeed = 0;
 
 
 
/* Main */
 
int main(void)
 
{
 
   RCC_ClocksTypeDef RCC_Clocks;
 
  
 
  /* Configure LED3 and LED4 on STM32L100C-Discovery */
 
  STM_EVAL_LEDInit(LED3);
 
  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);
 
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
 
 
 /* Initiate Blink Speed variable */ 
 
  BlinkSpeed = 1;
 
 
 /* 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);
 
  }
 
}
 
 
/**
 
  * @brief  Inserts a delay time.
 
  * @param  nTime: specifies the delay time length, in 1 ms.
 
  * @retval None
 
  */
 
void Delay(__IO uint32_t nTime)
 
{
 
  TimingDelay = nTime;
 
stm32l100c_discovery.h
Show inline comments
 
@@ -18,38 +18,38 @@ typedef enum
 
  BUTTON_USER = 0,
 
} Button_TypeDef;
 
 
typedef enum 
 
{  
 
  BUTTON_MODE_GPIO = 0,
 
  BUTTON_MODE_EXTI = 1
 
} ButtonMode_TypeDef;
 
  
 
#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 
 
 
void STM_EVAL_LEDInit(Led_TypeDef Led);
 
void STM_EVAL_LEDOn(Led_TypeDef Led);
 
void STM_EVAL_LEDOff(Led_TypeDef Led);
 
void STM_EVAL_LEDToggle(Led_TypeDef Led);
 
void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
 
uint32_t STM_EVAL_PBGetState(Button_TypeDef Button);
 
 
  
 
#ifdef __cplusplus
0 comments (0 inline, 0 general)