main.h
上传用户:guangya188
上传日期:2019-10-26
资源大小:4644k
文件大小:6k
源码类别:

RFID编程

开发平台:

C/C++

  1. /****************************************************************************
  2. * File :  main.h                                                            *
  3. * COPYRIGHT BY HUOYAN LTD.COMPANY                                           *
  4. * Version:      V1.3                                               *
  5. *                                                                           *
  6. * Created:      18.10.2005                                                  *
  7. * Last Change:  21.10.2005                                                  *
  8. *                                                                           *
  9. * Author:       NIL                                                         *
  10. *                                                                           *
  11. * Compiler:     KEIL C51 V7.10                                              *
  12. *                                                                           *
  13. * Description:  AT89S52-Firmware for FM1702 Demo Serial Reader              *
  14. *                                                                           *
  15. ****************************************************************************/
  16. #ifdef __SRC
  17. #define EXTERN
  18. #else
  19.  #define EXTERN         extern
  20. #endif
  21. #define TRUE   1
  22. #define FALSE  0
  23. #define ON     0
  24. #define OFF    1
  25. #define NO_TIMER2           1
  26. //设置波特率
  27. #define OSC_FREQ                22118400L
  28. #define BAUD_115200             256 - (OSC_FREQ/192L)/115200L   // 255
  29. #define BAUD_57600              256 - (OSC_FREQ/192L)/57600L    // 254
  30. #define BAUD_38400              256 - (OSC_FREQ/192L)/38400L    // 253
  31. #define BAUD_28800              256 - (OSC_FREQ/192L)/28800L    // 252
  32. #define BAUD_19200              256 - (OSC_FREQ/192L)/19200L    // 250
  33. #define BAUD_14400              256 - (OSC_FREQ/192L)/14400L    // 248
  34. #define BAUD_9600               256 - (OSC_FREQ/192L)/9600L     // 244
  35. #define RCAP2_50us             65536L - OSC_FREQ/240417L
  36. #define RCAP2_1ms              65536L - OSC_FREQ/12021L
  37. #define RCAP2_10ms             65536L - OSC_FREQ/1200L
  38. #define RCAP2_1s             65536L - OSC_FREQ/12L
  39. #define CALL_isr_UART()         TI = 1
  40. unsigned char idata MLastSelectedSnr[4];
  41. unsigned char idata RevBuffer[40];  
  42. unsigned char data SerBuffer[20];   
  43. bit CmdValid;
  44. unsigned char idata tagtype[2];             /* 卡片标识字符 */
  45. /* FM1702变量定义 */
  46. unsigned char idata RevBuffer[40];         /* FM1702命令发送接收缓冲区 */
  47. unsigned char idata UID[5];             /* 序列号 */
  48. unsigned char idata Secnr;         /* 扇区号 */
  49. unsigned char cardtype;
  50. //函数定义
  51. EXTERN void InitSystem(void); 
  52. EXTERN void cmd_process(void);
  53. EXTERN void delay_10ms(unsigned int _10ms);
  54. EXTERN void delay_1ms(unsigned char _1ms);
  55. EXTERN void delay_50us(unsigned char _50us);
  56. EXTERN void start_timeout(unsigned int _50us);
  57. EXTERN void stop_timeout(void);
  58. EXTERN unsigned char Clear_FIFO(void);
  59. EXTERN void Write_FIFO(unsigned char count, unsigned char idata *buff);
  60. EXTERN unsigned char Judge_Req(unsigned char idata *buff);
  61. EXTERN unsigned char Check_UID(void);
  62. EXTERN void Save_UID(unsigned char row, unsigned char col, unsigned char length);
  63. EXTERN void Set_BitFraming(unsigned char row, unsigned char col);
  64. EXTERN void Init_FM1702(unsigned char mode);
  65. EXTERN unsigned char Command_Send(unsigned char count, unsigned char idata *buff, unsigned char Comm_Set);
  66. EXTERN unsigned char Read_E2(unsigned char lsb, unsigned char msb, unsigned char count, unsigned char idata *buff);
  67. EXTERN unsigned char Write_E2(unsigned char lsb, unsigned char msb, unsigned char count, unsigned char idata *buff);
  68. EXTERN unsigned char MIF_Halt(void);
  69. EXTERN char M500HostCodeKey(  unsigned char *uncoded, unsigned char *coded);
  70. EXTERN unsigned char Load_keyE2_CPY(unsigned char Secnr, unsigned char Mode);
  71. EXTERN unsigned char Load_keyE2(unsigned char Secnr, unsigned char Mode);
  72. EXTERN unsigned char Request(unsigned char mode);
  73. EXTERN unsigned char AntiColl(void);
  74. EXTERN unsigned char Select_Card(void);
  75. EXTERN unsigned char Authentication(unsigned char idata *UID, unsigned char SecNR, unsigned char mode);
  76. EXTERN unsigned char MIF_READ(unsigned char idata *buff, unsigned char Block_Adr);
  77. EXTERN unsigned char MIF_Write(unsigned char idata *buff, unsigned char Block_Adr);
  78. EXTERN unsigned char MIF_Increment(unsigned char idata *buff, unsigned char Block_Adr);
  79. EXTERN unsigned char MIF_Decrement(unsigned char idata *buff, unsigned char Block_Adr);
  80. EXTERN unsigned char MIF_Restore(unsigned char Block_Adr);
  81. EXTERN unsigned char MIF_Transfer(unsigned char Block_Adr);
  82. EXTERN unsigned char HL_Active(unsigned char Block_Adr, unsigned char Mode);
  83. EXTERN unsigned char MIF_Initival(unsigned char idata *buff, unsigned char Block_Adr);
  84. EXTERN unsigned char HL_Read(unsigned char idata *buff, unsigned char Block_Adr, unsigned char Mode);
  85. EXTERN unsigned char HL_Write(unsigned char idata *buff, unsigned char Block_Adr, unsigned char Mode);
  86. //////////////////////////////////////////////////////////////////////////
  87. ////////SPI Interface/////////////////////////////////////////////////////
  88. //////////////////////////////////////////////////////////////////////////
  89. EXTERN void delay1(unsigned char dlength);
  90. EXTERN unsigned char SPIRead(unsigned char idata SpiAddress);
  91. EXTERN void SPIWrite(unsigned char idata SpiAddress,unsigned char idata SpiData);
  92. //////////////////////////////////////////////////////////////////////////
  93. //ISP function
  94. ///////////////////////////////////////////////////////////////////////
  95. extern void GoToIsp(void);
  96. //////////////////////////////////////////////////////////////////////////////
  97. // End of File
  98. //////////////////////////////////////////////////////////////////////////////