#ifndef __EMV_IF_H__
#define __EMV_IF_H__
#include <stdint.h>


typedef uint8_t (*_read_reg)(uint8_t addr) ;
typedef void (*_write_reg)(uint8_t addr, uint8_t data);
typedef void (*_read_buf)(uint8_t ReadAddr, uint8_t* pBuffer, uint32_t NumByteToRead);
typedef void (*_write_buf)(uint8_t WriteAddr, uint8_t* pBuffer, uint32_t NumByteToRead);
typedef void (*_ASSERT_SPI_CLK_LOW)(void);
typedef void (*_RELEASE_SPI_CLK_LOW)(void);
typedef void (*_delay_1ms)(uint32_t  delay_time);
typedef void (*_tran_delay_1ms)(uint32_t  delay_time);
typedef int32_t (*_DEBPRINTF)(const char * fmt, ...);

#define RF_CS_PORT   GPIOA
#define RF_CS_PIN     28
#define RF_RST_PORT   GPIOA
#define RF_RST_PIN     29
#define RF_IRQ_PIN     30
#define RC523RST_L GPIO_BitOut(RF_RST_PORT,RF_RST_PIN, 0)//P4OUT &= ~BIT1
#define RC523RST_H GPIO_BitOut(RF_RST_PORT,RF_RST_PIN, 1)//P4OUT |= BIT1

extern _read_reg  spi_rdreg;
extern _write_reg spi_wrreg;
extern _read_buf  spi_rdbuf;
extern _write_buf spi_wrbuf;
extern _ASSERT_SPI_CLK_LOW ASSERT_SPI_CLK_LOW;
extern _RELEASE_SPI_CLK_LOW RELEASE_SPI_CLK_LOW;

extern _delay_1ms delay_1ms;
extern _tran_delay_1ms tran_delay_1ms;
extern _DEBPRINTF DEBPRINTF;

extern volatile uint8_t sl2523_rfcfg_init;  // 0x26
extern volatile  uint8_t sl2523_rfcfg1_init;  // 0x45
extern  volatile uint8_t sl2523_cwgsp_init; // 0x28
extern  volatile uint8_t sl2523_modgsp_init; // 0x29
extern volatile  uint8_t sl2523_cwgsp_exch; // 0x28
extern volatile  uint8_t sl2523_modgsp_exch; // 0x29
extern volatile  uint8_t sl2523_cwgsp_tran; // 0x28
extern volatile  uint8_t sl2523_modgsp_tran; // 0x28
extern volatile  uint8_t sl2523_digit0_val;  // 0x
extern volatile  uint8_t sl2523_digit1_val;  // 0x
extern volatile  uint8_t sl2523_calc_init;
extern volatile uint8_t irq_flag_io;
extern volatile uint8_t  sl2523_emv_mode;

void mcu_drv_init(void);
void sl2523_emv_init(void);
void sl2523_emv_main(void);
void spi_wr_test(void);
void Rc523AdptCalib(void);
void pre_test_pcd(void);
void spi_wr_test(void);

#endif

//endfile
