315fee20f88f8091f14b0b9ddfb3abcd174fffaf
[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                         int (*set_speed)(struct rfid_asic_handle *h,
55                                          unsigned int speed);
56                 } iso14443a;
57                 struct {
58                         int (*init)(struct rfid_asic_handle *h);
59                 } iso14443b;
60                 struct {
61                         int (*init)(struct rfid_asic_handle *h);
62                 } iso15693;
63                 struct {
64                         int (*setkey)(struct rfid_asic_handle *h,
65                                       const unsigned char *key);
66                         int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd, 
67                                     u_int32_t serno, u_int8_t block);
68                 } mifare_classic;
69         } fn;
70 };
71
72 struct rc632_transport_handle {
73 };
74
75 /* A handle to a specific RC632 chip */
76 struct rfid_asic_rc632_handle {
77         struct rc632_transport_handle th;
78 };
79
80 #if 0
81 int 
82 rc632_reg_write(struct rfid_asic_handle *handle,
83                 u_int8_t reg,
84                 u_int8_t val);
85
86 int 
87 rc632_reg_read(struct rfid_asic_handle *handle,
88                u_int8_t reg,
89                u_int8_t *val);
90 int 
91 rc632_fifo_write(struct rfid_asic_handle *handle,
92                  u_int8_t len,
93                  const u_int32_t *buf,
94                  u_int8_t flags);
95
96 int 
97 rc632_fifo_read(struct rfid_asic_handle *handle,
98                 u_int8_t len,
99                 u_int8_t *buf);
100
101 int
102 rc632_set_bits(struct rfid_asic_handle *handle, u_int8_t reg,
103                 u_int82_t val);
104
105 int 
106 rc632_clear_bits(struct rfid_asic_handle *handle, u_int32_t reg,
107                  u_int32_t val);
108
109
110 int 
111 rc632_turn_on_rf(struct rfid_asic_handle *handle);
112
113
114 int 
115 rc632_turn_off_rf(struct rfid_asic_handle *handle);
116
117 int
118 rc632_power_up(struct rfid_asic_handle *handle);
119
120 int
121 rc632_power_down(struct rfid_asic_handle *handle);
122
123
124 int
125 rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time);
126
127 int
128 rc632_transmit(struct rfid_asic_handle *handle,
129                 const u_int32_t *buf,
130                 u_int32_t len,
131                 u_int64_t timeout);
132
133 int
134 rc632_transcieve(struct rfid_asic_handle *handle,
135                  const u_int32_t *tx_buf,
136                  u_int32_t tx_len,
137                  u_int32_t *rx_buf,
138                  u_int32_t *rx_len,
139                  unsigned int timer,
140                  unsigned int toggle);
141
142 int
143 rc632_read_eeprom(struct rfid_asic_handle *handle);
144
145
146 int
147 rc632_calc_crc16_from(struct rfid_asic_handle *handle);
148
149 int
150 rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf);
151
152
153 struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
154
155
156 extern struct rfid_asic rc632;
157 #endif
158
159 #endif