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