slrc400程序设计文档格式.docx
- 文档编号:21485614
- 上传时间:2023-01-30
- 格式:DOCX
- 页数:14
- 大小:17.04KB
slrc400程序设计文档格式.docx
《slrc400程序设计文档格式.docx》由会员分享,可在线阅读,更多相关《slrc400程序设计文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
RC400_RST=0;
DelayMs(50);
RC400_RST=1;
DelayMs(5);
while(i!
=0&
&
n!
=PCD_RESETPHASE)
{
n=ReadRawRC(RegCommand);
i--;
}
n==PCD_RESETPHASE)
if(i!
=0)
WriteRawRC(RegPage,0x80);
n=0x80;
while((i!
=0)&
(n&
0x80))
if(i==0||(n&
0xFF))
{status=MI_RESETERR;
else
{status=MI_RESETERR;
if(status==MI_OK)
{WriteRawRC(RegPage,0x0);
returnstatus;
}
//////////////////////////////////////////////////////////////////////
//设置RC400的工作方式
charPcdConfigISOType()
ClearBitMask(RegControl,0x08);
//
WriteRawRC(RegTxControl,0x58);
//100%ASK
WriteRawRC(RegCwConductance,0x3f);
//输出功率和操作距离调整
WriteRawRC(RegModConductance,0x05);
//mustbemeasuredfor15%ModulationIndex
WriteRawRC(RegCoderControl,0x2f);
//2efast2f//,1-256coding
WriteRawRC(RegModWidth,0x3F);
//设置调制脉冲宽度:
WriteRawRC(RegModWidthSOF,0x3F);
//设置SOF脉冲宽度:
//WriteRawRC(RegTypeBFraming,0x00);
WriteRawRC(RegRxControl1,0x8b);
//控制接收:
电压增益42db
WriteRawRC(RegDecoderControl,0x34);
//c14);
WriteRawRC(RegBitPhase,0xad);
//0xcd);
//0xad);
//
WriteRawRC(RegRxThreshold,0x68);
//c68);
//WriteRawRC(RegBPSKDemControl,0);
WriteRawRC(RegRxControl2,0x81);
//c41);
I时钟用作接收器时钟
WriteRawRC(RegClockQControl,0x00);
WriteRawRC(RegRxWait,0x08);
WriteRawRC(RegChannelRedundancy,0x2C);
//EnableCRCTX/RX
WriteRawRC(RegCRCPresetLSB,0xFF);
WriteRawRC(RegCRCPresetMSB,0xFF);
WriteRawRC(RegTimeSlotPeriod,0x00);
WriteRawRC(RegSIGOUTSelect,0x00);
//0X02//enableSIGOUT=envelope
//WriteRawRC(RFU27,0x00);
WriteRawRC(RegFIFOLevel,0x38);
WriteRawRC(RegTimerClock,0x0B);
WriteRawRC(RegTimerReload,0x00);
WriteRawRC(RegTimerControl,0x02);
//TStopRxEnd=0,TStopRxBeg=1,
//WriteRawRC(RFU2E,0x00);
//WriteRawRC(RFU2F,0x00);
DelayMs
(1);
PcdAntennaOn();
returnMI_OK;
//读RC400寄存器位
//input:
Address=寄存器地址
//ouput:
读出的值
unsignedcharReadRawRC(unsignedcharAddress)
staticunsignedcharc;
c=ReadRawIO(Address);
//readvalueatthespecified
//address
returnc;
//写RC400寄存器
//value=要写入的值
voidWriteRawRC(unsignedcharAddress,unsignedcharvalue)
{
WriteRawIO(Address,value);
//置RC400寄存器位
reg=寄存器地址
//mask=置位值
voidSetBitMask(unsignedcharreg,unsignedcharmask)
chartmp=0x0;
tmp=ReadRawRC(reg);
WriteRawRC(reg,tmp|mask);
//setbitmask
//清RC400寄存器位
//mask=清位值
voidClearBitMask(unsignedcharreg,unsignedcharmask)
WriteRawRC(reg,tmp&
~mask);
//clearbitmask
}
//通过RC400和ISO15693卡通讯
pi->
MfCommand=RC400命令字
//pi->
MfLength=发送的数据长度
MfData[]=发送数据
//output:
status=错误字
MfLength=接收的数据BIT长度
MfData[]=接收数据
charISO15693_Transceive(structTranSciveBuffer*pi)
bitrecebyte=0;
charstatus=MI_COM_ERR;
unsignedcharn,waitFor,TimerReload;
unsignedinti;
switch(pi->
MfCommand)
{
casePCD_TRANSMIT:
waitFor=0x08;
//0x10;
break;
default:
waitFor=0x28;
recebyte=1;
}
/*
switch(pi->
MfData[1])
caseISO15693_STAY_QUIET:
TimerReload=0x04;
//2048/fc=>
0x01=151us
break;
caseISO15693_SELECT:
caseISO15693_RESET_TO_READY:
TimerReload=0x0F;
caseISO15693_LOCK_AFI:
caseISO15693_LOCK_DSFID:
caseISO15693_LOCK_BLOCK:
caseISO15693_WRITE_SINGLE_BLOCK:
caseISO15693_WRITE_MULTIPLE_BLOCKS:
caseISO15693_WRITE_AFI:
caseISO15693_WRITE_DSFID:
TimerReload=0x29;
caseISO15693_READ_SINGLE_BLOCK:
TimerReload=0x17;
caseISO15693_INVENTORY:
TimerReload=0x1F;
caseISO15693_GET_SYSTEM_INFO:
TimerReload=0x25;
caseISO15693_GET_MULTIPLE_BLOCK_SECURITY:
TimerReload=0x40;
//(0x04+(cmd[cmdlen-1]+0x01))*0x02+0x04+0x01;
//(0x04+cmd[cmdlen-1])*0x02->
TimeforallreceivedBytes,0x04->
Timebevoreandafterresponse,0x01additional
caseISO15693_READ_MULTIPLE_BLOCKS:
//(0x04+0x04*(cmd[cmdlen-1]+0x01))*0x02+0x04+0x01;
default:
TimerReload=0x86;
WriteRawRC(RegPage,0x00);
WriteRawRC(RegFIFOLevel,0x1A);
SetBitMask(RegChannelRedundancy,0x04);
WriteRawRC(RegTimerReload,TimerReload);
WriteRawRC(RegTimerControl,0x06);
*/
SetBitMask(RegControl,0x01);
WriteRawRC(RegCommand,0x00);
WriteRawRC(RegInterruptEn,0x81);
WriteRawRC(RegInterruptRq,0x3F);
WriteRawRC(RegInterruptEn,0x38|0x80);
for(i=0;
i<
pi->
MfLength;
i++)
WriteRawRC(RegFIFOData,pi->
MfData[i]);
_nop_();
_nop_();
WriteRawRC(RegCommand,PCD_TRANSCEIVE);
//starttosendcommandtolabel
i=0xa000;
do
n=ReadRawRC(RegInterruptRq);
i--;
}while((i!
!
(n&
waitFor));
//等待发送完毕
if(!
recebyte)
{
if(n&
0x10)
status=MI_OK;
WriteRawRC(RegInterruptEn,0x10);
WriteRawRC(RegTimerControl,0x00);
WriteRawRC(RegCommand,PCD_IDLE);
ClearBitMask(RegCoderControl,0x80);
returnstatus;
else
if((i!
0x08))
if(!
(ReadRawRC(RegErrorFlag)&
0x0C))
n=ReadRawRC(RegFIFOLength);
pi->
MfLength=n*8;
n;
MfData[i]=ReadRawRC(RegFIFOData);
if(pi->
MfData[0]==0)//没有错误标志
status=MI_OK;
}
//开启天线
//每次启动或关闭天险发射之间应至少有1ms的间隔
charPcdAntennaOn()
unsignedchari;
i=ReadRawRC(RegTxControl);
if(i&
0x03)
{returnMI_OK;
SetBitMask(RegTxControl,0x03);
charISO15693_Transceive1(structTranSciveBuffer*pi)
waitFor=0x10;
SetBitMask(RegContr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- slrc400 程序设计
![提示](https://static.bdocx.com/images/bang_tan.gif)