LVGL控制——纯寄存器、标准外设开发

发布于:2025-09-13 ⋅ 阅读:(13) ⋅ 点赞:(0)

纯寄存器

#include <stm32f4xx.h>
 
void delay(uint32_t ms)
{
	int i,j;
	for(i=0;i<ms;i++){
		for(j=0;j<2500;j++);
	}
}

int main()
{
	
	//GPIOF9、10
	// 指向RCC_AHB1ENR寄存器
    volatile uint32_t *RCC_AHB1ENR=(uint32_t *)(0x40023800+0x30);    
    
	
    // 指向GPIOF_MODER寄存器
    volatile uint32_t *GPIOF_MODER = (uint32_t *)(0x40021400 + 0x00);
 
    // 指向GPIOF_OTYPER寄存器    
    volatile uint32_t *GPIOF_OTYPER = (uint32_t *)(0x40021400 + 0x04);
 
    // 指向GPIOF_OSPEEDR寄存器    
    volatile uint32_t *GPIOF_OSPEEDR = (uint32_t *)(0x40021400 + 0x08);
 
    // 指向GPIOF_PUPDR寄存器
    volatile uint32_t *GPIOF_PUPDR = (uint32_t *)(0x40021400 + 0x0C);
 
    // 指向GPIOF_ODR寄存器
    volatile uint32_t *GPIOF_ODR = (uint32_t *)(0x40021400 + 0x14);
		
	//GPIOE_D10、D11
    // 指向GPIOE_MODER寄存器
    volatile uint32_t *GPIOE_MODER = (uint32_t *)(0x40021000 + 0x00);
 
    // 指向GPIOE_OTYPER寄存器    
    volatile uint32_t *GPIOE_OTYPER = (uint32_t *)(0x40021000 + 0x04);
 
    // 指向GPIOE_OSPEEDR寄存器    
    volatile uint32_t *GPIOE_OSPEEDR = (uint32_t *)(0x40021000 + 0x08);
 
    // 指向GPIOE_PUPDR寄存器
    volatile uint32_t *GPIOE_PUPDR = (uint32_t *)(0x40021000 + 0x0C);
 
    // 指向GPIOE_ODR寄存器
    volatile uint32_t *GPIOE_ODR = (uint32_t *)(0x40021000 + 0x14);
	
	
	//指向GPIOA_MMODER寄存器
	volatile uint32_t *GPIOA_MODER = (uint32_t *)(0x40020000 + 0x00);
	
	//指向GPIOA_PUPDR寄存器
	volatile uint32_t *GPIOA_PUPDR = (uint32_t *)(0x40020000 + 0x0C);
	//指向GPIOA_IDR寄存器
	volatile uint32_t *GPIOA_IDR = (uint32_t *)(0x40020000 + 0x10);
	volatile uint32_t *GPIOE_IDR = (uint32_t *)(0x40021000 + 0x10);
	//RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
	
	//使能GPIOA时钟
	*RCC_AHB1ENR |= 1;
	
	//使能GPIOE时钟
	*RCC_AHB1ENR |= 1<<4;
	
	//使能GPIOF时钟
	*RCC_AHB1ENR |= 1<<5;
	
	// 设置GPIOF9为输出模式
	*GPIOF_MODER &= ~(0x03 << (9 * 2));
    *GPIOF_MODER |= (0x01 << (9 * 2));
    
    // 设置GPIOF9为推挽输出
    *GPIOF_OTYPER &= ~(0x01 << 9);
 
    // 设置GPIOF9的速度为高速
    *GPIOF_OSPEEDR |= (0x03 << (9 * 2));    
    
    // 设置GPIOF9为无上拉/下拉    
    *GPIOF_PUPDR &= ~(0x03 << (9 * 2));   
 
	// 设置GPIOF10为输出模式
	*GPIOF_MODER &= ~(0x03 << (10 * 2));
    *GPIOF_MODER |= (0x01 << (10 * 2));
    
    // 设置GPIOF10为推挽输出
    *GPIOF_OTYPER &= ~(0x01 << 10);
 
    // 设置GPIOF10的速度为高速
    *GPIOF_OSPEEDR |= (0x03 << (10 * 2));    
    
    // 设置GPIOF10为无上拉/下拉    
    *GPIOF_PUPDR &= ~(0x03 << (10 * 2));   
	
	
	//使能GPIOE_D0
	
	
	// 设置GPIOED_D0为输出模式
	*GPIOE_MODER &= ~(0x03 << (13 * 2));
    *GPIOE_MODER |= (0x01 << (13 * 2));
    
    // 设置GPIOD_D0为推挽输出
    *GPIOE_OTYPER &= ~(0x01 << 13);
 
    // 设置GPIOD_D0的速度为高速
    *GPIOE_OSPEEDR |= (0x03 << (13 * 2));    
    
    // 设置GPIOD_D0为无上拉/下拉    
    *GPIOE_PUPDR &= ~(0x03 << (13 * 2)); 
	
	// 设置GPIOED_D1为输出模式
	*GPIOE_MODER &= ~(0x03 << (14 * 2));
    *GPIOE_MODER |= (0x01 << (14 * 2));
    
    // 设置GPIOED_D1为推挽输出
    *GPIOE_OTYPER &= ~(0x01 << 14);
 
    // 设置GPIOED_D1的速度为高速
    *GPIOE_OSPEEDR |= (0x03 << (14 * 2));    
    
    // 设置GPIOED_D1为无上拉/下拉    
    *GPIOE_PUPDR &= ~(0x03 << (14 * 2));   
 
	//GPIOE_key0
	*GPIOA_MODER&=~(0x03);
	
	*GPIOA_PUPDR |= (0x01);   // PA0 置成上拉(01)

	//GPIOE_key1
	*GPIOE_MODER&=~(0x03 << (2*2));
	
	*GPIOE_PUPDR |= (0x01 << 2);   // PE2 置成上拉(01
	
	*GPIOE_MODER&=~(0x03 << (3*2));
	
	*GPIOE_PUPDR |= (0x01 << 3);   // PE2 置成上拉(01
	
	*GPIOE_MODER&=~(0x03 << (4*2));
	
	*GPIOE_PUPDR |= (0x01 << 4);   // PE2 置成上拉(01
	while(1){
		
		if((*GPIOA_IDR&1)==0){
		RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
		RCC_PLLCmd(DISABLE);
		RCC_PLLConfig(RCC_PLLSource_HSE,8,192,2,7);
		RCC_PLLCmd(ENABLE);
		RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
		// 亮 ----- GPIOF9输出低电平
		*GPIOF_ODR &= ~(0x01 << 9);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOF_ODR |= (0x01 << 9);
		delay(500);
		// 亮 ----- GPIOF10输出低电平
		*GPIOF_ODR &= ~(0x01 << 10);
		delay(500);
		
		//灭 ----- GPIOF10输出高电平
		*GPIOF_ODR |= (0x01 << 10);
		delay(500);
		
		// 亮 ----- GPIOE_D10输出低电平
		*GPIOE_ODR &= ~(0x01 << 13);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 13);
		delay(500);
		// 亮 ----- GPIOF9输出低电平
		*GPIOE_ODR &= ~(0x01 << 14);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 14);
		delay(500);
		}
		if((*GPIOA_IDR&1)==1){
		//灭 ----- GPIOF9输出高电平
		*GPIOF_ODR |= (0x01 << 9);
		//灭 ----- GPIOF10输出高电平
		*GPIOF_ODR |= (0x01 << 10);
		//灭 ----- GPIOE_D0输出高电平
		*GPIOE_ODR |= (0x01 << 13);
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 14);
		if((*GPIOE_IDR&1<<2)==0){
			// 亮 ----- GPIOF10输出低电平
		*GPIOF_ODR &= ~(0x01 << 10);
			
		}
		if((*GPIOE_IDR&1<<2)==1){
		
		//灭 ----- GPIOF10输出高电平
		*GPIOF_ODR |= (0x01 << 10);
			
		}
		if((*GPIOE_IDR&1<<3)==0){
			// 亮 ----- GPIOE_D10输出低电平
		*GPIOE_ODR &= ~(0x01 << 13);
			
		}
		if((*GPIOE_IDR&1<<3)==1){
		
		//灭 ----- GPIOF10输出高电平
		*GPIOE_ODR |= (0x01 << 13);
			
		}
		if((*GPIOE_IDR&1<<4)==0){
			
		RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
		RCC_PLLCmd(DISABLE);
		RCC_PLLConfig(RCC_PLLSource_HSE,8,336,2,7);
		RCC_PLLCmd(ENABLE);
		RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
			// 亮 ----- GPIOE_D10输出低电平
		*GPIOF_ODR &= ~(0x01 << 9);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOF_ODR |= (0x01 << 9);
		delay(500);
		// 亮 ----- GPIOF10输出低电平
		*GPIOF_ODR &= ~(0x01 << 10);
		delay(500);
		
		//灭 ----- GPIOF10输出高电平
		*GPIOF_ODR |= (0x01 << 10);
		delay(500);
		
		// 亮 ----- GPIOE_D10输出低电平
		*GPIOE_ODR &= ~(0x01 << 13);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 13);
		delay(500);
		// 亮 ----- GPIOF9输出低电平
		*GPIOE_ODR &= ~(0x01 << 14);
		delay(500);
		
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 14);
		delay(500);
			
		}
		if((*GPIOE_IDR&1<<4)==1){
			
		//灭 ----- GPIOF9输出高电平
		*GPIOE_ODR |= (0x01 << 14);
		delay(500);
	
		}
		
	}
		
	}
}

标准外设开发

main.c

#include <stm32f4xx.h>
#include <led.h>


/* 位带别名地址宏:GPIOA 引脚 X(0~15)*/
#define PinA(X)  *(volatile uint32_t *)(0x42000000 + (GPIOA_BASE + 0x10 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOF 引脚 X(0~15)*/
#define PinF(X)  *(volatile uint32_t *)(0x42000000 + (GPIOF_BASE + 0x14 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOE 引脚 X(0~15)*/
#define PinE(X)  *(volatile uint32_t *)(0x42000000 + (GPIOE_BASE + 0x14 -0x40000000)*32 + (X)*4)	

void delay(uint32_t ms)
{
	int i,j;
	for(i=0;i<ms;i++){
		for(j=0;j<10000;j++);
	}
}

int main()
{
	
	led_init();
	key_init();
	while(1){
		if(PinA(0)==0){
			//D1亮
			PinF(9)=0;
			PinE(14)=1;
			delay(500);
			//D2亮
			PinF(10)=0;
			PinF(9)=1;
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(PinA(0)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}

		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		
		
	}
}

led.h

#ifndef _LED_H_
#define _LED_H_
#include <stm32f4xx.h>
/* 位带别名地址宏:GPIOA 引脚 X(0~15)*/
#define PinA(X)  *(volatile uint32_t *)(0x42000000 + (GPIOA_BASE + 0x10 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOF 引脚 X(0~15)*/
#define PinF(X)  *(volatile uint32_t *)(0x42000000 + (GPIOF_BASE + 0x14 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOE 引脚 X(0~15)*/
#define PinE(X)  *(volatile uint32_t *)(0x42000000 + (GPIOE_BASE + 0x14 -0x40000000)*32 + (X)*4)	
/* 位带别名地址宏:GPIOE 引脚 X(0~15)*/
#define PinEI(X)  *(volatile uint32_t *)(0x42000000 + (GPIOE_BASE + 0x10 -0x40000000)*32 + (X)*4)
void led_init(void);
void key_init(void);


#endif

led.c

#include <stm32f4xx.h>
#include <led.h>


void led_init(void)
{
	GPIO_InitTypeDef GPIO_InitStrust;
	//1.开启GPIOE GPIOF GPIOA时钟
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF,ENABLE);
	//2.初始化GPIO
	GPIO_InitStrust.GPIO_Mode = GPIO_Mode_OUT;//输出模式
	GPIO_InitStrust.GPIO_OType = GPIO_OType_PP;//输出类型 --推挽
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10;//PF9 PF10
	GPIO_InitStrust.GPIO_PuPd = GPIO_PuPd_NOPULL;//无上下拉
	GPIO_InitStrust.GPIO_Speed = GPIO_High_Speed;//输出速度
	GPIO_Init(GPIOF,&GPIO_InitStrust);
	
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14;//PE13 PE14
	GPIO_Init(GPIOE,&GPIO_InitStrust);
	//3.默认关闭
	GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
	GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
}

void key_init(void)
{
	GPIO_InitTypeDef GPIO_InitStrust;
	//1.开启GPIOE GPIOF GPIOA时钟
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOE,ENABLE);
	//2.初始化GPIO
	GPIO_InitStrust.GPIO_Mode = GPIO_Mode_IN;//输入模式
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_0;//PA0
	GPIO_InitStrust.GPIO_PuPd = GPIO_PuPd_UP;//上拉
	GPIO_InitStrust.GPIO_Speed = GPIO_High_Speed;//输出速度High
	GPIO_Init(GPIOA,&GPIO_InitStrust);
	
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_2| GPIO_Pin_3| GPIO_Pin_4;//PE2//PE3 PE4
	GPIO_Init(GPIOE,&GPIO_InitStrust);
}

带位

main.c

#include <stm32f4xx.h>
#include <led.h>

void delay(uint32_t ms)
{
	int i,j;
	for(i=0;i<ms;i++){
		for(j=0;j<10000;j++);
	}
}

int main()
{
	
	led_init();
	key_init();
	while(1){
		if(PinA(0)==0){
			//D1亮
			PinF(9)=0;
			PinE(14)=1;
			delay(500);
			//D2亮
			PinF(10)=0;
			PinF(9)=1;
			delay(500);
			//D3亮
			PinE(13)=0;
			PinF(10)=1;
			delay(500);
			//D4亮
			PinE(14)=0;
			PinE(13)=1;
			delay(500);
			
		}
		if(PinA(0)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		if(PinEI(2)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(PinEI(2)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4)==0){
			//D1亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_9);
			GPIO_SetBits(GPIOE,GPIO_Pin_14);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOF,GPIO_Pin_10);
			GPIO_SetBits(GPIOF,GPIO_Pin_9);
			delay(500);
			//D1亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_13);
			GPIO_SetBits(GPIOF,GPIO_Pin_10);
			delay(500);
			//D2亮
			GPIO_ResetBits(GPIOE,GPIO_Pin_14);
			GPIO_SetBits(GPIOE,GPIO_Pin_13);
			delay(500);
			
		}
		if(GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4)==1){
			
			GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
			GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
		}
		
		
	}
}

 led.h

#ifndef _LED_H_
#define _LED_H_
#include <stm32f4xx.h>
/* 位带别名地址宏:GPIOA 引脚 X(0~15)*/
#define PinA(X)  *(volatile uint32_t *)(0x42000000 + (GPIOA_BASE + 0x10 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOF 引脚 X(0~15)*/
#define PinF(X)  *(volatile uint32_t *)(0x42000000 + (GPIOF_BASE + 0x14 -0x40000000)*32 + (X)*4)
/* 位带别名地址宏:GPIOE 引脚 X(0~15)*/
#define PinE(X)  *(volatile uint32_t *)(0x42000000 + (GPIOE_BASE + 0x14 -0x40000000)*32 + (X)*4)	
/* 位带别名地址宏:GPIOE 引脚 X(0~15)*/
#define PinEI(X)  *(volatile uint32_t *)(0x42000000 + (GPIOE_BASE + 0x10 -0x40000000)*32 + (X)*4)
void led_init(void);
void key_init(void);


#endif

led.c

#include <stm32f4xx.h>
#include <led.h>


void led_init(void)
{
	GPIO_InitTypeDef GPIO_InitStrust;
	//1.开启GPIOE GPIOF GPIOA时钟
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF,ENABLE);
	//2.初始化GPIO
	GPIO_InitStrust.GPIO_Mode = GPIO_Mode_OUT;//输出模式
	GPIO_InitStrust.GPIO_OType = GPIO_OType_PP;//输出类型 --推挽
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10;//PF9 PF10
	GPIO_InitStrust.GPIO_PuPd = GPIO_PuPd_NOPULL;//无上下拉
	GPIO_InitStrust.GPIO_Speed = GPIO_High_Speed;//输出速度
	GPIO_Init(GPIOF,&GPIO_InitStrust);
	
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14;//PE13 PE14
	GPIO_Init(GPIOE,&GPIO_InitStrust);
	//3.默认关闭
	GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
	GPIO_SetBits(GPIOE,GPIO_Pin_13|GPIO_Pin_14);
}

void key_init(void)
{
	GPIO_InitTypeDef GPIO_InitStrust;
	//1.开启GPIOE GPIOF GPIOA时钟
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOE,ENABLE);
	//2.初始化GPIO
	GPIO_InitStrust.GPIO_Mode = GPIO_Mode_IN;//输入模式
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_0;//PA0
	GPIO_InitStrust.GPIO_PuPd = GPIO_PuPd_UP;//上拉
	GPIO_InitStrust.GPIO_Speed = GPIO_High_Speed;//输出速度High
	GPIO_Init(GPIOA,&GPIO_InitStrust);
	
	GPIO_InitStrust.GPIO_Pin = GPIO_Pin_2| GPIO_Pin_3| GPIO_Pin_4;//PE2//PE3 PE4
	GPIO_Init(GPIOE,&GPIO_InitStrust);
}