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