1 #ifndef _RFID_ASIC_RC632_H
2 #define _RFID_ASIC_RC632_H
4 struct rfid_asic_transport_handle;
6 #include <librfid/rfid.h>
7 #include <librfid/rfid_asic.h>
9 struct rfid_asic_rc632_transport {
11 int (*reg_write)(struct rfid_asic_transport_handle *rath,
14 int (*reg_read)(struct rfid_asic_transport_handle *rath,
17 int (*fifo_write)(struct rfid_asic_transport_handle *rath,
21 int (*fifo_read)(struct rfid_asic_transport_handle *rath,
27 struct rfid_asic_handle;
29 struct iso14443a_atqa;
30 struct iso14443a_anticol_cmd;
31 struct iso15693_anticol_cmd;
33 struct rfid_asic_rc632 {
35 int (*power_up)(struct rfid_asic_handle *h);
36 int (*power_down)(struct rfid_asic_handle *h);
37 int (*rf_power)(struct rfid_asic_handle *h, int on);
38 int (*transceive)(struct rfid_asic_handle *h,
40 const u_int8_t *tx_buf,
47 int (*init)(struct rfid_asic_handle *h);
48 int (*transceive_sf)(struct rfid_asic_handle *h,
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,
59 int (*init)(struct rfid_asic_handle *h);
62 int (*init)(struct rfid_asic_handle *h);
63 int (*transceive_ac)(struct rfid_asic_handle *h,
64 struct iso15693_anticol_cmd *acf,
69 int (*setkey)(struct rfid_asic_handle *h,
70 const unsigned char *key);
71 int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd,
72 u_int32_t serno, u_int8_t block);
77 struct rc632_transport_handle {
80 /* A handle to a specific RC632 chip */
81 struct rfid_asic_rc632_handle {
82 struct rc632_transport_handle th;
85 struct rfid_asic_rc632_impl_proto {
86 u_int8_t mod_conductance;
87 u_int8_t cw_conductance;
92 struct rfid_asic_rc632_impl {
93 u_int32_t mru; /* maximum receive unit (PICC->PCD) */
94 u_int32_t mtu; /* maximum transmit unit (PCD->PICC) */
95 //struct rfid_asic_rc632_impl_proto proto[NUM_RFID_PROTOCOLS];
98 extern struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
99 extern void rc632_close(struct rfid_asic_handle *h);
102 /* register decoding inlines... */
103 #define DEBUGP_ERROR_FLAG(value) do {DEBUGP("error_flag: 0x%0.2x",value); \
104 if (value & RC632_ERR_FLAG_CRC_ERR ) \
106 if (value & RC632_ERR_FLAG_COL_ERR ) \
108 if (value & RC632_ERR_FLAG_FRAMING_ERR ) \
109 DEBUGPC(", FRAMING"); \
110 if (value & RC632_ERR_FLAG_PARITY_ERR) \
111 DEBUGPC(", PARITY"); \
112 if (value & RC632_ERR_FLAG_KEY_ERR ) \
114 if (value & RC632_ERR_FLAG_ACCESS_ERR ) \
115 DEBUGPC(", ACCESS"); \
116 DEBUGPC("\n");} while (0);
118 #define DEBUGP_STATUS_FLAG(foo) do {\
119 DEBUGP("status_flag: 0x%0.2x",foo); \
120 if (foo & RC632_STAT_ERR ) \
122 if (foo & RC632_STAT_HIALERT ) \
124 if (foo & RC632_STAT_IRQ ) \
126 if (foo & RC632_STAT_LOALERT ) \
128 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_AWAITINGRX ) \
129 DEBUGPC(", mAwaitingRX"); \
130 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_GOTORX ) \
131 DEBUGPC(", mGotoRX"); \
132 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_IDLE ) \
133 DEBUGPC(", mIdle"); \
134 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_PREPARERX ) \
135 DEBUGPC(", mPrepareRX"); \
136 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_RECV ) \
138 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXDATA ) \
139 DEBUGPC(", mTXData"); \
140 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXEOF ) \
141 DEBUGPC(", mTXeof"); \
142 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXSOF ) \
143 DEBUGPC(", mTXsof"); \
144 DEBUGPC("\n"); } while (0);
146 #define DEBUGP_INTERRUPT_FLAG(foo) do {\
147 DEBUGP("interrupt_flag: 0x%0.2x",foo); \
148 if (foo & RC632_INT_HIALERT) \
150 if (foo & RC632_INT_LOALERT) \
152 if (foo & RC632_INT_IDLE) \
154 if (foo & RC632_INT_RX) \
156 if (foo & RC632_INT_TX) \
158 if (foo & RC632_INT_TIMER) \
159 DEBUGPC(", TIMER"); \
160 if (foo & RC632_INT_SET) \
162 DEBUGPC("\n"); } while (0);