#ifndef __MIFARE_H
#define __MIFARE_H


unsigned int MifareReadId( unsigned char *card);
unsigned int MifareFindCard(unsigned char *serial_num);
unsigned int MifareCheckPassword(unsigned char Snr,unsigned char *serial_num);
unsigned int MifareInitReader(void);   
unsigned int MifareReadIdAndRWBlock(void);


// Read EEPROM Memory Block
tUInt PcdReadE2(tUInt startaddr, tUChar length, tUChar *readdata);
tUInt PcdWriteE2(tUInt startaddr, tUChar length, tUChar *writedata);
tUInt LoadDefaultKeys(void);
//tUInt AuthorizeCardAcces(tUChar block, tUChar*uid, tUChar rst_field);
tUInt AuthorizeCardAccess(tUChar block, tUChar auth_mode, tUChar *uid);
tUInt WriteSectorTrailer(void);
void PCD_Stop_and_FiledOff(void);
void RestartField(void);
tUInt FindAndSelectCard(void);
tUInt SaveKeyToEeprom(void);


#define WRITE_DATA_BLOCK			0x01		// zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define WRITE_VALUE_BLOCK			0x02		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define INCREMENT_VALUE_BLOCK		0x03		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define DECREMENT_VALUE_BLOCK		0x04		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define FORMAT_TRAILER_BLOCK		0x05		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define READ_DATA_BLOCK				0x06		// zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
#define READ_VALUE_BLOCK			0x07		// zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
//#define TRANSFER_VALUE_BLOCK		0x08		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block
//#define RESTORE_VALUE_BLOCK		0x09		// rezim zapisu/cteni VALUE BLOCKU, nikoliv klasicky DATA block

#define CARD_RW_DONE				0x01		// READ/WRITE cyklus probehl
#define CARD_WAIT_TIMEOUT			0x02		// timeout pri cekani na prilozeni karty





#endif
