#ifndef __SPI_COMMON_H__
#define __SPI_COMMON_H__

#include <stdint.h>

#ifndef TRUE
#define TRUE                                (0x01)
#endif
#ifndef FALSE
#define FALSE                               (0x00)
#endif

#define MAX_FRAME_BUF_LEN	                (260)	/* Prologue(3) + INF(254) + Epilogue(1) + guard(2) */
#define MAX_INF_FIELD_LEN	                (254)
#define NODE_ADDR_PEARL		                (0x12)
#define NODE_ADDR_HOST		                (0x21)
#define MAX_POLLING_CNT		                (500)	/* total polling time will be 500*2ms = 1 second */
#define POLLING_INTERVAL_IN_US	            (2000)	/* 2ms */
#define POLLING_INTERVAL_IN_MS	            (2)	/* 2ms */
#define MAX_INNER_LOOP_CNT	                (10)
#define MAX_WTX_COUNT		                (2)
#define MAX_BWT_COUNT		                (3)
#define MAX_R_BLOCK_SENDING                 (10)

#ifndef ESESTATUS
#define ESESTATUS                           uint16_t        /* Return values */
#endif
#define ESESTATUS_SUCCESS	                (0x0000)
#define ESESTATUS_OK                        (ESESTATUS_SUCCESS)

/* Feature not supported */
#define ESESTATUS_FEATURE_NOT_SUPPORTED     (0x0033)

/* Status Return by HAL */
#define ESESTATUS_HAL_MALLOC_FAIL		    (0x0090)
#define ESESTATUS_HAL_INVALID_PARAM		    (0x0091)
#define ESESTATUS_HAL_RESPONSE_INCORRECT	(0x0092)

/* Status Return by spi_protocol */
/* Critical : exit the application */
#define ESESTATUS_INVALID_DEVICE	        (0x00A0)
#define ESESTATUS_DEVICE_ERROR		        (0x00A1)

/* user mistake : exit the application */
#define ESESTATUS_INVALID_DATA		        (0x00A2)
#define ESESTATUS_INVALID_INPUT_PARAM       (0x00A6)
#define ESESTATUS_INVALID_SBLOCK_CNTL_INFO	(0x00A7)

/* Critical : Need to recover the interface */
#define ESESTATUS_BWT_TIMEOUT		        (0x00B0)
#define ESESTATUS_RECEIVE_ERROR		        (0x00B1)
#define ESESTATUS_R_BLOCK_MAX		        (0x00B2)
#define ESESTATUS_CRITICAL                      (0x00B3)
#define ESESTATUS_INNER_LOOP_MAX                (0x00B4)

/* Flow error */
#define ESESTATUS_NEED_RESTRANSMIT	        (0x00C0)
#define ESESTATUS_ESE_LONG_PROCESSING	    (0x00C1)
#define ESESTATUS_T1_PROTOCOL_ERROR	        (0x00C2)

/* Status used internally */
#define ESESTATUS_POLLING_TIME_OUT	        (0x00D0)

/* ESE open fail */
#define ESESTATUS_FAILED            		(0x00FF)

typedef struct spiDev_Config {
    char devName[64];
} spiDev_Config_t, *p_spiDev_Config_t;

#endif /* __SPI_COMMON_H__ */
