欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

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

STM32基于3.5庫的LED燈2

作者:黃賓山   來源:本站原創   點擊數:  更新時間:2014年03月03日   【字體:

3.5的庫在這里:http://www.raoushi.com/mcu/2765.html
#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 PD.2 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);


 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
 
 /* Configure PA.8 in output pushpull mode */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 GPIO_Init(GPIOA, &GPIO_InitStructure);


 while(1)
 {
  GPIO_ResetBits(GPIOD,GPIO_Pin_2);   //設置所選定的端口的一個或多個所選定的位為低
  GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_SET); //置位或清除所選定的特定位
  delay(5000000);
  GPIO_SetBits(GPIOD,GPIO_Pin_2);    //設置所選定的端口的一個或多個所選定的位為高
  GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_RESET); //置位或清除所選定的特定位
  delay(5000000);
 }
}

/*PD.2和PA.8端口接LED燈,循環亮滅*********************************************
*****************************************************************************/

 

關閉窗口

相關文章