main.h
资源名称:FM1702.rar [点击查看]
上传用户:guangya188
上传日期:2019-10-26
资源大小:4644k
文件大小:6k
源码类别:
RFID编程
开发平台:
C/C++
- /****************************************************************************
- * File : main.h *
- * COPYRIGHT BY HUOYAN LTD.COMPANY *
- * Version: V1.3 *
- * *
- * Created: 18.10.2005 *
- * Last Change: 21.10.2005 *
- * *
- * Author: NIL *
- * *
- * Compiler: KEIL C51 V7.10 *
- * *
- * Description: AT89S52-Firmware for FM1702 Demo Serial Reader *
- * *
- ****************************************************************************/
- #ifdef __SRC
- #define EXTERN
- #else
- #define EXTERN extern
- #endif
- #define TRUE 1
- #define FALSE 0
- #define ON 0
- #define OFF 1
- #define NO_TIMER2 1
- //设置波特率
- #define OSC_FREQ 22118400L
- #define BAUD_115200 256 - (OSC_FREQ/192L)/115200L // 255
- #define BAUD_57600 256 - (OSC_FREQ/192L)/57600L // 254
- #define BAUD_38400 256 - (OSC_FREQ/192L)/38400L // 253
- #define BAUD_28800 256 - (OSC_FREQ/192L)/28800L // 252
- #define BAUD_19200 256 - (OSC_FREQ/192L)/19200L // 250
- #define BAUD_14400 256 - (OSC_FREQ/192L)/14400L // 248
- #define BAUD_9600 256 - (OSC_FREQ/192L)/9600L // 244
- #define RCAP2_50us 65536L - OSC_FREQ/240417L
- #define RCAP2_1ms 65536L - OSC_FREQ/12021L
- #define RCAP2_10ms 65536L - OSC_FREQ/1200L
- #define RCAP2_1s 65536L - OSC_FREQ/12L
- #define CALL_isr_UART() TI = 1
- unsigned char idata MLastSelectedSnr[4];
- unsigned char idata RevBuffer[40];
- unsigned char data SerBuffer[20];
- bit CmdValid;
- unsigned char idata tagtype[2]; /* 卡片标识字符 */
- /* FM1702变量定义 */
- unsigned char idata RevBuffer[40]; /* FM1702命令发送接收缓冲区 */
- unsigned char idata UID[5]; /* 序列号 */
- unsigned char idata Secnr; /* 扇区号 */
- unsigned char cardtype;
- //函数定义
- EXTERN void InitSystem(void);
- EXTERN void cmd_process(void);
- EXTERN void delay_10ms(unsigned int _10ms);
- EXTERN void delay_1ms(unsigned char _1ms);
- EXTERN void delay_50us(unsigned char _50us);
- EXTERN void start_timeout(unsigned int _50us);
- EXTERN void stop_timeout(void);
- EXTERN unsigned char Clear_FIFO(void);
- EXTERN void Write_FIFO(unsigned char count, unsigned char idata *buff);
- EXTERN unsigned char Judge_Req(unsigned char idata *buff);
- EXTERN unsigned char Check_UID(void);
- EXTERN void Save_UID(unsigned char row, unsigned char col, unsigned char length);
- EXTERN void Set_BitFraming(unsigned char row, unsigned char col);
- EXTERN void Init_FM1702(unsigned char mode);
- EXTERN unsigned char Command_Send(unsigned char count, unsigned char idata *buff, unsigned char Comm_Set);
- EXTERN unsigned char Read_E2(unsigned char lsb, unsigned char msb, unsigned char count, unsigned char idata *buff);
- EXTERN unsigned char Write_E2(unsigned char lsb, unsigned char msb, unsigned char count, unsigned char idata *buff);
- EXTERN unsigned char MIF_Halt(void);
- EXTERN char M500HostCodeKey( unsigned char *uncoded, unsigned char *coded);
- EXTERN unsigned char Load_keyE2_CPY(unsigned char Secnr, unsigned char Mode);
- EXTERN unsigned char Load_keyE2(unsigned char Secnr, unsigned char Mode);
- EXTERN unsigned char Request(unsigned char mode);
- EXTERN unsigned char AntiColl(void);
- EXTERN unsigned char Select_Card(void);
- EXTERN unsigned char Authentication(unsigned char idata *UID, unsigned char SecNR, unsigned char mode);
- EXTERN unsigned char MIF_READ(unsigned char idata *buff, unsigned char Block_Adr);
- EXTERN unsigned char MIF_Write(unsigned char idata *buff, unsigned char Block_Adr);
- EXTERN unsigned char MIF_Increment(unsigned char idata *buff, unsigned char Block_Adr);
- EXTERN unsigned char MIF_Decrement(unsigned char idata *buff, unsigned char Block_Adr);
- EXTERN unsigned char MIF_Restore(unsigned char Block_Adr);
- EXTERN unsigned char MIF_Transfer(unsigned char Block_Adr);
- EXTERN unsigned char HL_Active(unsigned char Block_Adr, unsigned char Mode);
- EXTERN unsigned char MIF_Initival(unsigned char idata *buff, unsigned char Block_Adr);
- EXTERN unsigned char HL_Read(unsigned char idata *buff, unsigned char Block_Adr, unsigned char Mode);
- EXTERN unsigned char HL_Write(unsigned char idata *buff, unsigned char Block_Adr, unsigned char Mode);
- //////////////////////////////////////////////////////////////////////////
- ////////SPI Interface/////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////
- EXTERN void delay1(unsigned char dlength);
- EXTERN unsigned char SPIRead(unsigned char idata SpiAddress);
- EXTERN void SPIWrite(unsigned char idata SpiAddress,unsigned char idata SpiData);
- //////////////////////////////////////////////////////////////////////////
- //ISP function
- ///////////////////////////////////////////////////////////////////////
- extern void GoToIsp(void);
- //////////////////////////////////////////////////////////////////////////////
- // End of File
- //////////////////////////////////////////////////////////////////////////////