494e0449165b2d770dd8a0934d4d997d86f2399b
[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 #include <sys/types.h>
7 #include <rfid/rfid_asic.h>
8
9 struct rfid_asic_rc632_transport {
10         struct {
11                 int (*reg_write)(struct rfid_asic_transport_handle *rath,
12                                  u_int8_t reg,
13                                  u_int8_t value);
14                 int (*reg_read)(struct rfid_asic_transport_handle *rath,
15                                 u_int8_t reg,
16                                 u_int8_t *value);
17                 int (*fifo_write)(struct rfid_asic_transport_handle *rath,
18                                   u_int8_t len,
19                                   const u_int8_t *buf,
20                                   u_int8_t flags);
21                 int (*fifo_read)(struct rfid_asic_transport_handle *rath,
22                                  u_int8_t len,
23                                  u_int8_t *buf);
24         } fn;
25 };
26
27 struct rfid_asic_handle;
28
29 struct iso14443a_atqa;
30 struct iso14443a_anticol_cmd;
31
32 struct rfid_asic_rc632 {
33         struct {
34                 int (*power_up)(struct rfid_asic_handle *h);
35                 int (*power_down)(struct rfid_asic_handle *h);
36                 int (*turn_on_rf)(struct rfid_asic_handle *h);
37                 int (*turn_off_rf)(struct rfid_asic_handle *h);
38                 int (*transcieve)(struct rfid_asic_handle *h,
39                                   enum rfid_frametype,
40                                   const u_int32_t *tx_buf,
41                                   unsigned int tx_len,
42                                   u_int32_t *rx_buf,
43                                   unsigned int *rx_len,
44                                   u_int64_t timeout,
45                                   unsigned int flags);
46                 struct {
47                         int (*init)(struct rfid_asic_handle *h);
48                         int (*transcieve_sf)(struct rfid_asic_handle *h,
49                                              u_int32_t cmd,
50                                              struct iso14443a_atqa *atqa);
51                         int (*transcieve_acf)(struct rfid_asic_handle *h,
52                                               struct iso14443a_anticol_cmd *cmd,
53                                               unsigned int *bit_of_col);
54                 } iso14443a;
55                 struct {
56                         int (*init)(struct rfid_asic_handle *h);
57                 } iso14443b;
58                 struct {
59                         int (*init)(struct rfid_asic_handle *h);
60                 } iso15693;
61                 struct {
62                         int (*setkey)(struct rfid_asic_handle *h,
63                                       const unsigned char *key);
64                         int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd, 
65                                     u_int32_t serno, u_int8_t block);
66                 } mifare_classic;
67         } fn;
68 };
69
70 struct rc632_transport_handle {
71 };
72
73 /* A handle to a specific RC632 chip */
74 struct rfid_asic_rc632_handle {
75         struct rc632_transport_handle th;
76 };
77
78 #if 0
79 int 
80 rc632_reg_write(struct rfid_asic_handle *handle,
81                 u_int8_t reg,
82                 u_int8_t val);
83
84 int 
85 rc632_reg_read(struct rfid_asic_handle *handle,
86                u_int8_t reg,
87                u_int8_t *val);
88 int 
89 rc632_fifo_write(struct rfid_asic_handle *handle,
90                  u_int8_t len,
91                  const u_int32_t *buf,
92                  u_int8_t flags);
93
94 int 
95 rc632_fifo_read(struct rfid_asic_handle *handle,
96                 u_int8_t len,
97                 u_int8_t *buf);
98
99 int
100 rc632_set_bits(struct rfid_asic_handle *handle, u_int8_t reg,
101                 u_int82_t val);
102
103 int 
104 rc632_clear_bits(struct rfid_asic_handle *handle, u_int32_t reg,
105                  u_int32_t val);
106
107
108 int 
109 rc632_turn_on_rf(struct rfid_asic_handle *handle);
110
111
112 int 
113 rc632_turn_off_rf(struct rfid_asic_handle *handle);
114
115 int
116 rc632_power_up(struct rfid_asic_handle *handle);
117
118 int
119 rc632_power_down(struct rfid_asic_handle *handle);
120
121
122 int
123 rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time);
124
125 int
126 rc632_transmit(struct rfid_asic_handle *handle,
127                 const u_int32_t *buf,
128                 u_int32_t len,
129                 u_int64_t timeout);
130
131 int
132 rc632_transcieve(struct rfid_asic_handle *handle,
133                  const u_int32_t *tx_buf,
134                  u_int32_t tx_len,
135                  u_int32_t *rx_buf,
136                  u_int32_t *rx_len,
137                  unsigned int timer,
138                  unsigned int toggle);
139
140 int
141 rc632_read_eeprom(struct rfid_asic_handle *handle);
142
143
144 int
145 rc632_calc_crc16_from(struct rfid_asic_handle *handle);
146
147 int
148 rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf);
149
150
151 struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
152
153
154 extern struct rfid_asic rc632;
155 #endif
156
157 #endif