📄 i2c_host.c
字号:
#include"stdafx.h"
#include"I2C_fun.h"
#include"t6963.h"
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
unsigned long ct0,ct1;
void main(void)
{
unsigned char a,b,c,d,e,f;
//I_init();
unsigned long temp0,temp1;
ct0=ct1=0;
LCMInit();
LCMClear();
P10=1;
P11=1;
P12=1;
TMOD =0x11;
TL0=TH0=0;
TL1=TH1=0;
ET1=ET0=1;
EA=1;
Start:
I_start();
if(I_send(0x5f)){
TR1=1;
a=I_receive();
I_Ack();
TR1=0;
temp1=TH1;
temp1=temp1*256+TL1+ct1*0xffff;
b=I_receive();
I_NoAck();
I_stop();
}
else goto Start;
if(a==5) P10=0;
if(b==8) P11=0;
I_start();
a=I_send(0x5e);
P12=a;
if(a)
{
TR0=1;
I_send(0x09);
TR0=0;
temp0=TH0;
temp0=temp0*256+TL0+ct0*0xffff;
//I_clock();
I_stop();
}
a=temp0%10;
b=(temp0/10)%10;
c=(temp0/100)%10;
d=(temp0/1000)%10;
e=(temp0/10000)%10;
f=(temp0/100000);
DisplayOneChar(0,0,f|0x30);
DisplayOneChar(1,0,e|0x30);
DisplayOneChar(2,0,d|0x30);
DisplayOneChar(3,0,c|0x30);
DisplayOneChar(4,0,b|0x30);
DisplayOneChar(5,0,a|0x30);
a=temp1%10;
b=temp1/10%10;
c=temp1/100%10;
d=temp1/1000%10;
e=temp1/10000%10;
f=temp1/100000 ;
DisplayOneChar(0,1,f|0x30);
DisplayOneChar(1,1,e|0x30);
DisplayOneChar(2,1,d|0x30);
DisplayOneChar(3,1,c|0x30);
DisplayOneChar(4,1,b|0x30);
DisplayOneChar(5,1,a|0x30);
while(1);
}
void t0(void) interrupt 1
{
ct0++;
TR0=1;
}
void t1(void) interrupt 3
{
ct1++;
TR1=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -