8dc7860c9ba8eed943e64764b923b602544186aa
[librfid] / include / librfid / rfid_reader.h
1 #ifndef _RFID_READER_H
2 #define _RFID_READER_H
3
4 #include <librfid/rfid_asic.h>
5 #include <librfid/rfid_layer2_iso14443a.h>
6 #include <librfid/rfid_layer2_iso15693.h>
7
8 struct rfid_reader_handle;
9
10 struct rfid_reader {
11         char *name;
12         unsigned int id;
13         unsigned int l2_supported;
14         unsigned int proto_supported;
15
16         int (*get_api_version)(
17             struct rfid_reader_handle *h,
18             u_int8_t *version);
19
20         int (*get_environment)(
21             struct rfid_reader_handle *rh,
22             unsigned char num_bytes,
23             unsigned char *buf);
24
25         int (*set_environment)(
26             struct rfid_reader_handle *rh,
27             unsigned char num_bytes,
28             const unsigned char *buf);
29
30         int (*reset)(struct rfid_reader_handle *h);
31
32         int (*transceive)(struct rfid_reader_handle *h,
33                           enum rfid_frametype frametype,
34                           const unsigned char *tx_buf, unsigned int tx_len,
35                           unsigned char *rx_buf, unsigned int *rx_len,
36                           u_int64_t timeout, unsigned int flags);
37         struct rfid_reader_handle * (*open)(void *data);
38         void (*close)(struct rfid_reader_handle *h);
39         int (*rf_power)(struct rfid_reader_handle *h, int on);
40
41         struct rfid_14443a_reader {
42                 int (*init)(struct rfid_reader_handle *h);
43                 int (*transceive_sf)(struct rfid_reader_handle *h,
44                                      unsigned char cmd,
45                                      struct iso14443a_atqa *atqa);
46                 int (*transceive_acf)(struct rfid_reader_handle *h,
47                                       struct iso14443a_anticol_cmd *cmd,
48                                       unsigned int *bit_of_col);
49                 int (*set_speed)(struct rfid_reader_handle *h,
50                                  unsigned int tx,
51                                  unsigned int speed);
52                 unsigned int speed;
53         } iso14443a;
54         struct rfid_14443b_reader {
55                 int (*init)(struct rfid_reader_handle *rh);
56                 unsigned int speed;
57         } iso14443b;
58         struct rfid_15693_reader {
59                 int (*init)(struct rfid_reader_handle *rh);
60                 int (*transceive_ac)(struct rfid_reader_handle *h,
61                                      struct iso15693_anticol_cmd *acf,
62                                      unsigned char *uuid,
63                                      char *bit_of_col);
64         } iso15693;
65         struct rfid_mifare_classic_reader {
66                 int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key);
67                 int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd,
68                             u_int32_t serno, u_int8_t block);
69         } mifare_classic;
70 };
71
72 enum rfid_reader_id {
73         RFID_READER_CM5121,
74         RFID_READER_PEGODA,
75         RFID_READER_OPENPCD,
76         RFID_READER_SPIDEV,
77 };
78
79 struct rfid_reader_handle {
80         struct rfid_asic_handle *ah;
81
82         union {
83
84         } priv;
85         const struct rfid_reader *reader;
86 };
87
88 extern struct rfid_reader_handle *
89 rfid_reader_open(void *data, unsigned int id);
90
91 extern void rfid_reader_close(struct rfid_reader_handle *rh);
92 #endif