📄 head.h
字号:
#ifndef __WXX_h__
#define __WXX_h__
int k;
long int i;
int l1;
int j;
const char ss[]={'s','e','a','r','c','h','i','n','g','.','.','.'};
unsigned int uiValue,ko;
unsigned int uiDelay=0x0008;
const char shu[]={'0','1','2','3','4','5','6','7','8','9','.','+','-','*','/','='};
void Delay()
{ //延时子程序
unsigned int i;
for(i=0; i<30; i++){
*P_Watchdog_Clear=0x0001; //清WatchDog
}
}
void Delay1()
{ //延时子程序
unsigned int i;
for(i=0; i<60; i++){
*P_Watchdog_Clear=0x0001; //清WatchDog
}
}
void Delay2()
{ //延时子程序
unsigned int i;
for(i=0; i<15000; i++){
*P_Watchdog_Clear=0x0001; //清WatchDog
}
}
void Delay3()
{ //延时子程序
unsigned int i;
for(i=0; i<32768; i++){
*P_Watchdog_Clear=0x0001; //清WatchDog
}
}
unsigned int key1() //行扫描
{unsigned int k1;
Set_IOB_Dir(0xf0ff);
Set_IOB_Attrib(0xf0ff);
Set_IOB_Data(0x0f00);
k1=Get_IOB_Data();
return k1;
}
unsigned int key3()//列扫描,该扫描函数不同于其他单片机书籍常说的扫描法,跟反转法有点象
{
unsigned int k3;
Set_IOB_Dir(0x00ff);
Set_IOB_Attrib(0x00ff);
Set_IOB_Data(0x0000);
k3=Get_IOB_Data();
return k3;
}
unsigned int KeyFind()//获取键值的函数,返回键值
{
unsigned int w1,w2;
unsigned int KEY;
w1=key1();
w2=key3();
w1=w1&0x0f00;//获取行特征数据
w2=w2&0xf000;//获取列特征数据
KEY=w1|w2;//将行数据和列数据糅合
switch(KEY) //判断数值 //把对应的值赋给uiValue
{
case 0x0f00:
break;
case 0x8e00:
uiValue=0x0000;
break;
case 0x4e00:
uiValue=0x0001;
break;
case 0x2e00:
uiValue=0x0002;
break;
case 0x1e00:
uiValue=0x0003;
break;
case 0x8d00:
uiValue=0x0004;
break;
case 0x4d00:
uiValue=0x0005;
break;
case 0x2d00:
uiValue=0x0006;
break;
case 0x1d00:
uiValue=0x0007;
break;
case 0x8b00:
uiValue=0x0008;
break;
case 0x4b00:
uiValue=0x0009;
break;
case 0x2b00:
uiValue=0x000a;
break;
case 0x1b00:
uiValue=0x000b;
break;
case 0x8700:
uiValue=0x000c;
break;
case 0x4700:
uiValue=0x000d;
break;
case 0x2700:
uiValue=0x000e;
break;
case 0x1700:
uiValue=0x000f;
break;
}
if(uiValue==255) ko=ko;
else ko=uiValue;
return ko;
}
void SIO_OUT(unsigned int DATA)
{
*P_SIO_Start=1; // 启动写模式
*P_SIO_Data=DATA; // A7~A0 = 0
// 等待SIO空闲
i=*P_SIO_Start;
i&=0x0080;
while(i)
{
i=*P_SIO_Start;
i&=0x0080;
*P_Watchdog_Clear=0x0001;
}
*P_SIO_Stop=1;
}
void chushi()//液晶显示初始化
{
*P_IOB_Dir = 0x00FF;
*P_IOB_Attrib = 0x00FF;
*P_IOB_Data=0x0000;
// 对SPR4096进行Mass Erase
*P_SIO_Ctrl=0x00d1; // clk= CPUclk/8, 8位地址
*P_SIO_Start=1; // 启动写模式
*P_SIO_Data=0; // A7~A0 = 0
// 等待SIO空闲
i=*P_SIO_Start;
i&=0x0080;
while(i)
{
i=*P_SIO_Start;
i&=0x0080;
}
*P_SIO_Stop=1;
i=0x7ff; // 延时
while(i--);
Set_IOB_Buffer(0x0040);
SIO_OUT(0x0001);//清屏
Set_IOB_Buffer(0x0000);
Delay1();//1.53ms
Set_IOB_Buffer(0x0040);
SIO_OUT(0x0038);//功能设置 ;
Set_IOB_Buffer(0x0000);
Delay();
Set_IOB_Buffer(0x0040);
SIO_OUT(0x000c);//开显示
Set_IOB_Buffer(0x0000);
Delay();//39us
Set_IOB_Buffer(0x0040);
SIO_OUT(0x0006);//输入模式设置
Set_IOB_Buffer(0x0000);
Delay();//39us
Set_IOB_Buffer(0x0040);
}
void xianshi(unsigned int s1)//显示函数
{
SIO_OUT(s1);
Set_IOB_Buffer(0x0010);
Delay();//39us
Set_IOB_Buffer(0x0040);
}
void qp()//清屏函数
{
Set_IOB_Buffer(0x0040);
SIO_OUT(0x0001);//清屏
Set_IOB_Buffer(0x0000);
Delay1();//1.53ms
Set_IOB_Buffer(0x0040);
}
void Address1()//地址设置函数
{
SIO_OUT(0x0080);//显示位置
Set_IOB_Buffer(0x0000);
Delay();//39us
Set_IOB_Buffer(0x0040);
}
void Address2()//地址设置函数
{
SIO_OUT(0x00c0);//显示位置
Set_IOB_Buffer(0x0000);
Delay();//39us
Set_IOB_Buffer(0x0040);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -