#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "lcd.h"
//ALIENTEK Mini STM32¿a·¢°å·¶ày′úÂë11
//TFTLCDÏÔê¾êμÑé
//¼¼êõÖ§3Ö£o
www.openedv.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
void InitKey(void) //???????????GPIO??
{
GPIO_InitTypeDef GPIOStru;
GPIOStru.GPIO_Mode = GPIO_Mode_Out_PP; //??PA0?PA3??????
GPIOStru.GPIO_Speed = GPIO_Speed_50MHz;
GPIOStru.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_2|GPIO_Pin_1|GPIO_Pin_0;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_Init(GPIOA,&GPIOStru);
GPIOStru.GPIO_Mode = GPIO_Mode_IPD; //??PA4?PA7??????
GPIOStru.GPIO_Speed = GPIO_Speed_50MHz;
GPIOStru.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5|GPIO_Pin_4;
GPIO_Init(GPIOA,&GPIOStru);
}
int KeyVal;
u16 WriteVal;
int key(void)
{
GPIO_Write(GPIOA,(GPIOA->ODR & 0xfff0 | 0xf)); //??PA0?PA3??????
if((GPIOA->IDR & 0x00f0)==0x0000) //???PA4?PA7??0?????????
return -1;
else
{
delay_ms(5); //??5ms????
if((GPIOA->IDR & 0x00f0)==0x0000) //?????5ms??PA4?PA7???0?
return -1;
}
GPIO_Write(GPIOA,(GPIOA->ODR & 0xfff0 | 0x1));
switch(GPIOA->IDR & 0x00f0)
{
case 0x0010: KeyVal=15; break;
case 0x0020: KeyVal=11; break;
case 0x0040: KeyVal=7; break;
case 0x0080: KeyVal=3; break;
}
GPIO_Write(GPIOA,(GPIOA->ODR & 0xfff0 | 0x2));
switch(GPIOA->IDR & 0x00f0)
{
case 0x0010: KeyVal=14; break;
case 0x0020: KeyVal=10; break;
case 0x0040: KeyVal=6; break;
case 0x0080: KeyVal=2; break;
}
GPIO_Write(GPIOA,(GPIOA->ODR & 0xfff0 | 0x4));
switch(GPIOA->IDR & 0x00f0)
{
case 0x0010: KeyVal=13; break;
case 0x0020: KeyVal=9; break;
case 0x0040: KeyVal=5; break;
case 0x0080: KeyVal=1; break;
}
GPIO_Write(GPIOA,(GPIOA->ODR & 0xfff0 | 0x8));
switch(GPIOA->IDR & 0x00f0)
{
case 0x0010: KeyVal=12; break;
case 0x0020: KeyVal=8; break;
case 0x0040: KeyVal=4; break;
case 0x0080: KeyVal=0; break;
}
return KeyVal;
}
int main(void)
{
u8 lcd_id[12]; //′æ·ÅLCD ID×Ö·û′®
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
uart_init(9600); //′®¿ú3õê¼»ˉÎa9600
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
LCD_Init();
// POINT_COLOR=BLUE;
sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//½«LCD ID′òó¡μ½lcd_idêy×é¡£
while(1)
{
LCD_Clear(MAGENTA);break;
}
POINT_COLOR=BLUE;
// LCD_ShowString(30,40,200,24,24," ");
// LCD_ShowString(30,70,200,16,16," super qi");
// LCD_ShowString(30,90,200,16,16,"jia dian dian ");
// LCD_ShowString(30,110,200,16,16,lcd_id); //ÏÔê¾LCD ID
// LCD_ShowString(30,130,200,12,12,"2017/7/22");
//
LCD_ShowxNum(124,150,KeyVal,4,16,0);
}
一周热门 更多>