中级会员
 
- 积分
- 303
- 金钱
- 303
- 注册时间
- 2016-4-21
- 在线时间
- 129 小时
|
10金钱
精英板上是用FSMC驱动TFT屏幕,我的RFID RC522模块是接在PB组IO口,用的SPI2,应该不会影响到啊,不知道为什么寻卡时(status = PcdRequest(PICC_REQALL,CT);) 会黑屏,我贴下寻卡时的部分代码[mw_shl_code=c,true]char PcdComMF522(u8 Command,
u8 *pIn ,
u8 InLenByte,
u8 *pOut ,
u8 *pOutLenBit)
{
char status = MI_ERR;
u8 irqEn = 0x00;
u8 waitFor = 0x00;
u8 lastBits;
u8 n;
u16 i;
switch (Command)
{
case PCD_AUTHENT:
irqEn = 0x12;
waitFor = 0x10;
break;
case PCD_TRANSCEIVE:
irqEn = 0x77;
waitFor = 0x30;
break;
default:
break;
}
WriteRawRC(ComIEnReg,irqEn|0x80);
ClearBitMask(ComIrqReg,0x80); //清所有中断位
WriteRawRC(CommandReg,PCD_IDLE);
SetBitMask(FIFOLevelReg,0x80); //清FIFO缓存
for (i=0; i<InLenByte; i++)
{ WriteRawRC(FIFODataReg, pIn ); }
WriteRawRC(CommandReg, Command);
// n = ReadRawRC(CommandReg);
if (Command == PCD_TRANSCEIVE)
{ SetBitMask(BitFramingReg,0x80); } //开始传送
//i = 600;//根据时钟频率调整,操作M1卡最大等待时间25ms
i = 1000;
do
{
n = ReadRawRC(ComIrqReg);
i--;
}
while ((i!=0) && !(n&0x01) && !(n&waitFor));
ClearBitMask(BitFramingReg,0x80);
if (i!=0)
{
if(!(ReadRawRC(ErrorReg)&0x1B))
{
status = MI_OK;
if (n & irqEn & 0x01)
{ status = MI_NOTAGERR; }
if (Command == PCD_TRANSCEIVE)
{
n = ReadRawRC(FIFOLevelReg);
lastBits = ReadRawRC(ControlReg) & 0x07;
if (lastBits)
{ *pOutLenBit = (n-1)*8 + lastBits; }
else
{ *pOutLenBit = n*8; }
if (n == 0)
{ n = 1; }
if (n > MAXRLEN)
{ n = MAXRLEN; }
for (i=0; i<n; i++)
{ pOut = ReadRawRC(FIFODataReg); }
}
}
else
{ status = MI_ERR; }
}
SetBitMask(ControlReg,0x80); // stop timer now
WriteRawRC(CommandReg,PCD_IDLE);
return status;
}[/mw_shl_code]
|
|