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>
8 #include <librfid/rfid_layer2.h>
10 struct rfid_asic_rc632_transport {
12 int (*reg_write)(struct rfid_asic_transport_handle *rath,
15 int (*reg_read)(struct rfid_asic_transport_handle *rath,
18 int (*fifo_write)(struct rfid_asic_transport_handle *rath,
22 int (*fifo_read)(struct rfid_asic_transport_handle *rath,
28 struct rfid_asic_handle;
30 struct iso14443a_atqa;
31 struct iso14443a_anticol_cmd;
32 struct iso15693_anticol_cmd;
34 struct rfid_asic_rc632 {
36 int (*power)(struct rfid_asic_handle *h, int on);
37 int (*rf_power)(struct rfid_asic_handle *h, int on);
38 int (*init)(struct rfid_asic_handle *h, enum rfid_layer2_id);
39 int (*transceive)(struct rfid_asic_handle *h,
41 const u_int8_t *tx_buf,
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 (*transceive_ac)(struct rfid_asic_handle *h,
60 const struct iso15693_anticol_cmd *acf,
62 struct iso15693_anticol_resp *resp,
63 unsigned int *rx_len, char *bit_of_col);
66 int (*setkey)(struct rfid_asic_handle *h,
67 const unsigned char *key);
68 int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd,
69 u_int32_t serno, u_int8_t block);
74 struct rc632_transport_handle {
77 /* A handle to a specific RC632 chip */
78 struct rfid_asic_rc632_handle {
79 struct rc632_transport_handle th;
82 struct rfid_asic_rc632_impl_proto {
83 u_int8_t mod_conductance;
84 u_int8_t cw_conductance;
89 struct rfid_asic_rc632_impl {
90 u_int32_t mru; /* maximum receive unit (PICC->PCD) */
91 u_int32_t mtu; /* maximum transmit unit (PCD->PICC) */
92 //struct rfid_asic_rc632_impl_proto proto[NUM_RFID_PROTOCOLS];
95 extern struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
96 extern void rc632_close(struct rfid_asic_handle *h);
99 /* register decoding inlines... */
100 #define DEBUGP_ERROR_FLAG(value) do {DEBUGP("error_flag: 0x%0.2x",value); \
101 if (value & RC632_ERR_FLAG_CRC_ERR ) \
103 if (value & RC632_ERR_FLAG_COL_ERR ) \
105 if (value & RC632_ERR_FLAG_FRAMING_ERR ) \
106 DEBUGPC(", FRAMING"); \
107 if (value & RC632_ERR_FLAG_PARITY_ERR) \
108 DEBUGPC(", PARITY"); \
109 if (value & RC632_ERR_FLAG_KEY_ERR ) \
111 if (value & RC632_ERR_FLAG_ACCESS_ERR ) \
112 DEBUGPC(", ACCESS"); \
113 DEBUGPC("\n");} while (0);
115 #define DEBUGP_STATUS_FLAG(foo) do {\
116 DEBUGP("status_flag: 0x%0.2x",foo); \
117 if (foo & RC632_STAT_ERR ) \
119 if (foo & RC632_STAT_HIALERT ) \
121 if (foo & RC632_STAT_IRQ ) \
123 if (foo & RC632_STAT_LOALERT ) \
125 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_AWAITINGRX ) \
126 DEBUGPC(", mAwaitingRX"); \
127 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_GOTORX ) \
128 DEBUGPC(", mGotoRX"); \
129 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_IDLE ) \
130 DEBUGPC(", mIdle"); \
131 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_PREPARERX ) \
132 DEBUGPC(", mPrepareRX"); \
133 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_RECV ) \
135 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXDATA ) \
136 DEBUGPC(", mTXData"); \
137 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXEOF ) \
138 DEBUGPC(", mTXeof"); \
139 if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXSOF ) \
140 DEBUGPC(", mTXsof"); \
141 DEBUGPC("\n"); } while (0);
143 #define DEBUGP_INTERRUPT_FLAG(foo) do {\
144 DEBUGP("interrupt_flag: 0x%0.2x",foo); \
145 if (foo & RC632_INT_HIALERT) \
147 if (foo & RC632_INT_LOALERT) \
149 if (foo & RC632_INT_IDLE) \
151 if (foo & RC632_INT_RX) \
153 if (foo & RC632_INT_TX) \
155 if (foo & RC632_INT_TIMER) \
156 DEBUGPC(", TIMER"); \
157 if (foo & RC632_INT_SET) \
159 DEBUGPC("\n"); } while (0);