📄 ic1.txt
字号:
static void Delay10us(void)
{
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_
();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
}
extern void ICYD() // IC卡应答
{
uchar CRA;
CLK=0;
Delay10us();
RST=0;
Delay10us();
RST=1;
Delay10us();
Delay10us();
Delay10us();
CLK=1;
Delay10us();
CLK=0;
Delay10us();
RST=0;
Delay10us();
for(CRA=0;CRA<32;CRA++)
{
if(CRA<8)
{
ICHC[0]=ICHC[0]<<1;
if(IO==1)
{
ICHC[0]|=0x01;
}
}
if((CRA>7)&&(CRA<16))
{
ICHC[1]=ICHC[1]<<1;
if(IO==1)
{
ICHC[1]|=0x01;
}
}
if((CRA>15)&&(CRA<24))
{
ICHC[2]=ICHC[2]<<1;
if(IO==1)
{
ICHC[2]|=0x01;
}
}
if((CRA>23)&&(CRA<32))
{
ICHC[3]=ICHC[3]<<1;
if(IO==1)
{
ICHC[3]|=0x01;
}
}
}
CLK=1;
Delay10us();
CLK=0;
Delay10us();
}
extern void ICMAND(uchar MA,AD,DB) // 通用读写
{
uchar SA,SB;
IO=1;
Delay10us();
CLK=1;
Delay10us();
IO=0;
Delay10us();
CLK=0; //IC START
SA=1;
for(SB=8;SB>0;SB--)
{
if((MA&SA)==SA)
{IO=1;}
else
{IO=0;}
SA=SA<<1;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
CLK=0;
}
Delay10us();
SA=1;
for(SB=8;SB>0;SB--)
{
if((AD&SA)==SA)
{IO=1;}
else
{IO=0;}
SA=SA<<1;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
CLK=0;
}
Delay10us();
SA=1;
for(SB=0;SB<8;SB++)
{
if((DB&SA)==SA)
{IO=1;}
else
{IO=0;}
SA=SA<<1;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
CLK=0;
}
IO=0;
Delay10us();
CLK=1;
Delay10us();
IO=1;
}
extern uchar RDMAND(uchar AD)
{
uchar SA,SB;
uint SC,SD;
ICMAND(0x30,AD,0x00);
Delay10us();
for(SA=8;SA>0;SA--)
{
CLK=0;
SB=SB>>1;
if(IO==1)
{SB|=0x80;}
CLK=1;
}
SC=(256-AD)*8+2;
for(SD=0;SD<SC;SD++)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
return(SB);
}
extern void LRDMAND(uchar AD)
{
uchar SA,SB;
uint SC,SD;
ICMAND(0x30,AD,0x00);
Delay10us();
for(SC=0;SC<16;SC++)
{
for(SA=8;SA>0;SA--)
{
CLK=0;
SB=SB>>1;
if(IO==1)
{SB|=0x80;}
CLK=1;
}
ICHC[SC]=SB;
}
AD=AD+16;
SC=(256-AD)*8+1;
for(SD=0;SD<SC;SD++)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
}
extern void WRMAND(uchar AD,DB)
{
uint SD;
ICMAND(0x38,AD,DB);
Delay10us();
for(SD=256;SD>0;SD--)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
}
extern void WRMIMA(uchar AD,DB)
{
uint SD;
ICMAND(0x39,AD,DB);
Delay10us();
for(SD=256;SD>0;SD--)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
}
extern uchar RDMIMA()
{
uchar SA,SB,SC,SE;
ICMAND(0x31,0x00,0x00);
for(SC=4;SC>0;SC--)
{
for(SA=8;SA>0;SA--)
{
CLK=0;
Delay10us();
SB=SB>>1;
if(IO==1) {SB|=0x80;}
CLK=1;
}
ICHC[SC]=SB;
}
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
CLK=0;
CLK=0;
CLK=0;
CLK=0;
SE=ICHC[0];
return(SE);
}
extern uchar VERMIMA(uchar MA1,MA2,MA3)
{
uchar MB;
MB=RDMIMA;
Delay10us();
if(MB==7)
{WRMIMA(0,6);}
if(MB==6)
{WRMIMA(0,4);}
if(MB==4)
{WRMIMA(0,0);}
Delay10us();
Delay10us();
Delay10us();
Delay10us();
ICMAND(0x33,1,MA1);
for(MB=3;MB>0;MB--)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
Delay10us();
ICMAND(0x33,2,MA2);
for(MB=3;MB>0;MB--)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
Delay10us();
ICMAND(0x33,3,MA3);
for(MB=3;MB>0;MB--)
{
CLK=0;
CLK=0;
CLK=0;
CLK=0;
CLK=1;
CLK=1;
CLK=1;
CLK=1;
}
CLK=0;
Delay10us();
WRMIMA(0,0xff);
Delay10us();
MB=RDMIMA;
return(MB);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -