chen
2024-07-29 13ee763a011697633a072a74a25c3eee9f40bb4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _7816_3_T1_SEAPI_H_
#define _7816_3_T1_SEAPI_H_
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <stdint.h>
#include <stdbool.h>
 
#include "T1.h"
 
typedef enum
{
    // All wired transaction
    ESE_MODE_NORMAL = 0,
    // nfcc FW/BL download used
    ESE_MODE_NFCC_DL,
    // eSE COS download used
    ESE_MODE_ESE_DL,
} SE_init_mode;
 
typedef struct
{
    ESESTATUS ESE_lib_status;
 
    bool is_read_done;
    uint32_t max_write_retry_cnt;
    uint32_t write_retry_time;
    uint32_t max_read_retry_cnt;
    uint32_t read_retry_time;
 
    uint32_t max_recovery_cnt;
 
    uint8_t max_blk_retry_cnt;
 
    uint16_t max_wtx_cnt;
 
    bool is_resync_recovery_flag;
 
    uint16_t max_IFSD;
 
    uint16_t max_IFSC;
 
    bool is_T1_ext_hdr_len;
    uint8_t seq_num_device;
    uint8_t seq_num_card;
    bool is_seq_num_dr;
    T1_transmit_receive_state next_T1_state;
 
    /** T1 **/
    T1_params *p_T1_params;
} SE_context;
 
ESESTATUS se_open(SE_init_mode init_mode);
ESESTATUS se_init(SE_init_mode init_mode);
 
ESESTATUS se_transmit_receive(SE_data *p_cmd, SE_data *p_resp);
 
ESESTATUS se_deinit(void);
ESESTATUS se_status(void);
ESESTATUS se_close(void);
 
extern SE_context g_ese_ctx;
 
/*******************************************************************************
 * @Function         tm_main
 * @Parameters       None.
 * @Returns          0 - fail;  other never return.
 ******************************************************************************/
int tm_main(void);
 
uint16_t passthrough_apdu_to_t1(uint8_t *cmd_buf, uint16_t cmd_len, uint32_t *resp_buf_addr, uint16_t *resp_len);
uint16_t transmit_only_apdu_to_t1(uint8_t *cmd_buf, uint16_t cmd_len);
uint16_t receive_only_resp_from_t1(uint32_t *resp_buf_addr, uint16_t *resp_len);
ESESTATUS se_transmit_only(SE_data *p_cmd);
ESESTATUS se_receive_only(SE_data *p_resp);
 
#ifdef __cplusplus
}
#endif
 
#endif /* _STESEAPI_H_ */