2 /* Philips/NXP I*Code implementation, PCD side.
4 * (C) 2005-2008 by Harald Welte <laforge@gnumonks.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28 #include <librfid/rfid.h>
29 #include <librfid/rfid_protocol.h>
30 #include <librfid/rfid_layer2.h>
31 #include <librfid/rfid_layer2_icode1.h>
32 #include <librfid/rfid_protocol_icode.h>
35 icode_read(struct rfid_protocol_handle *ph, unsigned int page,
36 unsigned char *rx_data, unsigned int *rx_len)
38 unsigned char rx_buf[16];
39 unsigned int real_rx_len = sizeof(rx_buf);
48 icode_write(struct rfid_protocol_handle *ph, unsigned int page,
49 unsigned char *tx_data, unsigned int tx_len)
54 unsigned int rx_len = sizeof(rx);
61 icode_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
65 unsigned int *size = optval;
68 case RFID_OPT_PROTO_SIZE:
70 /* we have to return the size in bytes, not bits */
71 /* FIXME: implement this */
80 static struct rfid_protocol_handle *
81 icode_init(struct rfid_layer2_handle *l2h)
83 struct rfid_protocol_handle *ph;
85 int uid_len = sizeof(uid);
87 if (l2h->l2->id != RFID_LAYER2_ICODE1)
90 /* According to "SCBU002 - November 2005 */
91 rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID,
93 if (uid[5] != 0xe0 || uid[4] != 0x07)
95 if (l2h->uid_len != 6)
98 ph = malloc_protocol_handle(sizeof(struct rfid_protocol_handle));
102 static int icode_fini(struct rfid_protocol_handle *ph)
104 free_protocol_handle(ph);
108 const struct rfid_protocol rfid_protocol_icode = {
109 .id = RFID_PROTOCOL_ICODE_SLI,
110 .name = "I*Code SLI",
114 .write = &icode_write,
116 .getopt = &icode_getopt,
120 /* Functions below are not (yet? covered in the generic librfid api */