📄 msp430ywqz.c
字号:
}
IC_error = 0;
a = IC_read(0x00);
if (IC_error == 0xff)
{
sound_s();
goto FK_error; //卡查反
}
IC_error = 0;//
disp_lcd(0x0d,0x0a,0x0a,0x0d,0);
for(b=1;b<3;b++)
{//
delay(255);
delay(200);
disp_lcd(0x0e,0x0e,0x0e,0x0e,0);
delay(255);
delay(200);
disp_lcd(0x0d,0x0a,0x0a,0x0d,0);
}//
a = (BCD[6]<<4)+BCD[7];
IC_write(FYS_save1,a);
delay(20);
a = BCD[5];
IC_write(FYS_save0,a);
delay(20);
IC_write(FYS_flag,1);
delay(20);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lsbuf=(uint)(re1byte(0x00));
lsbuf=(uint)(lsbuf*256+re1byte(0x01));
if(lsbuf>2700)
{
for(i=0;i<50;i++)
delay(200);
goto testend;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
////////////////////////////////////////////////////////////
readicid(); //读取卡号
result[0]=0x00;
result[1]=0x00;
result[2]=BCD[5];
result[3]=(BCD[6]<<4)+BCD[7];
FLAG2|=BIT0; //置数据有标志,可进行发送
//disp_lcd(0x01,0x01,0x01,0x01,0);
for(i=0;i<5;i++)
delay(200);
FLAG2&=~BIT0;
lsbuf=(uint)(re1byte(0x00));
lsbuf=(uint)(lsbuf*256+re1byte(0x01));
for(ii=0;ii<8;ii++)
{
temp=icidbuf[ii];
wr1byte(0x40+12*lsbuf+ii,temp);
delay(50);
}
for(ii=0;ii<4;ii++)
{
temp=result[ii];
wr1byte(0x40+12*lsbuf+8+ii,temp);
delay(50);
}
lsbuf++;
at64count++;
temp=(uchar)(lsbuf/256);
wr1byte(0x00,temp);
delay(50);
temp=(uchar)(lsbuf%256);
wr1byte(0x01,temp);
delay(50);
////////////////////////////////////////////////////////////
a = IC_read(FYS_save0);
disp1 = a;
a = IC_read(FYS_save1);
disp2 = a>>4;
a = a<<4;
disp3 = a >> 4;
disp_lcd(0,disp1,disp2,disp3,0);
sound_s();
/*incard_led = 1;*/
P5OUT|=BIT0;
/*test_led = 1;*/
P5OUT&=~BIT3;
/*incard_led = 1;*/
P5OUT&=~BIT2;
/*testend_led = 0;*/
P5OUT&=~BIT1;
FLAG&=~BIT3;
goto mainloop1;
testend: /*incard_led = 1;*/
P5OUT|=BIT0;
/*test_led = 1;*/
P5OUT&=~BIT3;
/*incard_led = 1;*/
P5OUT&=~BIT2;
/*testend_led = 0;*/
P5OUT&=~BIT1;
FLAG&=~BIT3;
goto mainloop;
disp_lcd(0x0d,0x0d,0x0d,0x0d,0);
}
void checkcard(void)
{
if((P1IN&BIT2)== 0) //P1IN&BIT2为card_sw
{
delay(200);
IC_error = 0;
a = IC_read(PASS0);
i = a;
i = i<<8;
a = IC_read(PASS1);
i = i+a;
if ((IC_error == 0xff)||(i!=0x4a48)) //判卡:1。插反 2。误卡
{
//while(card_sw == 0)
while((P1IN&BIT2)== 0)
{
disp_lcd(0x0d,0x0c,0x0c,0x0d,0);
//EA = 0;
_DINT();
sound_s();
sound_s();
//EA = 1;
_EINT();
delay(100);
delay(100);
delay(100);
delay(100);
}
}
else
{
/*prep_led = 0;*/
//P5OUT|=BIT1;
/*incard_led = 1;*/
P5OUT&=~BIT0;
/*P5OUT|=BIT0; */
a = IC_read(NUM0);
i = a;
i = i<<8;
a = IC_read(NUM1);
i = i+a;
HEX_BCD(i);
disp_lcd(BCD[4],BCD[5],BCD[6],BCD[7],0);//显示编号
sound_s();
delay(255);
delay(255);
delay(255);
delay(255);
readicid(); /*************读取卡号****************/
b = 0;
//EX0 = 0;
P2IE&=~BIT6;
prenum = 0;
a = IC_read(FYS_flag);
if (a!=0)
{
/*prep_led = 0;*/
P5OUT|=BIT0;
/*incard_led = 1;*/
P5OUT&=~BIT3;
/*P5OUT|=BIT0; */
P5OUT&=~BIT1;
//repeatestf = 0xb0;
//goto disp_end; //已经测试,显示结果
xsjg();
}
else
{
P5OUT&=~BIT3;
/*P5OUT|=BIT0; */
P5OUT&=~BIT0;
/*P5OUT|=BIT0; */
P5OUT|=BIT2;
/*P5OUT|=BIT0; */
P5OUT&=~BIT1;
}
}
}
}
void HEX_BCD(unsigned long dd)
{
unsigned long div;
uchar i;
div=10000000;
for (i=0;i<8;i++)
{
BCD[i]=dd/div;
dd%=div;
div/=10;
}
}
void HEX_BCD4(uint dd)
{
uint div;
uchar i;
div=10000;
for (i=3;i<8;i++)
{
BCD[i]=dd/div;
dd%=div;
div/=10;
}
}
//////////////////////////////////
void sound_s(void)
{
/*sound = 1;*/
P5OUT|=BIT7; //打开蜂鸣器
delay(200);
delay(200);
/*sound = 0;*/
P5OUT&=~BIT7; //关闭蜂鸣器
}
void sound_star(void)
{
/*sound = 1;*/
P5OUT|=BIT7; //打开蜂鸣器
delay (200);
delay (200);
delay (200);
delay (200);
/*sound = 0;*/
P5OUT&=~BIT7; //关闭蜂鸣器
}
void delay1(uchar x)
{
uint i;
for(i=0;i<x;i++);
}
void nop()
{
}
/*void start()
{
sda=1;
nop();
scl=1;
nop();
sda=0;
nop();
scl=0;
nop();
}*/
void start430()
{
P3OUT|=(SDA430+SCL430); //将SDA置1
P3DIR|=(SCL430+SDA430); //将SCL SDA定义为输出
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT|=SCL430; //SCL=1
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT&=~SDA430; //SDA=0;
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT&=~SCL430; //SCL=0
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
}
/*void stop()
{
sda=0;
nop();
scl=1;
nop();
sda=1;
nop();
}*/
void stop430()
{
P3OUT&=~SDA430; //SDA=0
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT|=SCL430; //SCL=1
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT|=SDA430; //SDA=1
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
}
/*void writex(uchar j)
{
uchar i,temp;
temp=j;
for (i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
nop();
sda=CY;
nop();
scl=1;
nop();
}
scl=0;
nop();
sda=1;
nop();
}*/
void writex430(uchar j)
{
uchar i,temp,temp1;
temp=j;
for (i=0;i<8;i++)
{
P3OUT&=~SCL430; //SCL=0;
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
//P3OUT&=~SDA430;
nop();
nop();
temp1=(temp&0x80);
if(temp1==0) P3OUT&=~SDA430;
else P3OUT|=SDA430;
/*P3OUT|=((temp&0x80)/32); //sda=temp的最高位*/
temp=temp<<1;
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
P3OUT|=SCL430; //SCL=1;
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
nop();
}
P3OUT&=~SCL430; //SCL=0
nop();
nop();
nop();
nop();
nop();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -