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

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

?? mfrc500uc.c

?? RC500的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一区二区三区免费野_久草精品视频
一区二区三区国产精华| 26uuu国产日韩综合| 国产精品二三区| 成人a区在线观看| 亚洲女厕所小便bbb| 99国产精品99久久久久久| 国产精品久久夜| 91捆绑美女网站| 亚洲一区二区三区激情| 欧美一级高清大全免费观看| 精品在线免费观看| 亚洲国产精品二十页| 色综合视频一区二区三区高清| 亚洲欧美中日韩| 欧美日韩中文字幕精品| 久久er99热精品一区二区| 久久精品一二三| 99久久精品国产导航| 亚洲成人av免费| 欧美不卡一区二区三区四区| 国产精品正在播放| 亚洲美女精品一区| 91精品国产麻豆国产自产在线| 国内精品久久久久影院一蜜桃| 国产精品欧美一级免费| 日本高清不卡在线观看| 麻豆久久久久久| 中文字幕在线观看不卡视频| 欧美男人的天堂一二区| jiyouzz国产精品久久| 日本欧美一区二区三区乱码| 国产日韩精品一区二区浪潮av| 在线视频观看一区| 国产成人精品三级| 午夜a成v人精品| 中文字幕第一区二区| 欧美老女人在线| av影院午夜一区| 麻豆国产精品一区二区三区| 亚洲另类中文字| www精品美女久久久tv| 91久久久免费一区二区| 国产一区二区三区四区五区美女 | 中文字幕在线一区二区三区| 51精品国自产在线| 91丨porny丨最新| 激情六月婷婷综合| 青青青爽久久午夜综合久久午夜| 国产精品国产三级国产普通话99| 欧美大片一区二区| 欧美日韩在线播放三区| www.66久久| 国产99久久精品| 麻豆一区二区三| 亚洲国产成人porn| 亚洲视频每日更新| 国产亚洲婷婷免费| 日韩三级视频在线观看| 在线视频中文字幕一区二区| 国产成人av一区二区三区在线| 无码av免费一区二区三区试看| 亚洲免费观看高清完整版在线观看熊| 精品国产区一区| 欧美一区二区免费视频| 欧美精品v日韩精品v韩国精品v| 日本韩国欧美在线| 91视频免费播放| 97久久人人超碰| 成人一区二区三区中文字幕| 黄网站免费久久| 久久精品国产秦先生| 五月天欧美精品| 亚洲福利电影网| 亚洲中国最大av网站| 亚洲视频精选在线| 一区二区在线观看视频在线观看| 综合av第一页| 亚洲欧美欧美一区二区三区| 国产精品国产三级国产aⅴ中文| 国产精品久久久久久一区二区三区| 久久九九影视网| 久久精品日韩一区二区三区| 欧美极品美女视频| 中文字幕一区二区三区在线观看| 日本一区二区视频在线观看| 中文av一区特黄| 欧美国产1区2区| 亚洲欧美偷拍卡通变态| 亚洲精品写真福利| 亚洲国产成人精品视频| 日韩黄色免费网站| 蜜桃一区二区三区在线观看| 国内外成人在线| 成人教育av在线| 在线视频国内自拍亚洲视频| 制服丝袜亚洲播放| 久久综合一区二区| 中文字幕一区av| 亚洲国产日韩av| 精油按摩中文字幕久久| 国产盗摄精品一区二区三区在线| 成人91在线观看| 欧美日韩国产美| 精品成人a区在线观看| 久久精品一二三| 一区二区三区四区激情| 麻豆视频一区二区| 色综合久久中文综合久久97| 91精品国产综合久久久久久| 国产亚洲综合av| 亚洲图片欧美视频| 国内精品视频666| 欧美影院精品一区| 久久只精品国产| 一区二区三区在线观看欧美 | 中文字幕精品三区| 亚洲成人黄色影院| 国产a区久久久| 91精品国产91热久久久做人人| 2023国产精品| 亚洲一区二区三区中文字幕| 国内精品视频一区二区三区八戒| 91在线你懂得| 亚洲精品在线一区二区| 亚洲精品日产精品乱码不卡| 久99久精品视频免费观看| 色女孩综合影院| 国产亚洲一二三区| 美女视频一区二区三区| 色综合久久66| 国产欧美日韩视频在线观看| 午夜精品久久久久| 97久久超碰精品国产| 久久久久久久久久久久久久久99 | 日本一区二区成人| 蜜臀av一区二区| 欧美熟乱第一页| 中文字幕一区二区三区乱码在线| 九九精品视频在线看| 欧美三区免费完整视频在线观看| 中文字幕一区二区三区蜜月| 国产精品影音先锋| 精品乱人伦小说| 日韩国产精品久久| 在线观看亚洲a| 亚洲欧美日韩国产综合| 成人免费毛片片v| 日本一区二区三区在线观看| 国内精品视频666| 日韩女优av电影| 日韩高清一区二区| 欧美日韩不卡在线| 亚洲一二三区在线观看| 91免费看`日韩一区二区| 亚洲欧洲www| 99re免费视频精品全部| 中文字幕在线不卡国产视频| 成人精品视频一区| 欧美—级在线免费片| 国产成人超碰人人澡人人澡| 久久久亚洲精品石原莉奈 | 日本在线观看不卡视频| 欧美日本不卡视频| 五月婷婷久久丁香| 91精品中文字幕一区二区三区| 天天色天天爱天天射综合| 欧美日韩国产影片| 日韩福利视频网| 欧美成人bangbros| 激情综合网天天干| 久久精品一区二区三区av| 成熟亚洲日本毛茸茸凸凹| 久久久久久久久久久电影| 国产成都精品91一区二区三| 欧美极品美女视频| 91在线免费看| 亚洲一二三四区| 欧美老年两性高潮| 麻豆国产精品官网| 国产女同性恋一区二区| 成人黄色综合网站| 亚洲毛片av在线| 在线91免费看| 精品一二三四区| 中文字幕av在线一区二区三区| 99国产精品久久久| 亚欧色一区w666天堂| 欧美成人综合网站| 成人av网站在线观看免费| 一区二区欧美国产| 欧美一级二级三级乱码| 国产成人在线视频网站| 国产精品女上位| 色偷偷成人一区二区三区91| 日日夜夜精品视频免费| 久久亚洲综合色一区二区三区| 99久久久免费精品国产一区二区| 亚洲一区二区偷拍精品| 日韩午夜精品视频| 成人免费视频视频在线观看免费 |