📄 zlg8279.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <reg52.h>
#include <ctype.h>
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define NOP _nop_();_nop_();_nop_()
/*############### ZLG7289 ver define ##########################################*/
sbit ZLG7289_RST=P1^4;
sbit ZLG7289_CLK=P1^5;
sbit ZLG7289_NCS=P1^6;
sbit ZLG7289_DIO=P1^7;
sbit ZLG7289_K=P3^2;
/*########################################################################################*/
/*中断子程序区*/
/*########################################################################################*/
void exintp0(void) interrupt 0 using 0
{
uchar idata comm_r,cLoop;
uchar idata nn=0xff,mm=0x80,uu=0x7f;
EX0=0;
comm_r=0x15;
ZLG7289_NCS=1;ZLG7289_CLK=0;ZLG7289_NCS=0;
delay(0x88);
for(cLoop=0;cLoop<8;cLoop++)
{
if((comm_r&0x80)==0){ZLG7289_DIO=0;}
else{ZLG7289_DIO=1;}
delay(0x01);
ZLG7289_CLK=1; delay(0x0f);
ZLG7289_CLK=0; delay(0x0f);
comm_r<<=1;
}
delay(0x0f);
for(cLoop=0;cLoop<8;cLoop++)
{
ZLG7289_CLK=1; delay(0x0f);
ZLG7289_CLK=0; delay(0x0f);
if(ZLG7289_DIO==0){nn=(nn&uu);}
else{nn=(nn|mm);}
nn=_crol_(nn,1);
}
ZLG7289_NCS=1;
ZLG7289_CLK=0;
key_n=nn;
while(ZLG7289_K==0){delay(0x1ff);}
EX0=1;
}
void exintp1(void) interrupt 2 using 1
{
time_flag=0x88;
}
/*########################################################################################*/
/*中断函数区结束*/
/*########################################################################################*/
/*########################################################################################*/
/* 2.ZLG7289初始化子程序区
/*########################################################################################*/
void ZLG7289_ini(void)
{
ZLG7289_RST=0;delay(0x0f);ZLG7289_RST=1;
ZLG7289_NCS=1;ZLG7289_CLK=0;
}
/*########################################################################################*/
/* ZLG7289初始化子程序区结束
/*########################################################################################*/
/*########################################################################################*/
/* 3.ZLG7289显示子程序区
/*########################################################################################*/
void ZLG7289_write8_comm(uchar cData)
{
uchar idata cLoop;
ZLG7289_NCS=1;ZLG7289_CLK=0;ZLG7289_NCS=0;delay(0x14);
for(cLoop=0;cLoop<8;cLoop++)
{
if((cData&0x80)==0){ZLG7289_DIO=0;}
else{ZLG7289_DIO=1;}
delay(0x01);
ZLG7289_CLK=1; delay(0x02);
ZLG7289_CLK=0; delay(0x02);
cData<<=1;
}
ZLG7289_NCS=1;ZLG7289_CLK=0;
}
void ZLG7289_write8_data(uchar comm,uchar cData)
{
uchar idata cLoop;
ZLG7289_NCS=1;ZLG7289_CLK=0;;ZLG7289_NCS=0;delay(0x14);
for(cLoop=0;cLoop<8;cLoop++)
{
if((comm&0x80)==0){ZLG7289_DIO=0;}
else{ZLG7289_DIO=1;}
delay(0x01);
ZLG7289_CLK=1; delay(0x02);
ZLG7289_CLK=0; delay(0x02);
comm<<=1;
}
delay(0x01);
for(cLoop=0;cLoop<8;cLoop++)
{
if((cData&0x80)==0){ZLG7289_DIO=0;}
else{ZLG7289_DIO=1;}
delay(0x01);
ZLG7289_CLK=1; delay(0x02);
ZLG7289_CLK=0; delay(0x02);
cData<<=1;
}
ZLG7289_NCS=1;ZLG7289_CLK=0;
}
void ZLG7289_rst(void)
{
ZLG7289_write8_comm(0xa4);
delay(0xff);
}
/*########################################################################################*/
/* ZLG7289显示子程序区结束
/*########################################################################################*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -