【stm32f0实验】自己建立的工程模板和点亮LED

[复制链接]
 楼主| gaochy1126 发表于 2012-7-23 17:05 | 显示全部楼层 |阅读模式
#include "stm32f0xx_conf.h"

#define uchar unsigned char
#define uint unsigned int

GPIO_InitTypeDef        GPIO_InitStructure;
void delay()
{
                uint x,y;
        for(x=0;x<1000;x++)
                for(y=0;y<1000;y++);
       
}
void Set_Led()
{
                GPIO_WriteBit(GPIOC,GPIO_Pin_9,1);
}

void Reset_Led()
{
                GPIO_WriteBit(GPIOC,GPIO_Pin_9,0);
}
void Init_Gpio()
{
       
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOC, &GPIO_InitStructure);       
       
}
int main()
{
        SystemInit();
        Init_Gpio();
        while(1)
        {
                Set_Led();
                delay();
                Reset_Led();
                delay();
               
               
        }
}

GPIO.zip

135.54 KB, 下载次数: 56

GG_GG 发表于 2012-7-24 17:58 | 显示全部楼层
新手学习了
gigicoco007 发表于 2012-7-24 23:43 | 显示全部楼层
学习
gygp 发表于 2012-7-25 08:13 | 显示全部楼层
感谢分享
onlyrcy 发表于 2012-7-25 14:20 | 显示全部楼层
初学点灯绝对是一语双关,非常有用
 楼主| gaochy1126 发表于 2012-7-26 19:26 | 显示全部楼层
楼上很有才 5# onlyrcy
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1148

主题

11651

帖子

26

粉丝
快速回复 在线客服 返回列表 返回顶部

1148

主题

11651

帖子

26

粉丝
快速回复 在线客服 返回列表 返回顶部