1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

標題: stm32按鍵燈亮程序 [打印本頁]

作者: geige    時間: 2015-7-26 02:20
標題: stm32按鍵燈亮程序
//分別按下S1~S4,D1~D4分別點亮
#include "stm32f10x.h"
void Delay(unsigned intx);

int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD| RCC_APB2Periph_GPIOE,ENABLE);//IO口使能設置
  GPIO_InitTypeDefGPIO_InitStructure;   //定義結構體
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; //LED管腳   
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC,&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_13;     //LED管腳
  GPIO_Init(GPIOD,&GPIO_InitStructure);
  
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4| GPIO_Pin_5;//按鍵管腳
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;  //設置為上拉輸入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOE,&GPIO_InitStructure);
  
  
  while(1)
  {
   if(!(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_5)))
     GPIO_SetBits(GPIOC,GPIO_Pin_6);  
   else
     GPIO_ResetBits(GPIOC,GPIO_Pin_6);
   if(!(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4)))
     GPIO_SetBits(GPIOC,GPIO_Pin_7);
   else
     GPIO_ResetBits(GPIOC,GPIO_Pin_7);
   if(!(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3)))
     GPIO_SetBits(GPIOD,GPIO_Pin_13);
   else
     GPIO_ResetBits(GPIOD,GPIO_Pin_13);
   if(!(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)))
     GPIO_SetBits(GPIOD,GPIO_Pin_6);
   else
     GPIO_ResetBits(GPIOD,GPIO_Pin_6);
   

  }
}


void Delay(unsigned intx)
{
unsigned int t;
t=x;
while(t--);
}







歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1