專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

STM32基于3.5庫(kù)的LED燈2

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

3.5的庫(kù)在這里:http://www.torrancerestoration.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);   //設(shè)置所選定的端口的一個(gè)或多個(gè)所選定的位為低
  GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_SET); //置位或清除所選定的特定位
  delay(5000000);
  GPIO_SetBits(GPIOD,GPIO_Pin_2);    //設(shè)置所選定的端口的一個(gè)或多個(gè)所選定的位為高
  GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_RESET); //置位或清除所選定的特定位
  delay(5000000);
 }
}

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

 

關(guān)閉窗口

相關(guān)文章