1 /* Shared/Common functions for all RC632 based readers
3 * (C) 2006-2008 by Harald Welte <laforge@gnumonks.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <librfid/rfid.h>
26 #include <librfid/rfid_reader.h>
27 #include <librfid/rfid_asic.h>
28 #include <librfid/rfid_asic_rc632.h>
29 #include <librfid/rfid_layer2.h>
31 #include "rfid_reader_rc632_common.h"
33 int _rdr_rc632_transceive(struct rfid_reader_handle *rh,
34 enum rfid_frametype frametype,
35 const unsigned char *tx_data, unsigned int tx_len,
36 unsigned char *rx_data, unsigned int *rx_len,
37 u_int64_t timeout, unsigned int flags)
39 return rh->ah->asic->priv.rc632.fn.transceive(rh->ah, frametype,
45 int _rdr_rc632_transceive_sf(struct rfid_reader_handle *rh,
46 unsigned char cmd, struct iso14443a_atqa *atqa)
48 return rh->ah->asic->priv.rc632.fn.iso14443a.transceive_sf(rh->ah,
54 _rdr_rc632_transceive_acf(struct rfid_reader_handle *rh,
55 struct iso14443a_anticol_cmd *cmd,
56 unsigned int *bit_of_col)
58 return rh->ah->asic->priv.rc632.fn.iso14443a.transceive_acf(rh->ah,
63 _rdr_rc632_iso15693_transceive_ac(struct rfid_reader_handle *rh,
64 const struct iso15693_anticol_cmd *acf,
66 struct iso15693_anticol_resp *resp,
67 unsigned int *resp_len, char *bit_of_col)
69 return rh->ah->asic->priv.rc632.fn.iso15693.transceive_ac(
70 rh->ah, acf, acf_len, resp, resp_len,
76 _rdr_rc632_14443a_set_speed(struct rfid_reader_handle *rh,
77 unsigned int tx, unsigned int speed)
81 DEBUGP("setting rate: ");
83 case RFID_14443A_SPEED_106K:
87 case RFID_14443A_SPEED_212K:
91 case RFID_14443A_SPEED_424K:
95 case RFID_14443A_SPEED_848K:
103 return rh->ah->asic->priv.rc632.fn.iso14443a.set_speed(rh->ah,
108 _rdr_rc632_l2_init(struct rfid_reader_handle *rh, enum rfid_layer2_id l2)
110 return rh->ah->asic->priv.rc632.fn.init(rh->ah, l2);
114 _rdr_rc632_mifare_setkey(struct rfid_reader_handle *rh, const u_int8_t *key)
116 return rh->ah->asic->priv.rc632.fn.mifare_classic.setkey(rh->ah, key);
120 _rdr_rc632_mifare_auth(struct rfid_reader_handle *rh, u_int8_t cmd,
121 u_int32_t serno, u_int8_t block)
123 return rh->ah->asic->priv.rc632.fn.mifare_classic.auth(rh->ah,
128 _rdr_rc632_getopt(struct rfid_reader_handle *rh, int optname,
129 void *optval, unsigned int *optlen)
135 _rdr_rc632_setopt(struct rfid_reader_handle *rh, int optname,
136 const void *optval, unsigned int optlen)
138 unsigned int *val = (unsigned int *)optval;
140 if (!optval || optlen < sizeof(*val))
144 case RFID_OPT_RDR_RF_KILL:
146 return rh->ah->asic->priv.rc632.fn.rf_power(rh->ah, 0);
148 return rh->ah->asic->priv.rc632.fn.rf_power(rh->ah, 1);