日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]1 /*2 ::按鍵控制3 PA8接LED,PE2接按鍵4 */5 #include"stm32f10x.h"6 void RCC_Configuration(void);7 void GPIO_Config(void);8 void Delay(__IO uint32_t nCount);910 int main()11 {12 RCC_Configuration();

1 /*

2 ::按鍵控制

3 PA8接LED,PE2接按鍵

4 */

5 #include"stm32f10x.h"

6 void RCC_Configuration(void);

7 void GPIO_Config(void);

8 void Delay(__IO uint32_t nCount);

9

10 int main()

11 {

12 RCC_Configuration(); //系統(tǒng)時(shí)鐘配置|使能GPIO口

13 GPIO_Config(); //LED控制配置

14 while (1)

15 {

16 if(!GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2))

17 {

18 Delay(0x000FF);//延時(shí)防抖

19 if(!GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2))

20 {

21 GPIO_WriteBit(GPIOA,GPIO_Pin_8,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOA,GPIO_Pin_8)));

22 }

23 }

24 }

25 }

26 /****************************************************************************

27 * 名 稱:void GPIO_Config(void)

28 * 功 能:GPIO初始化函數(shù)

29 * 入口參數(shù):無

30 * 出口參數(shù):無

31 * 說 明:

32 * 調(diào)用方法:無

33 ****************************************************************************/

34 void GPIO_Config(void)

35 {

36 GPIO_InitTypeDef GPIO_InitStructure;

37 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //配置LEDA8

38 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽輸出

39 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

40 GPIO_Init(GPIOA, &GPIO_InitStructure);

41

42 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //配置按鍵PE2

43 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//上拉輸入

44 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

45 GPIO_Init(GPIOE, &GPIO_InitStructure);

46 }

47 /****************************************************************************

48 * 名 稱:void RCC_Configuration(void)

49 * 功 能:系統(tǒng)時(shí)鐘配置為72MHZ|使能GPIO口

50 * 入口參數(shù):無

51 * 出口參數(shù):無

52 * 說 明:

53 * 調(diào)用方法:無

54 ****************************************************************************/

55 void RCC_Configuration(void)

56 {

57 SystemInit();

58 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOE, ENABLE);//使能GPIO口

59 }

60 /****************************************************************************

61 * 名 稱:void Delay(__IO uint32_t nCount)

62 * 功 能:延時(shí)函數(shù)

63 * 入口參數(shù):無

64 * 出口參數(shù):無

65 * 說 明:

66 * 調(diào)用方法:無

67 ****************************************************************************/

68 void Delay(__IO uint32_t nCount)

69 {

70 for(; nCount != 0; nCount--);

71 }


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉