- fix mifare write support
[librfid] / 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 (*transceive)(struct rfid_asic_handle *h,
39                                   enum rfid_frametype,
40                                   const u_int8_t *tx_buf,
41                                   unsigned int tx_len,
42                                   u_int8_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 (*transceive_sf)(struct rfid_asic_handle *h,
49                                              u_int8_t cmd,
50                                              struct iso14443a_atqa *atqa);
51                         int (*transceive_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 struct rfid_asic_rc632_impl_proto {
82         u_int8_t mod_conductance;
83         u_int8_t cw_conductance;
84         u_int8_t bitphase;
85         u_int8_t threshold;
86 };
87
88 struct rfid_asic_rc632_impl {
89         u_int32_t mru;          /* maximum receive unit (PICC->PCD) */
90         u_int32_t mtu;          /* maximum transmit unit (PCD->PICC) */
91         //struct rfid_asic_rc632_impl_proto proto[NUM_RFID_PROTOCOLS];
92 };
93
94 extern struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
95 extern void rc632_close(struct rfid_asic_handle *h);
96
97 #endif