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

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

?? mfrc500uc.c

?? This library modul is written for a C166 microcontroller derivative. rfid 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一区二区三区免费野_久草精品视频
成人美女在线视频| 久久婷婷一区二区三区| 日韩精品中文字幕在线一区| 国产日韩欧美综合一区| 男男视频亚洲欧美| 欧美影院精品一区| 国产精品久久久久天堂| av电影天堂一区二区在线| 欧美一区二区日韩一区二区| 自拍偷拍亚洲综合| 精品一区二区三区免费毛片爱 | 99久久久久免费精品国产| 91精品国产综合久久精品| 亚洲自拍偷拍麻豆| 成人福利视频网站| 久久欧美中文字幕| 蜜臀av性久久久久av蜜臀妖精| 91福利国产精品| 亚洲视频1区2区| 不卡的av电影| 中文字幕一区二区三区在线不卡 | 亚洲一区成人在线| 91麻豆国产精品久久| 亚洲国产精品ⅴa在线观看| 国产精品99久久久久久有的能看 | 91久久人澡人人添人人爽欧美| 日本一区二区三区四区在线视频| 国内国产精品久久| 亚洲精品一区二区三区精华液| 男男gaygay亚洲| 日韩欧美精品在线| 久久精品国内一区二区三区| 91精品国产乱| 久久疯狂做爰流白浆xx| 日韩精品中文字幕一区 | 26uuu国产在线精品一区二区| 青青草国产成人99久久| 91精品国产欧美日韩| 理论片日本一区| 久久综合久久综合九色| 国产一区二区免费看| 国产亚洲精久久久久久| 成人h精品动漫一区二区三区| 日本一区二区成人| 一本色道亚洲精品aⅴ| 一二三四社区欧美黄| 欧美精品色综合| 人禽交欧美网站| 久久久久9999亚洲精品| 99综合电影在线视频| 一区二区三区日韩精品| 欧美日韩国产一区二区三区地区| 日日夜夜精品视频免费| 精品国产一区a| 成人av手机在线观看| 亚洲一区二区三区中文字幕在线| 欧美丰满美乳xxx高潮www| 美女视频免费一区| 欧美国产日本视频| 欧美中文字幕不卡| 极品少妇xxxx精品少妇偷拍| 国产精品欧美极品| 欧美亚洲国产一区二区三区va| 日韩福利电影在线| 久久精品99久久久| 久久久精品人体av艺术| 色噜噜偷拍精品综合在线| 蜜桃精品视频在线| 亚洲免费在线观看视频| 91精品国模一区二区三区| 成人高清视频免费观看| 天堂成人国产精品一区| 欧美极品xxx| 欧美日韩国产综合一区二区| 国产999精品久久久久久| 一级中文字幕一区二区| 2021国产精品久久精品| 在线日韩av片| 风流少妇一区二区| 青草av.久久免费一区| 亚洲欧洲在线观看av| 日韩精品一区在线| 欧美色偷偷大香| 99久久免费国产| 国产福利91精品一区| 五月天欧美精品| 综合激情网...| 国产日韩欧美精品在线| 欧美一区二区三区免费大片 | 亚洲色图另类专区| 久久九九国产精品| 欧美成人a∨高清免费观看| 91影视在线播放| av电影天堂一区二区在线| 国产综合色精品一区二区三区| 亚洲午夜日本在线观看| 亚洲精选视频免费看| 中国av一区二区三区| 久久综合五月天婷婷伊人| 7777精品久久久大香线蕉| 在线观看av一区二区| 91在线观看地址| 国产v综合v亚洲欧| 国产精品一区二区三区四区| 奇米精品一区二区三区在线观看一 | 激情综合网最新| 奇米亚洲午夜久久精品| 日韩和欧美的一区| 午夜激情综合网| 亚洲一区二区三区不卡国产欧美| 亚洲人吸女人奶水| 亚洲欧美一区二区三区久本道91| 欧美国产97人人爽人人喊| 欧美激情在线免费观看| 国产欧美精品一区| 欧美韩日一区二区三区| 国产精品视频麻豆| 国产精品久久久久一区二区三区共 | 日韩精品一区二区三区在线播放| 欧美性色综合网| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 97se亚洲国产综合自在线| 国产**成人网毛片九色| 成人三级在线视频| 99久久国产综合色|国产精品| 国产成人精品免费网站| 成人影视亚洲图片在线| 97久久精品人人澡人人爽| 欧美在线视频不卡| 91精品婷婷国产综合久久性色| 欧美一级片免费看| 久久久不卡影院| 国产精品国产三级国产普通话99 | 亚洲女厕所小便bbb| 亚洲第一会所有码转帖| 麻豆高清免费国产一区| 韩国成人精品a∨在线观看| 不卡的电视剧免费网站有什么| 在线欧美日韩国产| 欧美α欧美αv大片| 欧美激情综合五月色丁香| 亚洲精品亚洲人成人网 | 欧美一区二区免费| 久久久国产精华| 亚洲一区日韩精品中文字幕| 香蕉av福利精品导航| 国产麻豆欧美日韩一区| 一本色道久久综合狠狠躁的推荐 | 在线观看网站黄不卡| 日韩一级高清毛片| 中文乱码免费一区二区| 亚洲一区电影777| 国产一区激情在线| 91福利国产成人精品照片| 欧美精品一区二| 一区二区三区日韩欧美精品| 久久爱另类一区二区小说| av在线一区二区| 日韩欧美国产不卡| 一区二区三区四区不卡视频| 国内精品在线播放| 欧美日韩一级黄| 国产精品不卡一区| 久久精品国产精品青草| 欧美在线视频你懂得| 亚洲国产高清在线| 久久91精品国产91久久小草| 91麻豆.com| 欧美极品xxx| 精品午夜一区二区三区在线观看| 91一区在线观看| 欧美激情一区二区三区蜜桃视频| 午夜成人在线视频| 欧美亚洲精品一区| 亚洲色图一区二区| 国产a久久麻豆| 日韩精品一区二区三区老鸭窝| 亚洲高清视频在线| 色综合久久九月婷婷色综合| 日本一区二区三级电影在线观看 | 日韩精品亚洲专区| 色综合久久综合网欧美综合网| 久久久.com| 国产一区二区不卡| 亚洲精品一区二区三区福利 | 95精品视频在线| 精品国产凹凸成av人导航| 日韩福利电影在线观看| 欧美日韩一区 二区 三区 久久精品| 亚洲欧洲综合另类在线 | 国产一区二区视频在线| 欧美大片在线观看一区二区| 午夜不卡av免费| 欧美日韩美女一区二区| 午夜精品视频在线观看| 欧美理论片在线| 日韩电影一二三区| 欧美一区二区精美| 久久成人18免费观看| 26uuu久久天堂性欧美|