⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.h

📁 keilc写RFID独T5557卡的源程序,
💻 H
字号:
#include "w78e365.h"

#define uchar unsigned char	
#define uint unsigned int		 
#define uint32 unsigned long 	


#define FWD_CMD_LOGIN   0x4      
#define FWD_CMD_WRITE   0x2
#define FWD_CMD_READ    0x1
#define FWD_CMD_DISABLE 0x5

#define FWD_T5557_READ  	0x12
#define FWD_T5557_WRITE 	0x13
#define FWD_T5557_WAKEUP 	0x10
#define FWD_T5557_RESET  	0x00
#define ERR_T5557_READ_ERR  0x0B
#define ERR_T5557_WRONG_ERR 0x0C


#define	STX	0x02
#define	ETX	0x03

#define CAPTURE_SIZE (2*11*4)    

#define UART_MESSAGE_OK          0x00
#define ERR_ASIC_ANTENNA_FAULT   0x01
#define ERR_UART_ERROR_FLAG      0x04
#define ERR_UART_OVERFLOW        0x05
#define ERR_UART_WRONG_ICMD      0x06
#define ERR_UART_BAD_CRC         0x07
#define ERR_UART_UNKNOWN_CMD     0x08
#define ERR_UART_NO_ETX          0x09
#define ERR_UART_INTERBYTE_ERR   0x0A
#define ERR_EM4469_FLOWLINK_ERR  0x0B
#define ERR_EM4469_WRONG_DE      0x0C
#define ERR_EM4469_WRONG_DR      0x0D
#define ERR_EM4469_PARITY_ERR    0x10
#define ERR_EM4469_BAD_CONF_DATA 0x11
#define ERR_EM4469_NACK          0x12
#define ERR_EM4469_NEITHER_ACK   0x13
#define ERR_EM4469_NO_VALID_DR   0x14
#define ERR_EM4469_BAD_RAW       0x15
//版本,日期控制
#define READER_RELEASE 0x10   //1.0
#define READER_YEAR    6   //2006
#define READER_MONTH   4
#define READER_DATE    28
#define READER_FAMILY  90

#define	MAX_RXNUM	32
#define ts_min	        27//270*11.0592/12=249//取近似的整数
#define ts_max	        33//330*11.0592/12=304
#define t1_min	        9//90*11.0592/12=83:-10调整
#define t1_max	        18//180*11.0592/12=166
#define t2_min	        21//210*11.0592/12=194
#define t2_max	        30//300*11.0592/12=276

uchar xdata rx_buff[MAX_RXNUM];		//单片机接收PC串口数据缓冲区
uchar xdata tx_buff[MAX_RXNUM];		//单片机发送数据到PC数据缓冲区
uchar cap_count;
uchar check_stat;

uint xdata get_settings_low;
uint xdata get_settings_hi;

uchar config_encoder;                 
uchar config_data_rate;               
uchar config_delayed;                 
uchar config_lwr;                     
uchar config_raw;  
uchar lwr;                          //last word read
uchar delayed;                      //delayed value

uchar halfDataRate;                 //half period data rate module
uchar raw;                          //raw flag to capture read after write response

uchar xdata capture_data[CAPTURE_SIZE];          //maximum bytes captured at once
uint xdata maxCaptureTimeLow;           //lower part of current maximum capture time (used to initialise TCNT1)
uchar xdata maxCaptureTimeHi;            //upper part of current maximum capture time (expected value 0xFF or 0xFE only)
uint xdata read_tag_memory_word_low;      // Read Cmd content low
uint xdata read_tag_memory_word_hi;       // Read Cmd content hi
uint xdata maxTRead;                    //current datarate maximum response capture time
uint xdata maxTLogin;                   //current datarate maximum response capture time
uint xdata maxTWrite;                   //current datarate maximum response capture time
uint32 xdata maxTWriteRaw;                //current datarate maximum response capture time
uint xdata maxTDisable;                 //current datarate maximum response capture time
uint32 xdata maxTDefaultRead;             //current datarate maximum response capture time
uint xdata tpp_period;                  //Tpp pause in RF clocks
uint xdata twr_period;                  //Twr write time pause in RF clocks

uchar xdata last_valid;                   //last valid value for invalid sequence compression

uchar xdata captured_bit_count; 	//store_bit current capture bit counter
uchar xdata capture_cnt;        	//store_bit current capture byte index
uchar xdata bit_pos;                      //bit position in demodulation
uchar xdata enable_capture;             //enable capture ( 1=capture enable)
uchar xdata last_bit;                     //for biphase and miller usag
 
uint xdata last_capture;                //counter1 is now reset at capture start, we make a difference

uchar xdata captured_byte;     		 //store_bit current capture bits
uchar xdata captured_valid;     		//store_bit current capture valid bits
                                     		 //between current and last value
uchar xdata capture_time[256];
uchar xdata *capture_read_time_data_ptr;	
uchar xdata capture_check;
uchar xdata	capture_check_count;
bit	buffer_capture_check;
uchar xdata	compute_capture_check;
uchar xdata debug_mode;

uchar xdata fwd_bit_sz;                          //forwardlink bit counter

uchar xdata *fwd_write_ptr;                     //forwardlink bit pointer

uchar xdata currentMaxTimeHi;             //actual hi value of maximum capture time

bit flag_wait;

uchar xdata MaxCaptureHalfDateRate;
uchar xdata MaxCaptureDateRate;

uchar xdata fwd_bit_phase;              //forwardlink bit phase

uchar xdata forwardLink_data[80];                //array of forwarded bits 
uchar xdata *forward_ptr;                       //ptr for forward message preparation

//uchar xdata read_pulse_front;
//
//bit read_ok;
//bit read_header;
//bit is_longwave;
//bit is_one


//函数
void SendResponse(unsigned char i);
uchar Prepare_Cmd(uchar cmd); 
uchar Prepare_Addr(uchar addr);
void SendForward(uchar fwd_bit_count);
void Wait(uint period);
uchar Prepare_Data( uchar *data_tx);
void ManchesterRead(void);
void ManchesterWrite(void);
uint count_module(void);
void ReadWordToPC(void);
void WriteWordtoCard(void);
void ReadStatusToPC(void);
void FieldSwitch(void);
void SetReaderConfiguration(void);
void GetReaderConfiguration(void);
void Disable(void);
void Login(void);
void PCLinkReader(void);
//void DefaultRead(void);
void Readonly_autodetection(void);
void ClearCaptureBuffers(void);
void capture(void);
void store_bit(bit b);
void trace(uchar *str,uchar len);
void myputchar(uchar c);
void speak_on(void);
void return_00(void);

void ResetT5557(void);
void WakeUpT5557(void);
void GeneralRead_T5557(void);
void ReadT5557(void);
void WriteT5557(void);
void ReadT5557_PWD(void);
void WriteT5557_PWD(void);

bit b_edge;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -