01-數位輸出 STM8L GPIO Digital Output LED

2014-06-30 20.33.50 copy


/* Includes ------------------------------------------------------------------*/

#include "stm8l15x.h"
#include "main.h"
#include

#define LED1_H()    (GPIO_SetBits (GPIOE,GPIO_Pin_7))
#define LED1_L()    (GPIO_ResetBits (GPIOE,GPIO_Pin_7))

 void CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_TypeDef CLK_SYSCLKDiv)
{
  /* check the parameters */
  assert_param(IS_CLK_SYSTEM_DIVIDER(CLK_SYSCLKDiv));

  CLK->CKDIVR = (uint8_t)(CLK_SYSCLKDiv);
}

void GPIO_config(void)
{
  GPIO_Init (GPIOE,GPIO_Pin_7,GPIO_Mode_Out_PP_High_Fast);//定?引?,推挽?出,10MHz,所以?阻取小
}

void CLK_config(void)
{
 CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1 );
}

void delay(unsigned long i)
{
 unsigned int j;
 for(;i>0;i--)
    for(j=1000;j>0;j--);
}

void main(void)
{
 CLK_config();
 GPIO_config();
 while(1)
 {
  LED1_L();
  delay(1000);
  LED1_H();
  delay(1000);
 }
}

IAR
CH01 簡介CH02 STM8L