use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion...
[librfid] / include / rfid / rfid_asic_rc632.h
1 #ifndef _RFID_ASIC_RC632_H
2 #define _RFID_ASIC_RC632_H
3
4 struct rfid_asic_transport_handle;
5
6 struct rfid_asic_rc632_transport {
7         struct {
8                 int (*reg_write)(struct rfid_asic_transport_handle *rath,
9                                  unsigned char reg,
10                                  unsigned char value);
11                 int (*reg_read)(struct rfid_asic_transport_handle *rath,
12                                 unsigned char reg,
13                                 unsigned char *value);
14                 int (*fifo_write)(struct rfid_asic_transport_handle *rath,
15                                   unsigned char len,
16                                   const unsigned char *buf,
17                                   unsigned char flags);
18                 int (*fifo_read)(struct rfid_asic_transport_handle *rath,
19                                  unsigned char len,
20                                  unsigned char *buf);
21         } fn;
22 };
23
24 struct rfid_asic_handle;
25
26 struct iso14443a_atqa;
27 struct iso14443a_anticol_cmd;
28
29 struct rfid_asic_rc632 {
30         struct {
31                 int (*power_up)(struct rfid_asic_handle *h);
32                 int (*power_down)(struct rfid_asic_handle *h);
33                 int (*turn_on_rf)(struct rfid_asic_handle *h);
34                 int (*turn_off_rf)(struct rfid_asic_handle *h);
35                 int (*transcieve)(struct rfid_asic_handle *h,
36                                   const unsigned char *tx_buf,
37                                   unsigned int tx_len,
38                                   unsigned char *rx_buf,
39                                   unsigned int *rx_len,
40                                   u_int64_t timeout,
41                                   unsigned int flags);
42                 struct {
43                         int (*init)(struct rfid_asic_handle *h);
44                         int (*transcieve_sf)(struct rfid_asic_handle *h,
45                                              unsigned char cmd,
46                                              struct iso14443a_atqa *atqa);
47                         int (*transcieve_acf)(struct rfid_asic_handle *h,
48                                               struct iso14443a_anticol_cmd *cmd,
49                                               unsigned int *bit_of_col);
50                 } iso14443a;
51                 struct {
52                         int (*init)(struct rfid_asic_handle *h);
53                 } iso14443b;
54                 struct {
55                         int (*init)(struct rfid_asic_handle *h);
56                 } iso15693;
57         } fn;
58 };
59
60 struct rc632_transport_handle {
61 };
62
63 /* A handle to a specific RC632 chip */
64 struct rfid_asic_rc632_handle {
65         struct rc632_transport_handle th;
66 };
67
68 int 
69 rc632_reg_write(struct rfid_asic_handle *handle,
70                 unsigned char reg,
71                 unsigned char val);
72
73 int 
74 rc632_reg_read(struct rfid_asic_handle *handle,
75                unsigned char reg,
76                unsigned char *val);
77 int 
78 rc632_fifo_write(struct rfid_asic_handle *handle,
79                  unsigned char len,
80                  const unsigned char *buf,
81                  unsigned char flags);
82
83 int 
84 rc632_fifo_read(struct rfid_asic_handle *handle,
85                 unsigned char len,
86                 unsigned char *buf);
87
88 int
89 rc632_set_bits(struct rfid_asic_handle *handle, unsigned char reg,
90                 unsigned char val);
91
92 int 
93 rc632_clear_bits(struct rfid_asic_handle *handle, unsigned char reg,
94                  unsigned char val);
95
96
97 int 
98 rc632_turn_on_rf(struct rfid_asic_handle *handle);
99
100
101 int 
102 rc632_turn_off_rf(struct rfid_asic_handle *handle);
103
104 int
105 rc632_power_up(struct rfid_asic_handle *handle);
106
107 int
108 rc632_power_down(struct rfid_asic_handle *handle);
109
110
111 int
112 rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time);
113
114 int
115 rc632_transmit(struct rfid_asic_handle *handle,
116                 const unsigned char *buf,
117                 unsigned char len,
118                 u_int64_t timeout);
119
120 int
121 rc632_transcieve(struct rfid_asic_handle *handle,
122                  const unsigned char *tx_buf,
123                  unsigned char tx_len,
124                  unsigned char *rx_buf,
125                  unsigned char *rx_len,
126                  unsigned int timer,
127                  unsigned int toggle);
128
129 int
130 rc632_read_eeprom(struct rfid_asic_handle *handle);
131
132
133 int
134 rc632_calc_crc16_from(struct rfid_asic_handle *handle);
135
136 int
137 rc632_register_dump(struct rfid_asic_handle *handle, unsigned char *buf);
138
139
140 struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
141
142
143 extern struct rfid_asic rc632;
144 #endif