亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mfrc500uc.c

?? RC500的mifare卡開發備用程序及電路
?? C
?? 第 1 頁 / 共 3 頁
字號:
*              - PCD_AUTHENT2
*              - PCD_RECEIVE
*              - PCD_LOADKEY
*              - PCD_TRANSMIT
*              - PCD_TRANSCEIVE
*             
*       send  (IN)
*             byte stream of variable length, which should be send to
*             the PICC, the length of stream has to be specified
*             in the info - structure
*       rcv   (OUT) 
*             byte stream of variable length, which was received 
*             from the PICC. The length can be obtained from the
*             info - structure
*       info  (OUT)
*             communication and status structure
* return: enum:
*          - MI_OK               operation without error
*          - MI_NOTAGERR         no tag in rf field
*          - MI_ACCESSTIMEOUT    RIC is not responding in time
*          - MI_COLLERR          collision in during rf data transfer
*          - MI_PARITYERR        parity error while receiving data
*          - MI_FRAMINGERR       framing error - start bit not valid
*          - MI_OVFLERR          FIFO overflow - to many data bytes
*          - MI_CRCERR           CRC error of received data
*          - MI_NY_IMPLEMENTED   internal error - source not identified
*         
*
* This function provides the central interface to the reader module.
* Depending on the "cmd"-value, all necessary interrupts are enabled
* and the communication is started. While the processing is done by
* the reader module, this function waits for its completion.
*
* It's notable, that the data in the send byte stream is written 
* to the FIFO of the reader module by the ISR itself. Immediate after 
* enabling the interrupts, the LoAlert interrupt is activated.
*
* The ISR writes the data to the FIFO. This function is not directly involved
* in writing or fetching data from FIFO, all work is done by the 
* corresponding ISR.After command completion, the error status is evaluated and 
* returned to the calling function.
*/ 
char PcdSingleResponseCmd(unsigned char cmd,
                volatile unsigned char* send, 
                volatile unsigned char* rcv,
                volatile MfCmdInfo *info);

/// Basic Register definitions
/*!
* return: none
*/
char PcdBasicRegisterConfiguration(void);

/// Set Reader IC Register Bit
/*!
* -o  reg  (IN)
*             register address
* -o  mask (IN)
*             Bit mask to set
* return:     none
*              
* This function performs a read - modify - write sequence
* on the specified register. All bits with a 1 in the mask
* are set - all other bits keep their original value.
*/
void SetBitMask(unsigned char reg,unsigned char mask);

/// Clear Reader IC Register Bit
/*!
* -o  reg  (IN)
*             register address
* -o  mask (IN)
*             Bit mask to clear
* return: none
*              
* This function performs a read - modify - write sequence
* on the specified register. All bits with a 1 in the mask
* are cleared - all other bits keep their original value.
*/
void ClearBitMask(unsigned char reg,unsigned char mask);

/// Flush remaining data from the FIFO
/*!
* -o  none
* return: none
*              
* This function erases  all remaining data in the MF RC 500's FIFO .
* Before writing new data or starting a new command, all remaining data 
* from former  commands should be deleted.
*/
void FlushFIFO(void);

/// Sleep several milliseconds
/*
The implementation of this function depends heavily
on the microcontroller in use. The measurement need not to be
very accurate. Only make sure, that the periode is not shorter, than
the required one.
*/
void SleepMs(unsigned short ms);

/// Sleep several microseconds
/*
The implementation of this function depends heavily
on the microcontroller in use. The measurement need not to be
very accurate. Only make sure, that the periode is not shorter, than
the required one.
*/
void SleepUs(unsigned short us);


///////////////////////////////////////////////////////////////////////
//      M I F A R E   M O D U L E   C O N F I G U R A T I O N
///////////////////////////////////////////////////////////////////////
char Mf500PcdConfig(void)
{
   char status = MI_RESETERR;
      
   status = PcdReset();

   if (status == MI_OK)
   {
     if ((status = PcdBasicRegisterConfiguration()) == MI_OK);
     {
        Mf500PcdWriteAttrib(); // write current modulation parameters
        PcdRfReset(1); // Rf - reset and enable output driver    
     }
   }
   return status;
}

///////////////////////////////////////////////////////////////////////
//          M I F A R E   R E M O T E   A N T E N N A
//  Configuration of slave module
///////////////////////////////////////////////////////////////////////
char Mf500ActiveAntennaSlaveConfig(void)
{
   char status = MI_OK;

   FlushFIFO();    // empty FIFO
   ResetInfo(MInfo);   
   MSndBuffer[0] = 0x10; // addr low byte
   MSndBuffer[1] = 0x00; // addr high byte

   MSndBuffer[2] = 0x00; // Page
   MSndBuffer[3] = 0x7B; // RegTxControl modsource 11,InvTx2,Tx2RFEn,TX1RFEn
   MSndBuffer[4] = 0x3F; // RegCwConductance
   MSndBuffer[5] = 0x3F; // RFU13
   MSndBuffer[6] = 0x19; // RFU14
   MSndBuffer[7] = 0x13; // RegModWidth     
   MSndBuffer[8] = 0x00; // RFU16
   MSndBuffer[9] = 0x00; // RFU17
 
   MSndBuffer[10] = 0x00; // Page
   MSndBuffer[11] = 0x73; // RegRxControl1 
   MSndBuffer[12] = 0x08; // RegDecoderControl
   MSndBuffer[13] = 0x6c; // RegBitPhase     
   MSndBuffer[14] = 0xFF; // RegRxThreshold  
   MSndBuffer[15] = 0x00; // RegBPSKDemControl
   MSndBuffer[16] = 0x00; // RegRxControl2   
   MSndBuffer[17] = 0x00; // RegClockQControl

   MSndBuffer[18] = 0x00; // Page
   MSndBuffer[19] = 0x06; // RegRxWait
   MSndBuffer[20] = 0x03; // RegChannelRedundancy
   MSndBuffer[21] = 0x63; // RegCRCPresetLSB    
   MSndBuffer[22] = 0x63; // RegCRCPresetMSB    
   MSndBuffer[23] = 0x0;  // RFU25
   MSndBuffer[24] = 0x04; // RegMfOutSelect enable mfout = manchester HT
   MSndBuffer[25] = 0x00; // RFU27
     
   // PAGE 5      FIFO, Timer and IRQ-Pin Configuration
   MSndBuffer[26] = 0x00; // Page
   MSndBuffer[27] = 0x08; // RegFIFOLevel       
   MSndBuffer[28] = 0x07; // RegTimerClock      
   MSndBuffer[29] = 0x06; // RegTimerControl    
   MSndBuffer[30] = 0x0A; // RegTimerReload     
   MSndBuffer[31] = 0x02; // RegIRqPinConfig    
   MSndBuffer[32] = 0x00; // RFU    
   MSndBuffer[33] = 0x00; // RFU
   MInfo.nBytesToSend   = 34;
         
   status = PcdSingleResponseCmd(PCD_WRITEE2,
                   MSndBuffer,
                   MRcvBuffer,
                   &MInfo); // write e2
   return status;
}

///////////////////////////////////////////////////////////////////////
//          M I F A R E   R E M O T E   A N T E N N A
//  Configuration of master module
///////////////////////////////////////////////////////////////////////
char Mf500ActiveAntennaMasterConfig(void)
{
   char status = MI_OK;

   WriteRC(RegRxControl2,0x42);
   WriteRC(RegTxControl,0x10);
   WriteRC(RegBitPhase,0x11);
   WriteRC(RegMfOutSelect,0x02);

   return status;
}     
                  
///////////////////////////////////////////////////////////////////////
//          M I F A R E    R E Q U E S T 
///////////////////////////////////////////////////////////////////////
char Mf500PiccRequest(unsigned char req_code, // request code ALL = 0x52 
                                           // or IDLE = 0x26 
                   unsigned char *atq)     // answer to request
{
  return Mf500PiccCommonRequest(req_code,atq);
}

///////////////////////////////////////////////////////////////////////
//          M I F A R E   C O M M O N   R E Q U E S T 
///////////////////////////////////////////////////////////////////////
char Mf500PiccCommonRequest(unsigned char req_code, 
                            unsigned char *atq)
{
   char status = MI_OK;

    //************* initialize ******************************
   if ((status = Mf500PcdSetDefaultAttrib()) == MI_OK)
   {
   
      PcdSetTmo(60);
      
      WriteRC(RegChannelRedundancy,0x03); // RxCRC and TxCRC disable, parity enable
      ClearBitMask(RegControl,0x08);      // disable crypto 1 unit   
      WriteRC(RegBitFraming,0x07);        // set TxLastBits to 7 
      
      ResetInfo(MInfo);   
      MSndBuffer[0] = req_code;
      MInfo.nBytesToSend   = 1;   
      MInfo.DisableDF = 1;
      status = PcdSingleResponseCmd(PCD_TRANSCEIVE,
                         MSndBuffer,
                         MRcvBuffer,
                         &MInfo);
      if ((status == MI_OK) && (MInfo.nBitsReceived != 16)) // 2 bytes expected
      {
         status = MI_BITCOUNTERR;
      } 
      if ((status == MI_COLLERR) && (MInfo.nBitsReceived == 16)) //
         status = MI_OK; // all received tag-types are combined to the 16 bit
         
      // in any case, copy received data to output - for debugging reasons
      if (MInfo.nBytesReceived >= 2)
      {
         memcpy(atq,MRcvBuffer,2);      
      }
      else
      {
         if (MInfo.nBytesReceived == 1)
            atq[0] = MRcvBuffer[0];
         else
            atq[0] = 0x00;
         atq[1] = 0x00;
      }
   }
   return status; 
}

///////////////////////////////////////////////////////////////////////
//          M I F A R E    A N T I C O L L I S I O N
// for standard select
///////////////////////////////////////////////////////////////////////
char Mf500PiccAnticoll (unsigned char bcnt,
                     unsigned char *snr)
{
   return Mf500PiccCascAnticoll(0x93,bcnt,snr); // first cascade level
}

///////////////////////////////////////////////////////////////////////
//          M I F A R E    A N T I C O L L I S I O N
// for extended serial numbers
///////////////////////////////////////////////////////////////////////
char Mf500PiccCascAnticoll (unsigned char select_code,
                         unsigned char bcnt,       
                         unsigned char *snr)       
{
   char  status = MI_OK;
   char  snr_in[4];         // copy of the input parameter snr
   char  nbytes = 0;        // how many bytes received
   char  nbits = 0;         // how many bits received
   char  complete = 0;      // complete snr recived
   short i        = 0;
   char  byteOffset = 0;
   unsigned char snr_crc;   // check byte calculation
   unsigned char snr_check;
   unsigned char dummyShift1;       // dummy byte for snr shift
   unsigned char dummyShift2;       // dummy byte for snr shift   
 
   //************* Initialisierung ******************************
   if ((status = Mf500PcdSetDefaultAttrib()) == MI_OK)
   {
      PcdSetTmo(106);
      
      memcpy(snr_in,snr,4);   
      
      WriteRC(RegDecoderControl,0x28); // ZeroAfterColl aktivieren   
      ClearBitMask(RegControl,0x08);    // disable crypto 1 unit
         
      //************** Anticollision Loop ***************************
      complete=0;
      while (!complete && (status == MI_OK) )
      {
         // if there is a communication problem on the RF interface, bcnt 
         // could be larger than 32 - folowing loops will be defective.
         if (bcnt > 32)
         {
            status = MI_WRONG_PARAMETER_VALUE;
            continue;
         }
         ResetInfo(MInfo);
         MInfo.cmd = select_code;   // pass command flag to ISR        
         MInfo.DisableDF = 1;
         WriteRC(RegChannelRedundancy,0x03); // RxCRC and TxCRC disable, parity enable
         nbits = bcnt % 8;   // remaining number of bits
         if (nbits)
         {
            WriteRC(RegBitFraming,nbits << 4 | nbits); // TxLastBits/RxAlign auf nb_bi
            nbytes = bcnt / 8 + 1;   
            // number of bytes known
   
            // in order to solve an inconsistancy in the anticollision sequence
            // (will be solved soon), the case of 7 bits has to be treated in a
            // separate way
            if (nbits == 7 )
            {
            	MInfo.RxAlignWA = 1;
               MInfo.nBitsReceived = 7; // set flag for 7 bit anticoll, which is evaluated
                                        // in the ISRnBitsReceived        
               WriteRC(RegBitFraming,nbits); // reset RxAlign to zero
            }
         } 
         else
         {
            nbytes = bcnt / 8;
         }
  
         MSndBuffer[0] = select_code;
         MSndBuffer[1] = 0x20 + ((bcnt/8) << 4) + nbits; //number of bytes send
                  
         for (i = 0; i < nbytes; i++)  // Sende Buffer beschreiben
         {
            MSndBuffer[i + 2] = snr_in[i];
         }
         MInfo.nBytesToSend   = 2 + nbytes;    

         status = PcdSingleResponseCmd(PCD_TRANSCEIVE,
                            MSndBuffer,
                            MRcvBuffer,
                            &MInfo);

          // in order to solve an inconsistancy in the anticollision sequence
          // (will be solved soon), the case of 7 bits has to be treated in a
          // separate way 
         if (MInfo.RxAlignWA)
         {
            // reorder received bits
            dummyShift1 = 0x00;
            for (i = 0; i < MInfo.nBytesReceived; i++)
            {
                dummyShift2 = MRcvBuffer[i];
                MRcvBuffer[i] = (dummyShift1 >> (i+1)) | (MRcvBuffer[i] << (7-i));
                dummyShift1 = dummyShift2;
            }
            MInfo.nBitsReceived -= MInfo.nBytesReceived; // subtract received parity bits
            // recalculation of collision position
            if ( MInfo.collPos ) MInfo.collPos += 7 - (MInfo.collPos + 6) / 9;
         }
         
         if ( status == MI_OK || status == MI_COLLERR)    // no other occured
         {

            byteOffset = 0;
            if ( nbits != 0 )           // last byte was not complete
            {
               snr_in[nbytes - 1] = snr_in[nbytes - 1] | MRcvBuffer[0];
               byteOffset = 1;
            }
            for ( i =0; i < (4 - nbytes); i++)     
            {
               snr_in[nbytes + i] = MRcvBuffer[i + byteOffset];
            }
            // R e s p o n s e   P r o c e s s i n g   
            if ( MInfo.nBitsReceived != (40 - bcnt) ) // not 5 bytes answered
            {
               status = MI_BITCOUNTERR;
            } 
            else 
            {
               if (status != MI_COLLERR ) // no error and no collision
               {
                  // SerCh check
                  snr_crc = snr_in[0] ^ snr_in[1] ^ snr_in[2] ^ snr_in[3];
                  snr_check = MRcvBuffer[MInfo.nBytesReceived - 1];
                  if (snr_crc != snr_check)
                  {
                     status = MI_SERNRERR;
                  } 
                  else   
                  {
                     complete = 1;
                  }
               }
               else                   // collision occured
               {
                  bcnt = bcnt + MInfo.collPos - nbits;
                  status = MI_OK;
               }
            }
        }
      }
   }
   // transfer snr_in to snr - even in case of an error - for 
   // debugging reasons

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级生活片| 日韩码欧中文字| 国产精品久久久久久久久久免费看 | 成人美女视频在线观看| 欧美日韩成人综合| 国产精品美女www爽爽爽| 免费在线看成人av| 色网综合在线观看| 欧美激情中文字幕一区二区| 蜜臀久久久久久久| 在线观看av一区| 亚洲图片激情小说| 成人免费视频一区| 久久婷婷国产综合国色天香| 日韩精品电影在线观看| 欧美在线你懂得| 一区二区三区视频在线看| 成熟亚洲日本毛茸茸凸凹| 欧美xxxx在线观看| 免费看精品久久片| 1000部国产精品成人观看| 国产成人h网站| 国产欧美一区视频| 国产成人av电影在线| 久久精品一二三| 成人在线综合网站| 日本一区二区三区电影| 成人综合激情网| 中文字幕在线免费不卡| 99精品视频在线观看免费| 国产精品沙发午睡系列990531| 国产精品一区二区三区乱码| 久久久夜色精品亚洲| 国产高清不卡二三区| 欧美国产精品专区| 成人激情小说乱人伦| 国产精品久久久久久久久久久免费看| 国产成人精品免费网站| 国产精品久久久久久久久图文区| 91女厕偷拍女厕偷拍高清| 亚洲美女区一区| 777a∨成人精品桃花网| 极品销魂美女一区二区三区| 2021中文字幕一区亚洲| 成人永久免费视频| 亚洲另类春色校园小说| 精品视频一区 二区 三区| 午夜免费欧美电影| 久久精品日韩一区二区三区| 成人黄色电影在线| 亚洲高清不卡在线| 欧美不卡123| 97se亚洲国产综合自在线观| 日日摸夜夜添夜夜添精品视频| 欧美tickle裸体挠脚心vk| 不卡的电视剧免费网站有什么| 曰韩精品一区二区| 精品捆绑美女sm三区| 不卡的av电影在线观看| 日本女人一区二区三区| 久久久久久久电影| 欧美日韩一区二区三区视频| 国产在线视频一区二区三区| 亚洲国产成人高清精品| 日本一区二区高清| 中文字幕一区二区5566日韩| 成人动漫精品一区二区| 亚洲成av人片一区二区| 国产三区在线成人av| 精品视频资源站| 国产成人精品一区二区三区四区| 一区二区三区精密机械公司| 欧美videos大乳护士334| 91亚洲大成网污www| 精品影视av免费| 伊人开心综合网| 久久色在线视频| 欧美色电影在线| 成人福利视频网站| 奇米色一区二区三区四区| 国产精品久久久久影院| 精品嫩草影院久久| 日韩一区二区高清| 欧美在线观看一二区| 国产91对白在线观看九色| 日韩亚洲欧美中文三级| 精品国产乱码久久久久久蜜臀 | 欧美午夜电影网| 国产精品一区二区在线观看不卡| 香蕉久久夜色精品国产使用方法| 中日韩av电影| 久久夜色精品国产欧美乱极品| 777午夜精品免费视频| 色中色一区二区| 91美女片黄在线观看| 成人免费视频一区二区| 国产精品一二三四| 另类专区欧美蜜桃臀第一页| 天堂一区二区在线免费观看| 一级日本不卡的影视| 亚洲美腿欧美偷拍| 亚洲欧美另类久久久精品| 国产精品色呦呦| 国产精品少妇自拍| 国产精品不卡在线观看| 国产精品无码永久免费888| 久久精品网站免费观看| 久久亚洲一级片| 亚洲精品福利视频网站| 在线免费精品视频| 日韩色在线观看| 9l国产精品久久久久麻豆| 国产福利一区二区三区视频 | 欧美日韩中文一区| 色一情一乱一乱一91av| 色婷婷精品久久二区二区蜜臂av| aaa欧美日韩| 91色综合久久久久婷婷| 91在线视频官网| 色域天天综合网| 精品视频在线看| 91精品国产91久久综合桃花| 欧美一级欧美三级| 欧美大度的电影原声| 久久人人爽爽爽人久久久| 国产视频911| 中文字幕中文字幕一区| 一区二区三区日本| 亚洲.国产.中文慕字在线| 琪琪一区二区三区| 国产成人综合网站| 欧美成人综合网站| 国产精品久久久久久久久图文区 | 成人精品高清在线| 91麻豆视频网站| 欧美日韩1区2区| 精品黑人一区二区三区久久| 久久久不卡网国产精品一区| 中文字幕日本乱码精品影院| 亚洲国产人成综合网站| 欧美专区在线观看一区| 欧美tickling网站挠脚心| 国产精品系列在线| 亚洲一卡二卡三卡四卡五卡| 蜜桃一区二区三区在线观看| 成人一级视频在线观看| 欧美在线播放高清精品| 欧美成人三级在线| 18成人在线视频| 久久国产日韩欧美精品| 91在线播放网址| 欧美sm极限捆绑bd| 亚洲一区二区黄色| 国产精品中文欧美| 欧美日韩国产首页在线观看| 国产午夜精品一区二区三区四区| 中文字幕一区二区三区四区| 91久久国产综合久久| 成人av在线播放网站| 欧美日韩激情一区二区三区| 成人精品国产免费网站| 欧美精品一二三区| 欧美国产日韩亚洲一区| 免费av成人在线| 欧美在线综合视频| 久久久久国色av免费看影院| 丝袜美腿亚洲综合| 91色综合久久久久婷婷| 久久精品无码一区二区三区| 日韩精品五月天| 91成人国产精品| 国产精品美女久久久久高潮| 蜜桃视频在线观看一区二区| 91成人免费电影| 亚洲天堂免费看| 成人毛片在线观看| 国产三级欧美三级日产三级99| 免费一级欧美片在线观看| 欧美亚洲一区三区| 亚洲免费视频中文字幕| 成人激情免费视频| 久久精品夜色噜噜亚洲a∨ | 国产三级一区二区| 精品美女一区二区三区| 国产在线精品一区二区不卡了| 91精品国产综合久久婷婷香蕉| 中文字幕在线不卡一区二区三区| 久久国产综合精品| 欧美精品在线一区二区| 亚洲综合色区另类av| 91免费视频大全| 亚洲欧洲一区二区在线播放| 国产激情一区二区三区四区 | 国产精品久久看| 成人午夜在线视频| 国产精品久久一卡二卡| 99精品视频在线播放观看| 亚洲欧洲制服丝袜| 色偷偷成人一区二区三区91| 亚洲免费观看高清完整版在线观看熊|