 /**
  ****************************************************************
  * @file iso14443_4.h
  *
  * @brief 
  *
  * @author 
  *
  * 
  ****************************************************************
  */
#ifndef ISO14443_4_H
#define ISO14443_4_H
#define ISO14443_4_ERR_PROTOCOL  ( 100 )
#define ISO14443_PROTOCOL_RETRANSMISSION_LIMITED  ( 2 )

#define ISO14443_CL_PROTOCOL_CHAINED              ( 0x10 )
#define ISO14443_CL_PROTOCOL_CID                  ( 0x8 )
#define ISO14443_CL_PROTOCOL_NAD                  ( 0x4 )
#define ISO14443_CL_PROTOCOL_ISN                  ( 0x1 )

typedef struct pcd_info_s
{
    unsigned char     uc_nid;
    unsigned char     uc_nad_en;
    unsigned char     uc_cid;
    unsigned char     uc_cid_en;
    unsigned int      ui_fsc;
    unsigned int      ui_fwi;
    unsigned int      ui_sfgi;
    unsigned char     uc_pcd_pcb;
    unsigned char     uc_picc_pcb;
    unsigned int      uc_pcd_txr_num;
    unsigned int      uc_pcd_txr_lastbits;
	  unsigned char	  uc_wtxm;
}pcd_info_s;

//pcd_info_s g_pcd_module_info = {0,0,0,0,0,0,0,0,0,0,0,};

extern pcd_info_s  g_pcd_module_info;


enum exe_step_t 
   { 
       ORG_IBLOCK = 1,
       ORG_ACKBLOCK,  
       ORG_NACKBLOCK,
        ORG_SBLOCK,
       ORG_TRARCV, 
        RCV_IBLOCK,
      RCV_RBLOCK,
        RCV_SBLOCK,
        RCV_INVBLOCK,
        NON_EVENT 
    };

int ISO14443_4_HalfDuplexExchange( struct pcd_info_s *ppcd_info, 
                                   unsigned char *psrc, 
                                   int i_tx_n, 
                                   unsigned char *pdes, 
                                  unsigned int *pi_rx_n );

int ISO14443_4_SRequest( struct pcd_info_s *ppcd_info, 
                         unsigned char      ucSPcb,
                         unsigned char      ucParam );

void pcd_default_info(void);

int iso14443_4_deselect(unsigned char CID);

int pcd_rats_a(unsigned char CID, unsigned char *ats);

//void com_typea_rats(void);
//void com_typea_rats(u8 pps_pcmd);
int com_typea_rats(unsigned char pps_pcmd);
int pcd_pps_rate(unsigned char *ATS, unsigned char CID, unsigned char rate);
void pcd_set_rate(unsigned char rate, unsigned char type);
int APDU(void);

												 											 
#endif

