專注電子技術(shù)學習與研究
當前位置:單片機教程網(wǎng) >> MCU設計實例 >> 瀏覽文章

STM32F1003BR基于3.5固件庫的LED燈

作者:黃賓山   來源:本站原創(chuàng)   點擊數(shù):  更新時間:2014年03月03日   【字體:


#include "stm32f10x.h"
/***********************************************************************
************************************************************************/
GPIO_InitTypeDef GPIO_InitStructure;
/***********************************************************************
************************************************************************/
void delay(vu32 nCount)
 {
 for(; nCount != 0; nCount--);
 }
/***********************************************************************
************************************************************************/
main()
{
 /* GPIOD Periph clock enable */
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
 
 /* Configure PD0 and PD2 in output pushpull mode */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 GPIO_Init(GPIOD, &GPIO_InitStructure);

 while(1)
 {
  GPIO_ResetBits(GPIOD,GPIO_Pin_2); 
  delay(5000000);
  GPIO_SetBits(GPIOD,GPIO_Pin_2);
  delay(5000000);
 }
}

/*PD.2端口接LED燈,循環(huán)亮滅*********************************************
************************************************************************/

關(guān)閉窗口

相關(guān)文章