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

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

?? mfrc500uc.c

?? 是關于KeilC下串口Baudrat設定的。
?? 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一区二区三区免费野_久草精品视频
亚洲视频一区在线| 一区二区免费在线| 亚洲一区精品在线| 精品一区二区三区免费观看| 成人黄色小视频| 91精品综合久久久久久| 国产日韩欧美不卡在线| 亚洲成av人**亚洲成av**| 岛国av在线一区| 欧美草草影院在线视频| 一区二区三区中文在线观看| 欧美日韩在线一区二区| 欧美国产激情一区二区三区蜜月| 秋霞影院一区二区| 91原创在线视频| 国产亚洲综合色| 毛片一区二区三区| 91精品国产综合久久久久久| 麻豆成人免费电影| 欧美国产精品中文字幕| 色综合天天综合网国产成人综合天 | 欧美一级视频精品观看| 亚洲欧美另类久久久精品2019| 国产不卡在线一区| 亚洲精品一区二区在线观看| 天天综合日日夜夜精品| 欧美撒尿777hd撒尿| 免费看欧美美女黄的网站| 国产欧美一区二区三区在线老狼| 色综合天天综合网国产成人综合天| 日本视频在线一区| 欧美日韩一区二区电影| 久久99精品久久久| 亚洲人精品一区| 日韩一区二区三区电影| 麻豆国产欧美日韩综合精品二区| 中文字幕av不卡| 欧美三级日本三级少妇99| 国产一区二区三区精品视频| 日韩欧美在线影院| aaa亚洲精品一二三区| 国产精品久久久久久久岛一牛影视| 狠狠色丁香婷综合久久| 久久精品视频免费观看| 色综合 综合色| 亚洲最大成人综合| 久久亚洲捆绑美女| 成人黄色电影在线| 日韩国产成人精品| 自拍偷拍欧美激情| 精品国产一区二区在线观看| 一本到高清视频免费精品| 精品一区二区精品| 亚洲福利视频一区二区| 9191久久久久久久久久久| 国产精品一区二区免费不卡| 国产精品久久三| 欧美精品成人一区二区三区四区| 偷窥国产亚洲免费视频| 国产日韩精品一区二区三区| 6080日韩午夜伦伦午夜伦| 不卡的av电影| 久久精品免费观看| 国产三级一区二区| 欧美老肥妇做.爰bbww| 99免费精品在线观看| 久久99国产精品免费| 亚洲国产成人精品视频| 国产精品久久久久天堂| 精品国产一区二区三区不卡| 欧美日韩综合在线免费观看| 国产白丝精品91爽爽久久| 喷水一区二区三区| 亚洲一区二区三区激情| 中文字幕中文字幕一区二区| 欧美成人精品1314www| 欧美日韩和欧美的一区二区| 精品一二三四在线| 天堂蜜桃一区二区三区 | 日韩欧美高清一区| 成人午夜在线视频| 精品亚洲aⅴ乱码一区二区三区| 一区二区三区四区国产精品| 国产精品久线在线观看| 国产亚洲自拍一区| 26uuu久久综合| 精品日韩成人av| 91精品在线观看入口| 欧美视频精品在线| 激情综合网av| 免费成人美女在线观看.| 三级影片在线观看欧美日韩一区二区 | 九九热在线视频观看这里只有精品| 亚洲国产精品久久久久秋霞影院| 亚洲精品老司机| 久久综合色之久久综合| 日韩午夜三级在线| 91精品国产欧美一区二区18 | 久久久久久久免费视频了| 色偷偷一区二区三区| 国产91精品在线观看| 国产激情一区二区三区四区 | eeuss鲁片一区二区三区在线看| 精品一区二区免费视频| 免费一级片91| 蜜乳av一区二区| 久久99久国产精品黄毛片色诱| 日本不卡的三区四区五区| 天天综合日日夜夜精品| 日本最新不卡在线| 日本不卡在线视频| 老司机免费视频一区二区| 欧美96一区二区免费视频| 美女mm1313爽爽久久久蜜臀| 激情五月婷婷综合网| 国内不卡的二区三区中文字幕| 韩国av一区二区| 国产精品自拍网站| 成人综合激情网| 99视频热这里只有精品免费| 91蜜桃视频在线| 欧美性生交片4| 337p亚洲精品色噜噜狠狠| 日韩免费看网站| 久久久亚洲精品石原莉奈| 国产婷婷色一区二区三区在线| 中文字幕av资源一区| 1024成人网| 亚洲精品一区二区三区在线观看 | www久久精品| 久久蜜桃av一区精品变态类天堂| 国产三级精品视频| 日韩毛片高清在线播放| 亚洲制服丝袜av| 青青草国产精品亚洲专区无| 久久99精品久久久久| 国产成人a级片| 色综合久久久久久久久久久| 欧美日韩精品三区| 精品国产一区二区在线观看| 国产色爱av资源综合区| 中文字幕亚洲欧美在线不卡| 亚洲综合视频在线| 男人的天堂久久精品| 成人黄色大片在线观看| 欧美午夜在线观看| 日韩欧美在线123| 中文字幕欧美区| 夜夜爽夜夜爽精品视频| 蜜桃传媒麻豆第一区在线观看| 国产精品一区二区久久不卡| 99久久久国产精品| 粉嫩蜜臀av国产精品网站| 一本一道久久a久久精品综合蜜臀| 欧美日韩大陆一区二区| 久久精品一二三| 亚洲激情自拍偷拍| 久久不见久久见中文字幕免费| 成人免费视频国产在线观看| 欧美在线啊v一区| 欧美视频日韩视频在线观看| 欧美va亚洲va| 亚洲精品国产a| 久久er99热精品一区二区| 99久久伊人久久99| 91麻豆精品国产91久久久使用方法 | 天堂va蜜桃一区二区三区 | 国产黑丝在线一区二区三区| 91国偷自产一区二区开放时间 | 久久精品视频免费观看| 亚洲一区免费视频| 国产一区二区三区在线看麻豆| 91免费版pro下载短视频| 在线不卡a资源高清| 中文字幕精品一区二区精品绿巨人 | 国产成人日日夜夜| 色综合天天综合网天天狠天天| 日韩欧美一区二区免费| 亚洲欧美在线高清| 美国av一区二区| 91高清视频在线| 久久婷婷成人综合色| 亚洲成人三级小说| 成人精品视频一区| 日韩欧美卡一卡二| 一区二区在线观看免费| 国产精品中文欧美| 欧美日韩国产不卡| 最近日韩中文字幕| 国产一区久久久| 欧美精品电影在线播放| 亚洲欧美二区三区| 国产伦精品一区二区三区视频青涩| 在线观看欧美日本| 中文字幕不卡在线| 麻豆一区二区99久久久久| 91视频在线观看| 久久精品水蜜桃av综合天堂| 日韩av不卡一区二区| 91麻豆成人久久精品二区三区|