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

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

?? m500auc.c

?? MRF500源碼,讀寫射頻卡!快點下!!絕對精彩
?? C
?? 第 1 頁 / 共 5 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//    Copyright (c), Philips Semiconductors Gratkorn
//
//                  (C)PHILIPS Electronics N.V.2000
//       All rights are reserved. Reproduction in whole or in part is 
//      prohibited without the written consent of the copyright owner.
//  Philips reserves the right to make changes without notice at any time.
// Philips makes no warranty, expressed, implied or statutory, including but
// not limited to any implied warranty of merchantibility or fitness for any
//particular purpose, or that the use will not infringe any third party patent,
// copyright or trademark. Philips must not be liable for any loss or damage
//                          arising from its use.
///////////////////////////////////////////////////////////////////////////////
#define DLL_EXPORT      // library source module definition
#include <p89c51rx.h>
#include <Mfreg500.h>
#include <M500A.h>
#include <RdIo.h>

#include <string.h>
#include <stdio.h>
#include <main.h>

////////////////////////////////////////////////////////////////////////////////
//                M O D U L E   D E F I N I T I O N
////////////////////////////////////////////////////////////////////////////////
// COMMENT: This library module is modified from the original source code for a
//	    microcontroller C164 CI, to suit the general purpose 8051 mcu.
//          The source can be ported to other platforms very easily. 
//          The communication channel to the RC500 reader IC is assumed to be 
//          unknown. All data is written with the generic IO functions 
//          of the module ReaderIO.h. In our case the reader module is 
//          connected via memory mapped io at base address 0x7f00.
//          The interrupt pin of the reader IC is assumed to be connected to 
//          the fast external interrupt pin INT0# (active low) and the reset
//          pin of the reader IC should be connected to a dedicated port pin
//          (Port3: Pin: 3).
//          In this configuration, a reset of the reader module is independend
//          from the reset of the microcontroller.
//          In order to generate communication timeouts, 
//          general purpose timer 2 of the microcontroller is used. This 
//          timer need not to be initialised in advance. Before every usage 
//          the timer is completely initialised in each function. 
//          Non of the timers is essential for the functionality of the reader
//          module, but are helpful furing software development. All protocoll 
//          relevant timing constraints are generated
//          by the internal timer of the reader module.
//
//          Some explanations to the programming method of this library.
//          There are three kind of functions coded in this module.
//            a) internal functions, which have no prototypes in a header
//               file and are not intended to be used outside of this file
//            b) commands, which are intended for the reader module itself
//            c) commands, which are intended for any tag in the rf field.
//               These commands are send to the reader and the reader module
//               transmitts the data to the rf interface.
//          Commands for the reader and for the tag have the appropriate 
//          prefix (PCD for proximity coupled device or reader module
//                  PICC for proximity integrated circuit card or tag)
//          and their protypes are defined in the header file.
//          Each command for a PICC consists of a PCD command. Therefore
//          the function M500PcdCmd is very important for the understanding
//          of the communication.
//
//          The basic functionality is provided by the interrupt service
//          routine (ISR), which closely works together with the function
//          M500PcdCmd. All kinds of interrupts are serviced by the 
//          same ISR. 


// inline structure in order to reset the communication channel between 
// function and ISR
#define ResetInfo(info)    \
            info.cmd            = 0; \
            info.status         = MI_OK;\
            info.irqSource      = 0;   \
            info.nBytesSent     = 0;   \
            info.nBytesToSend   = 0;  \
            info.nBytesReceived = 0;  \
            info.nBitsReceived  = 0;   \
            info.collPos        = 0;

// struct definition for a communication channel between function and ISR
typedef struct 
         {
            unsigned char  cmd;           //!< command code 
            char           status;        // communication status
            unsigned char  nBytesSent;    // how many bytes already sent
            unsigned char  nBytesToSend;  // how many bytes to send
            unsigned char  nBytesReceived;// how many bytes received
            unsigned short nBitsReceived; // how many bits received
            unsigned char  irqSource;     // which interrupts have occured
            unsigned char  collPos;       // at which position occured a
                                          // collision
         } MfCmdInfo;

// modul variables 
extern	 unsigned char xdata *GpBase;

static   unsigned char idata MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length

static   unsigned char xdata MKeys[16][12]; // storage for authentication keys
                                      // in order to provide a calling 
                                      // compatible interface to old libraries
                             // Other reader modules keep several sets
                             // of keys in an E2PROM. In this case,
                             // these keys are stored in the uC and
                             // transfered to the reader module 
                             // before authentication

// Infomation concerning data processing
         // send buffer for general use
static   volatile unsigned char xdata MSndBuffer[SND_BUF_LEN];
         // receive buffer for general use
static   volatile unsigned char xdata MRcvBuffer[RCV_BUF_LEN];
         // info struct for general use
static   volatile MfCmdInfo     MInfo;                  

// Interrupt service routine
// Variable in order to exchange data between function and ISR
static   volatile MfCmdInfo     *MpIsrInfo = 0; 
        // ISR send buffer
static   volatile unsigned char *MpIsrOut  = 0; 
         // ISR receive buffer
static   volatile unsigned char *MpIsrIn   = 0;     

// storage of the last selected serial number including check byte.
//For multi level serial numbers, only the first 4 bytes are stored.
unsigned char MLastSelectedSnr[5];

// Timer 2
bit		T2IR	 	= 0;	// Timer2 timeout flag
unsigned int 	CountDown	= 0;	// Timeout counter with 50us resolution

sbit    RC500RST        	= P2^1;
sbit    LED	        	= P3^4;

///////////////////////////////////////////////////////////////////////////////
//             Prototypes for local functions 
///////////////////////////////////////////////////////////////////////////////

void start_timeout(unsigned int _50us);
void stop_timeout(void);

// _____________________________________________________________________________
//
//  FUNCTION: M500PcdSetTmo
//        IN: tmoLength   1  ... 1.0 ms timeout periode
//                        2  ... 1.5 ms timeout periode
//                        3  ... 6.0 ms timeout periode
//        		  4  ... 9.6 ms timeout period
//                        5  ... 38.5 ms timeout period
//                        6  ... 154 ms timeout period
//                        7  ... 616.2 ms timeout period
//       OUT: -
//    RETURN: 
//   COMMENT: Set timeout length of the reader internal timer.
//               
void M500PcdSetTmo(unsigned char tmoLength);

// _____________________________________________________________________________
//
//  FUNCTION: M500PcdCmd
//        IN: cmd  PCD_IDLE
//                   PCD_WRITEE2
//                   PCD_READE2
//                   PCD_LOADCONFIG
//                   PCD_LOADKEYE2
//                   PCD_AUTHENT1
//                   PCD_CALCCRC
//                   PCD_AUTHENT2
//                   PCD_RECEIVE
//                   PCD_LOADKEY
//                   PCD_TRANSMIT
//                   PCD_TRANSCEIVE
//                   PCD_RESETPHASE
//                   for a detailed description of the parameter values, please
//                   have a look on the header file of the reader register
//                   definitions.
//            send      byte stream of variable length, which should be send to
//                      the PICC, the length of stream has to be specified
//                      in the info - structure
//       OUT: rcv    byte stream of variable length, which was received 
//                      from the PICC or PCD
//            info      communication and status structure
//    RETURN: 
//   COMMENT: 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. Immediate after 
//            enabling the interrupts, the LoAlert interrupt is activated.
//            The ISR writes the data to the FIFO. This function is not involved
//            in writing or fetching data from FIFO, all work is done by the 
//            ISR.After command completion, the error status is evaluated and 
//            returned to the calling function.
//
char M500PcdCmd(unsigned char cmd,
                volatile unsigned char* send, 
                volatile unsigned char* rcv,
                volatile MfCmdInfo *info);

// _____________________________________________________________________________
//
//  FUNCTION: SetBitMask
//        IN: reg      register address
//            mask     bit mask to set
//       OUT: -
//    RETURN: 
//   COMMENT:  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.
//
char SetBitMask(unsigned char reg,unsigned char mask);

// _____________________________________________________________________________
//
//  FUNCTION: ClearBitMask
//        IN: reg      register address
//            mask     bit mask to clear
//       OUT: -
//    RETURN: 
//   COMMENT:  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.
//
char ClearBitMask(unsigned char reg,unsigned char mask);

// _____________________________________________________________________________
//
//  FUNCTION: FlushFIFO
//        IN: -
//       OUT: -
//    RETURN: 
//   COMMENT: All remaining date in the FIFO of the reader module is 
//            erased by this function. Before wrinting new data or
//            starting a new command, all remaining data from former 
//            commands should be deleted. Please note, that in 
//            normal operation, never data should be left, that means
//            that a call to this function should not be necessary.
//
void FlushFIFO(void);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccAuthState
//        IN: auth_mode
//            snr
//            sector
//       OUT: -
//    RETURN: 
//   COMMENT: 
//
char M500PiccAuthState(unsigned char auth_mode,// PICC_AUTHENT1A, PICC_AUTHENT1B
                       unsigned char *snr,    // 4 byte serial number
                       unsigned char sector); // 0 <= sector <= 15  
                                            // sector address for authentication

//////////////////////////////////////////////////////////////////////
//           E X C H A N G E   B Y T E   S T R E A M
///////////////////////////////////////////////////////////////////////
char ExchangeByteStream(unsigned char Cmd,
                        unsigned char *send_data,
                        unsigned char send_bytelen,
                        unsigned char *rec_data,  
                        unsigned char *rec_bytelen);

///////////////////////////////////////////////////////////////////////////////
//                  Interrupt Handler RC500
///////////////////////////////////////////////////////////////////////////////
void RC500ISR (void) interrupt 0 using 1    //Ext0 interrupt
{
   static unsigned char idata irqBits;
   static unsigned char idata irqMask;            
   static unsigned char idata nbytes;
   static unsigned char idata cnt;

   IE0 = 0; 	// Clear interrupt request flag

   if (MpIsrInfo && MpIsrOut && MpIsrIn)  // transfer pointers have to be set
                                          // correctly
   {
      while( ReadRawIO(RegPrimaryStatus) & 0x08) // loop while IRQ pending
                                                // Attention: IRQ bit is 
                                                // inverted when used with
                                                // low activ IRQ
      {
         irqMask = ReadRawIO(RegInterruptEn); // read enabled interrupts
         // read pending interrupts
         irqBits = ReadRawIO(RegInterruptRq) & irqMask;
         MpIsrInfo->irqSource |= irqBits; // save pending interrupts
         //************ LoAlertIRQ ******************
         if (irqBits & 0x01)    // LoAlert
         {  
            nbytes = MFIFOLength - ReadRawIO(RegFIFOLength);
            // less bytes to send, than space in FIFO
            if ((MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent) <= nbytes)
            {
               nbytes = MpIsrInfo->nBytesToSend - MpIsrInfo->nBytesSent;
               WriteRawIO(RegInterruptEn,0x01); // disable LoAlert IRQ
            }
            // write remaining data to the FIFO
            for ( cnt = 0;cnt < nbytes;cnt++)
            {
               WriteRawIO(RegFIFOData,MpIsrOut[MpIsrInfo->nBytesSent]);
               MpIsrInfo->nBytesSent++;
            }
            WriteRawIO(RegInterruptRq,0x01);  // reset IRQ bit
         }
      
         //************* TxIRQ Handling **************
         if (irqBits & 0x10)       // TxIRQ
         {
            WriteRawIO(RegInterruptRq,0x10);    // reset IRQ bit 
            WriteRawIO(RegInterruptEn,0x82);    // enable HiAlert Irq for
                                           // response
            if (MpIsrInfo->cmd == PICC_ANTICOLL1) 	// if cmd is anticollision
	    {                                           // switch off parity generation
               WriteRawIO(RegChannelRedundancy,0x02);	// RXCRC and TXCRC disable, parity disable
	    }	
         }

         //************* HiAlertIRQ or RxIRQ Handling ******************
         if (irqBits & 0x0E) // HiAlert, Idle or RxIRQ
         {
            // read some bytes ( length of FIFO queue)              
            // into the receive buffer
            nbytes = ReadRawIO(RegFIFOLength);
            // read date from the FIFO and store them in the receive buffer
            for ( cnt = 0; cnt < nbytes; cnt++)               
            {
               MpIsrIn[MpIsrInfo->nBytesReceived] = ReadRawIO(RegFIFOData);
               MpIsrInfo->nBytesReceived++;
            }
            WriteRawIO(RegInterruptRq,0x0A & irqBits);  
                                       // reset IRQ bit - idle irq will
                                       // be deleted in a seperate section
         }   
   
         //************** IdleIRQ Handling ***********
         if (irqBits & 0x04)     // Idle IRQ
         {
            WriteRawIO(RegInterruptEn,0x20); // disable Timer IRQ
            WriteRawIO(RegInterruptRq,0x20); // disable Timer IRQ request
            irqBits &= ~0x20;   // clear Timer IRQ in local var
            MpIsrInfo->irqSource &= ~0x20; // clear Timer IRQ in info var
                                        // when idle received, then cancel
                                        // timeout
            WriteRawIO(RegInterruptRq,0x04);  // reset IRQ bit 
            // status should still be MI_OK
            // no error - only used for wake up
         }
       
         //************* TimerIRQ Handling ***********
         if (irqBits & 0x20)       // timer IRQ
         {
            WriteRawIO(RegInterruptRq,0x20); // reset IRQ bit 
            MpIsrInfo->status = MI_NOTAGERR; // timeout error

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看国产一区二区| 国产黑丝在线一区二区三区| 99麻豆久久久国产精品免费| 欧美国产精品中文字幕| 国产成人精品影院| 亚洲四区在线观看| 91视频免费播放| 一区二区三区日韩欧美精品| 欧美午夜精品免费| 婷婷国产在线综合| 精品国产免费一区二区三区香蕉| 久久97超碰色| 欧美激情一区二区三区四区 | 欧美三级中文字| 日韩美女啊v在线免费观看| 波多野结衣中文字幕一区二区三区| 国产精品一二三四| 色域天天综合网| 亚洲精品日产精品乱码不卡| 99视频超级精品| 欧美日本一区二区| 久久精品国产在热久久| 91久久精品午夜一区二区| 日日摸夜夜添夜夜添国产精品| 国产精品视频观看| 色综合久久综合中文综合网| 国内精品国产三级国产a久久| 日本不卡一区二区| 久久久久久亚洲综合| 国产欧美日韩视频一区二区| 性欧美疯狂xxxxbbbb| 日韩不卡在线观看日韩不卡视频| 一区二区三区加勒比av| 国产乱子伦视频一区二区三区 | 免费成人在线观看| 欧美高清性hdvideosex| 亚洲成人一区在线| 在线播放国产精品二区一二区四区| 国产一区视频导航| 午夜电影一区二区| 欧美亚洲综合在线| 亚洲成av人片一区二区梦乃| 在线观看国产日韩| 日韩在线播放一区二区| 国产盗摄一区二区| 91超碰这里只有精品国产| 国产一区二区精品久久91| 九九**精品视频免费播放| 亚洲成a人片在线观看中文| 亚洲一区在线观看视频| 丁香一区二区三区| 青青草国产精品亚洲专区无| 亚洲人成在线播放网站岛国| 久久―日本道色综合久久| 欧美日韩小视频| 国产乱码精品一区二区三| 久久久一区二区三区捆绑**| 日本高清成人免费播放| 成人蜜臀av电影| 久久国产精品一区二区| 亚洲国产你懂的| 亚洲久草在线视频| 国产精品欧美久久久久无广告| 欧美成人伊人久久综合网| 7777精品伊人久久久大香线蕉| 韩日av一区二区| 国产91丝袜在线播放九色| 亚洲国产日韩av| 99热精品一区二区| 亚洲一区二区三区免费视频| 久久精品亚洲精品国产欧美| 粉嫩欧美一区二区三区高清影视 | 一区二区三区.www| 精品不卡在线视频| 欧美中文字幕一区二区三区| 成人免费看黄yyy456| 捆绑调教一区二区三区| 丝袜亚洲另类欧美综合| 亚洲综合一二三区| 亚洲一二三专区| 一区二区不卡在线播放| 亚洲天堂中文字幕| 一区二区三区产品免费精品久久75 | 99久久精品国产麻豆演员表| 丰满少妇久久久久久久| 不卡影院免费观看| 色欧美日韩亚洲| 欧美日韩精品一区二区天天拍小说| 欧美日韩一区二区在线观看视频| 欧美影视一区在线| 亚洲综合免费观看高清完整版在线| 亚洲一区二区三区影院| 最新日韩在线视频| 亚洲日穴在线视频| 中文字幕一区视频| 国产一区二区在线电影| 国产99久久久国产精品潘金| 欧美日韩在线观看一区二区| 中文字幕免费观看一区| 一本久久综合亚洲鲁鲁五月天| 亚洲欧美电影院| 亚洲欧美在线观看| 一区二区三区高清| 亚洲人妖av一区二区| 亚洲欧美日韩综合aⅴ视频| 91精品国产欧美一区二区成人| 欧美日韩国产综合一区二区三区| 国产精品免费人成网站| 亚洲精品一区二区精华| 久久婷婷一区二区三区| 久久久久久久综合日本| 精品视频在线看| 欧洲av在线精品| 久久电影网站中文字幕| 91精彩视频在线观看| 国产精品欧美极品| 中文av一区特黄| 国产麻豆视频一区| 精品国产免费人成在线观看| 懂色av中文一区二区三区| 久久婷婷一区二区三区| 婷婷成人激情在线网| 国产91丝袜在线观看| 樱花草国产18久久久久| 欧美高清一级片在线观看| 国产精品毛片a∨一区二区三区| 蜜臀av性久久久久蜜臀aⅴ | 欧美妇女性影城| 一区二区三区成人在线视频| av网站一区二区三区| 91免费视频网址| 国产精品不卡在线观看| 福利视频网站一区二区三区| 久久综合色播五月| 极品少妇一区二区| 久久在线观看免费| 久久99精品国产麻豆婷婷| 日韩精品资源二区在线| 经典三级视频一区| 26uuu久久综合| 国产一区二区美女| 国产精品色婷婷久久58| 成人一二三区视频| 中文字幕欧美一| 99re热这里只有精品免费视频| 亚洲欧美在线视频观看| 欧美在线高清视频| 无码av免费一区二区三区试看| 欧美精品aⅴ在线视频| 奇米一区二区三区| 久久午夜电影网| 成人免费av资源| 亚洲女同ⅹxx女同tv| 成人黄色免费短视频| 国产精品高潮久久久久无| 91亚洲大成网污www| 一区二区三区精密机械公司| 7777精品伊人久久久大香线蕉经典版下载 | 欧美在线免费观看亚洲| 午夜欧美电影在线观看| 欧美一级免费大片| 国产精品99久久久| 国产精品乱码人人做人人爱 | 欧美日本国产视频| 美女在线观看视频一区二区| www国产成人免费观看视频 深夜成人网| 国产麻豆视频一区二区| 亚洲男人都懂的| 欧美一级黄色大片| 粉嫩欧美一区二区三区高清影视| 亚洲精品久久久久久国产精华液| 欧美日韩国产电影| 国产一区二区按摩在线观看| 中文字幕一区二区在线观看| 精品视频一区三区九区| 国产精品一区免费在线观看| 亚洲精品视频在线观看免费 | 欧美午夜不卡视频| 精品亚洲porn| 综合欧美亚洲日本| 日韩一区二区三区精品视频| 成人小视频免费在线观看| 亚洲国产精品久久一线不卡| 26uuu色噜噜精品一区二区| 91黄色免费看| 国产在线不卡一卡二卡三卡四卡| 一区二区三区资源| 日韩视频免费观看高清在线视频| 成人午夜激情影院| 日韩av一区二区三区四区| 国产精品嫩草影院com| 欧美一级高清片在线观看| 99精品久久只有精品| 久久不见久久见中文字幕免费| 亚洲欧美日韩人成在线播放| 欧美日韩一区二区三区不卡| 午夜精品一区二区三区免费视频| 精品黑人一区二区三区久久 | 国产亚洲欧美激情| 欧美精品v日韩精品v韩国精品v|