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

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

?? mfrc500uc.c

?? This library modul is written for a C166 microcontroller derivative. rfid mifare
?? C
?? 第 1 頁 / 共 3 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//    Copyright (c), Philips Semiconductors Gratkorn
//
//                  (C)PHILIPS Electronics N.V.2000
//                     All rights are reserved. 
//  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.
///////////////////////////////////////////////////////////////////////////////
#include <string.h>
#include <stdio.h>

#include <RICReg.h>
#include <MfRc500.h>
#include <PICCCmdConst.h>
#include <MfErrNo.h>

/* 
* Projekt: MF EV X00 Firmware
*
* $Workfile:: MfRc500uC.c                                               $ 
* $Modtime:: 24.06.02 15:41                                             $ 
* $Author:: Hb                                                          $
* $Revision:: 8                                                         $
*
* 
* This library modul is written for a C166 microcontroller derivative.
* The source can be ported to other platforms very easily. 
* In our case the reader module is 
* connected via memory mapped io at base address 0x100000.
* 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
* (Port: P1 Pin: 9).
* In this configuration, a reset of the reader module is independend
* from the reset of the microcontroller.
* 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.
*
*  ---- internal functions, which have no prototypes in a header
*       file. This kind of functions are not intended to be used 
*       outside of this file
*  ---- commands, which are intended for the reader module itself
*  ---- 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.
* Certainly, each command for a PICC consists of an instruction to the PCD. 
* Therefore
* the function PcdSingleResponseCmd is very important for the understanding
* of the communication.
* 
* The basic functionality is provided by the interrupt service
* routine (SingleResponseCmd), which closely works together with the function
* PcdSingleResponseCmd. All kinds of interrupts are serviced by the 
* same ISR. 
*/

///////////////////////////////////////////////////////////////////////////////
//             M O D U L   V A R I A B L E S 
///////////////////////////////////////////////////////////////////////////////


// interrupt vector number for interrupt of the RIC
// select the appropriate value corresponding to the microcontroller in use
#define READER_INT       // e. g. 0x18 
// disable reader interrupt
// select the appropriate value corresponding to the microcontroller in use
#define READER_INT_DISABLE    // e. g. EXICON &= ~0x0002
// enable reader interrupt
// select the appropriate value corresponding to the microcontroller in use
#define READER_INT_ENABLE     // e. g. EXICON |= 0x0002

// initialize reset pin and change port direction
// select the appropriate value corresponding to the microcontroller in use
#define READER_INIT_RESET    // e. g. P6 |= 0x20; DP6 |= 0x20
// set reset pin
// select the appropriate value corresponding to the microcontroller in use
#define READER_RESET         // e. g. P6 |= 0x20
// clear reset pin
// select the appropriate value corresponding to the microcontroller in use
#define READER_CLEAR_RESET    // e. g. P6 &= ~0x20

// memory base address corresponding to the previous set address select register
// select the appropriate value corresponding to the microcontroller in use
#define MEMORY_BASE_ADDRESS    0x100000

// the RIC has only 3 address lines - page select is necessary
#define GetRegPage(addr) (0x80 | (addr>>3))

/* ISO14443 Support Properties
* Some of the protokoll functions of ISO14443 needs information about
* the capability of the reader device, which are provided by this
* constants.
*/
//{
#define TCLFSDSNDMAX   8   ///< max. frame size send
#define TCLFSDRECMAX   8   ///< max. frame size rcv
#define TCLDSMAX       3   ///< max. baudrate divider PICC --> PCD
#define TCLDRMAX       3   ///< max. baudrate divider PCD --> PICC

#define TCLDSDFLT      0   ///< default baudrate divider PICC --> PCD
#define TCLDRDFLT      0   ///< default baudrate divider PCD --> PICC
//}

/* ISR communication structures
* All parameters are passed to the ISR via this structure.
*/
//{
// struct definition for a communication channel between function and ISR
typedef struct 
         {
            unsigned char  cmd;           //!< command code 
            char           status;        //!< communication status
            unsigned short nBytesSent;    //!< how many bytes already sent
            unsigned short nBytesToSend;  //!< how many bytes to send
            unsigned short nBytesReceived;//!< how many bytes received
            unsigned long  nBitsReceived; //!< how many bits received
            unsigned char  irqSource;     //!< which interrupts have occured
            unsigned char  collPos;       /*!< at which position occured a
                                          collision*/
            unsigned char  errFlags;      //!< error flags
            unsigned char  saveErrorState;//!< accumulated error flags for
                                          //!< multiple responses
            unsigned char  RxAlignWA;     //!< workaround for RxAlign = 7
            unsigned char  DisableDF;     //!< disable disturbance filter
         } MfCmdInfo;

// Convinience function for initialising the communication structure.
#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; \
            info.errFlags       = 0; \
            info.saveErrorState = 0; \
            info.RxAlignWA      = 0; \
            info.DisableDF      = 0;

// In order to exchange some values between the ISR and the calling function,
// a struct is provided. 
volatile MfCmdInfo     MInfo;                  

// communication info stucture
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];


// storage buffer for receive and transmit routines
//{
#define MEMORY_BUFFER_SIZE    300
volatile unsigned char MemPool[MEMORY_BUFFER_SIZE];

volatile unsigned char *MSndBuffer = MemPool; // pointer to the transmit buffer
volatile unsigned char *MRcvBuffer = MemPool; // pointer to the receive buffer
//}

/* Higher Baudrate Control
* attention: RegDecoderControl is modified in CascAnticoll
* Because of standard baudrate usage during anticollision, the 
* register can be written. For general purpose usage, only some bits 
* should be set.         
*
* Please pay attention, that the location of the configuration array is
* in ROM space, that means that on 16 bit microcontroller the access 
* should be word aligned.
*/
//{
typedef struct 
         {
            unsigned short  SubCarrierPulses; ///< RegRxControl1
            unsigned short  RxCoding;         ///< RegDecoderControl
            unsigned short  RxThreshold;      ///< RegRxThreshold
            unsigned short  BPSKDemControl;   ///< RegBPSKDemControl
         } t_DSCfg;

typedef struct 
         {
            unsigned short  CoderRate;        ///< RegCoderControl
            unsigned short  ModWidth;         ///< RegModWidth
         } t_DRCfg;
     
const t_DSCfg  MDSCfg[4] = {{0x73,0x08,0x88,0x00}     // Manchaster 106 kBaud
                            ,{0x53,0x09,0x50,0x0C}     // BPSK 212 kBaud
                            ,{0x33,0x09,0x50,0x0C}     // BPSK 424 kBaud
                            ,{0x13,0x09,0x50,0x0C}};   // BPSK 848 kBaud
const t_DRCfg  MDRCfg[4] = {{0x19,0x13}          // Miller 106 kBaud
                            ,{0x11,0x07}          // Miller 212 kBaud
                            ,{0x09,0x03}          // Miller 424 kBaud
                            ,{0x01,0x01}};        // Miller 848 kBaud

// data send baudrate divider PICC --> PCD
static unsigned char MDSI = TCLDSDFLT;    

// data send baudrate divider PCD --> PICC
static unsigned char MDRI = TCLDRDFLT;   
//}

// Write one byte to the reader IC address space
/*!
* -o  address  (IN) reader ic register address
* -o  value    (IN) 8 bit value
* return: none
*
* Function for writting one char to the reader module
*
* The reader module is connected to a 16 bit demultiplexed bus,
* therefore the address pin of the reader module is mapped as
* follows: \n
* uC             Reader \n
* A1               A0   \n
* A2               A1   \n
* A3               A2   \n
*
* In order to get the correct address, the original address need to 
* be multiplied by 2.
*/

#define WriteRawRC(addr,value) *(gpcRCBaseAddress + addr) = value;

//! Read one byte from the reader IC address space
/*!
* -o  address  (IN) reader ic register address
* -o  value    (IN) 8 bit value
* return: none
*
* Function for reading one char from the reader module
*
* The reader module is connected to a 16 bit demultiplexed bus,
* therefore the address pin of the reader module is mapped as
* follows: \n
* uC             Reader \n
* A1               A0   \n
* A2               A1   \n
* A3               A2   \n
*
* In order to get the correct address, the original address need to 
* be multiplied by 2.
*/
#define ReadRawRC(addr) (*(gpcRCBaseAddress + addr))


//! Open Reader IC Connection
/*!
* -o  none
* return: MI_OK
*         other    error opening reader ic channel
*
* Open and initialize communication channel to the reader module
*/
char OpenRC(void);

//! Write one byte to the reader IC address space
/*!
* -o  address  (IN) reader ic register address
* -o  value    (IN) 8 bit value
* return: none
*
* This function determines the necessary page address of the 
* reader module and writes the page number to the page 
* register and the value to the specified address.
*/
void WriteRC(unsigned char Address, unsigned char value);

//! Write one byte to the reader IC address space
/*
* -o  address   (IN) reader IC register address
* return: value    8 bit data, read from the reader ic address space
*
* This function determines the necessary page address of the 
* reader module and writes the page number to the page 
* register and reads the value from the specified address.
*/
unsigned char ReadRC(unsigned char Address);

//! Close reader IC communication channel
/*!
* -o  none
* return: none
*
* Closing the communication channel to the reader module
*/
void CloseRC(void);

// In case of a parallel connection, the address space of the reader module
// needs to be mapped to the address space of the microcontroller. Therefore
// a base address is reserved.
unsigned char * const gpcRCBaseAddress = (unsigned char * const)(MEMORY_BASE_ADDRESS);

///////////////////////////////////////////////////////////////////////////////
//                 Open Reader Communication
///////////////////////////////////////////////////////////////////////////////
char OpenRC(void)
{
   signed char status = MI_OK;

   READER_INIT_RESET;

   return status;
}

///////////////////////////////////////////////////////////////////////////////
//                 Close Reader Communication
///////////////////////////////////////////////////////////////////////////////
void CloseRC(void)
{
}

///////////////////////////////////////////////////////////////////////////////
//          G E N E R I C    W R I T E
///////////////////////////////////////////////////////////////////////////////
void WriteRC(unsigned char Address, unsigned char value)
{
   WriteRawRC(0x00,GetRegPage(Address));   // select appropriate page
   WriteRawRC(Address,value);              // write value at the specified 
                                           // address
}

///////////////////////////////////////////////////////////////////////////////
//          G E N E R I C    R E A D
///////////////////////////////////////////////////////////////////////////////
unsigned char ReadRC(unsigned char Address)
{
   WriteRawRC(0x00,GetRegPage(Address));   // select appropriate page
   return ReadRawRC(Address);              // read value at the specified 
}  

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

///  Internal Authentication State Switch
/*!
* -o  auth_mode (IN) 
*                  enum: selects master key A or master key B 
*                   - PICC_AUTHENT1A
*                   - PICC_AUTHENT1B 
*                  
* -o  *snr      (IN) 
*                  4 byte serial number of the card, which should be 
*                  authenticated
* -o  sector (IN) Range [0..15] 
*               specifies the key RAM address 
*               from which the keys should be taken
* return: enum:
*          - MI_OK
*          - CCE
*          - MI_BITCOUNTERR  wrong number of bits received
*          - MI_AUTHERR      wrong keys for selected card
*          - MI_KEYERR       error while loading keys
*         
* 
* Internal authentication state function.
*/
char Mf500PiccAuthState(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

/// Write Baudrate Divider
/*!
* -o     none
* return:   MI_OK
*
* Write function for baudrate divider and PCD properties
*/
char  Mf500PcdWriteAttrib(void);

/* ISR Communication Structure
* Data, which have to be passed between ISR and other functions are
* colleted within one structure. 
*/ 
//{
// ISR for Single Response Commands 
/*
* -o  none
* return: none
*
* This function is a central routine in the communication chain between
* PCD and PICC. 
*/ 
//interrupt (READER_INT) 
void SingleResponseIsr(void);

// Command issuer for Single Response Commands 
/*
* -o  cmd  (IN)
*             Command type
*             enum:
*              - PCD_IDLE
*              - PCD_WRITEE2
*              - PCD_READE2
*              - PCD_LOADCONFIG
*              - PCD_LOADKEYE2
*              - PCD_AUTHENT1
*              - PCD_CALCCRC

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看国产精品网站| 国产精品中文字幕日韩精品| 91国偷自产一区二区三区观看| 国产日产亚洲精品系列| 国产aⅴ精品一区二区三区色成熟| 国产欧美日韩精品一区| 成年人午夜久久久| 亚洲精品亚洲人成人网| 欧美日韩精品是欧美日韩精品| 午夜精品久久久久久久久| 欧美一区二区免费观在线| 国内成人精品2018免费看| 亚洲国产精品ⅴa在线观看| 色综合亚洲欧洲| 日韩av午夜在线观看| 国产日韩欧美精品在线| 91视频在线观看免费| 图片区日韩欧美亚洲| 欧美精品一区二区久久久 | 亚洲一区二区欧美激情| 欧美日韩第一区日日骚| 国精产品一区一区三区mba桃花| 欧美国产欧美综合| 欧美三级蜜桃2在线观看| 久久国产精品色婷婷| 亚洲日本免费电影| 91精品国产免费| 成人免费视频一区| 午夜视频在线观看一区二区| 精品国产91亚洲一区二区三区婷婷| 成人精品免费网站| 日韩av在线播放中文字幕| 国产精品嫩草影院av蜜臀| 欧美久久久久久蜜桃| 色94色欧美sute亚洲线路二| 天天操天天综合网| 国产精品欧美一级免费| 欧美精选在线播放| 99这里只有久久精品视频| 天天影视色香欲综合网老头| 中文字幕欧美国产| 日韩一区国产二区欧美三区| fc2成人免费人成在线观看播放| 男人的天堂久久精品| 亚洲日本免费电影| 亚洲国产精华液网站w| 欧美一区二区私人影院日本| 97se亚洲国产综合在线| 国产乱码精品一区二区三| 午夜婷婷国产麻豆精品| 亚洲人一二三区| 久久综合999| 日韩亚洲欧美中文三级| 欧美日韩综合一区| 91免费看`日韩一区二区| 国产另类ts人妖一区二区| 日韩精品一卡二卡三卡四卡无卡| 亚洲天堂免费看| 国产精品视频一二三区 | 久久国产精品无码网站| 亚洲第一搞黄网站| 亚洲一区在线观看网站| 国产精品嫩草影院com| 久久九九99视频| 精品毛片乱码1区2区3区| 91精品国产91久久久久久一区二区 | 在线观看免费亚洲| 9i看片成人免费高清| 成人av在线电影| 成人免费视频一区| 成人av在线播放网站| 成人激情视频网站| 成人精品高清在线| 成人网页在线观看| 成人精品视频一区| bt7086福利一区国产| 99精品久久免费看蜜臀剧情介绍| 成人性生交大片免费看在线播放| 国产成人在线网站| 成人性视频免费网站| 成人av在线资源网| 91小视频在线免费看| 91国内精品野花午夜精品 | 日本欧美一区二区三区乱码| 亚洲国产日韩综合久久精品| 亚洲国产成人va在线观看天堂| 国产真实精品久久二三区| 日韩精品一二三| 麻豆91精品视频| 激情av综合网| 国产精品综合二区| 成人av在线网| 欧美性生活久久| 91麻豆精品国产91久久久久| 日韩精品在线一区| 久久久久亚洲综合| 亚洲日本va午夜在线电影| 亚洲国产精品一区二区久久| 午夜不卡av在线| 另类小说综合欧美亚洲| 国产精品77777| 99re视频这里只有精品| 欧美日韩一区二区在线观看视频| 91精品久久久久久久99蜜桃| 久久影院午夜片一区| 国产精品久久久久久久午夜片| 亚洲精品乱码久久久久| 午夜精品福利一区二区三区蜜桃| 久久国产精品免费| 99久久99久久久精品齐齐| 欧洲日韩一区二区三区| 欧美成人乱码一区二区三区| 日本一区二区久久| 亚洲图片欧美视频| 美女久久久精品| 99免费精品在线观看| 在线电影院国产精品| 国产欧美日韩精品在线| 亚洲福利一二三区| 国产成人综合精品三级| 91精品福利在线| 国产亚洲欧美一级| 亚洲综合区在线| 国产精品一区二区在线观看不卡 | 日本aⅴ精品一区二区三区 | 麻豆国产一区二区| 91性感美女视频| www国产精品av| 一区二区三区高清| 国产精一区二区三区| 欧美日韩国产三级| 中文字幕精品综合| 久久黄色级2电影| 在线区一区二视频| 中文字幕第一页久久| 麻豆91免费观看| 欧美在线免费观看亚洲| 国产人成亚洲第一网站在线播放 | 国产精品成人在线观看| 男男成人高潮片免费网站| 91视频.com| 久久九九国产精品| 久久成人18免费观看| 欧美日韩电影在线| 亚洲一二三区视频在线观看| 成人午夜电影小说| 欧美不卡一区二区三区四区| 久久99国产精品尤物| 欧美妇女性影城| 亚洲精品五月天| 97久久超碰国产精品电影| 久久久久国产精品麻豆ai换脸| 日本视频一区二区| 欧美午夜精品免费| 亚洲另类一区二区| 91在线云播放| 亚洲人成网站色在线观看 | 色综合久久99| 日本一区二区不卡视频| 国产一本一道久久香蕉| 精品久久一区二区三区| 日本视频在线一区| 日韩亚洲欧美一区| 蜜臀av一区二区在线观看 | 国产一区二区免费看| 日韩无一区二区| 久久99精品久久久久| 精品黑人一区二区三区久久 | 欧美日韩免费电影| 午夜电影久久久| 欧美久久一二三四区| 日韩电影在线免费看| 在线播放/欧美激情| 午夜精品久久久久久久久久| 91精选在线观看| 日本aⅴ免费视频一区二区三区| 91麻豆精品国产91久久久资源速度| 石原莉奈一区二区三区在线观看| 欧美日韩国产免费一区二区| 日韩国产欧美在线视频| 日韩久久久精品| 国产精品一区二区你懂的| 国产精品久久久久久久浪潮网站| 91色九色蝌蚪| 亚洲精品亚洲人成人网 | 久久国产成人午夜av影院| 2024国产精品| 国产**成人网毛片九色 | 亚洲欧美日韩综合aⅴ视频| 欧美在线视频日韩| 婷婷亚洲久悠悠色悠在线播放| 91精品免费在线观看| 国产激情视频一区二区在线观看 | 精品剧情v国产在线观看在线| 国产精品自拍av| 蜜桃av一区二区三区电影| 久久综合色婷婷| 色婷婷久久99综合精品jk白丝| 日韩精品成人一区二区三区| 久久精品一区二区三区不卡|