按道理说,我在程序后面使卡进入休眠状态了,但是为什么会被重复读取呢?
程序如下:
int main(void)
{
unsigned char status;
//u8 Data[16];
//u8 i;
//u8 k;//读写错误重试次数
u8 m;
delay_init(); //延时函数初始化
NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
OUTPUT_Init(); //输出模块初始化
uart_init(9600);
LCD_Init();
KEY_Init();
InitRc522(); //初始化射频卡模块
//sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//将LCD ID打印到lcd_id数组。
LEDA=1;
while(1)
{
status = PcdRequest(PICC_REQALL,CT);/*尋卡*/
if(status==MI_OK)//尋卡成功
{
printf("PcdRequest_MI_OK\t\n");
status=MI_ERR;
status = PcdAnticoll(SN);/*防冲撞*/
}
if (status==MI_OK)//防衝撞成功
{
printf("PcdAnticoll_MI_OK\t\n");
status=MI_ERR;
LEDA=1;
LEDB=1;
// ShowID(0,200,SN,BLUE,WHITE); //在液晶屏上显示卡的ID号
printf("ID:%02x %02x %02x %02x\t\n",SN[0],SN[1],SN[2],SN[3]);//发送卡号
if((SN[0]==card_1[0])&&(SN[1]==card_1[1])&&(SN[2]==card_1[2])&&(SN[3]==card_1[3]))
{
printf("The User is:小明\t\n");
}
if((SN[0]==card_2[0])&&(SN[1]==card_2[1])&&(SN[2]==card_2[2])&&(SN[3]==card_2[3]))
{
printf("The User is:小华\t\n");
}
if((SN[0]==card_3[0])&&(SN[1]==card_3[1])&&(SN[2]==card_3[2])&&(SN[3]==card_3[3]))
{
printf("The User is:小李\t\n");
}
if((SN[0]==card_4[0])&&(SN[1]==card_4[1])&&(SN[2]==card_4[2])&&(SN[3]==card_4[3]))
{
printf("The User is:小王\t\n");
}
// total=card1_bit+card2_bit+card3_bit+card4_bit+lxl_bit;
// LCD_ShowString(0,16,200,16,16,"total:");
// LCD_ShowNum(46,16,total,2,16);
status =PcdSelect(SN);
if(status==MI_OK)
{
printf("PcdSelect_MI_OK");
status = PcdHalt();
}
if(status==MI_OK)
{
printf("PcdHalt_MI_OK");
}
} |