- enhance openpcd in-firmware driver stubs
- fix 15693 segfaults with cm5121 and openpcd (15693 is not working yet!)
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1904
e0336214-984f-0b4b-a45f-
81c69e1f0ede
/* system / environment specific defines */
/* system / environment specific defines */
+/* build for openpcd firmware */
//#define LIBRFID_FIRMWARE
//#define LIBRFID_FIRMWARE
+/* build without dynamic allocations */
+#define LIBRFID_STATIC
+
-#ifndef LIBRFID_FIRMWARE
/* If we're not doing a firmware compile, then we just use the regular
* malloc()/free() functions as expected */
/* If we're not doing a firmware compile, then we just use the regular
* malloc()/free() functions as expected */
#define malloc_reader_handle(x) &rfid_rh
#define free_reader_handle(x) EMPTY_STATEMENT
#define malloc_reader_handle(x) &rfid_rh
#define free_reader_handle(x) EMPTY_STATEMENT
-#endif /* LIBRFID_FIRMWARE */
+#endif /* LIBRFID_STATIC */
level exchange and does fully automatic initialization.
*/
level exchange and does fully automatic initialization.
*/
+#include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
*/
#endif /*TEST*/
#endif /*HAVE_LIBUSB*/
*/
#endif /*TEST*/
#endif /*HAVE_LIBUSB*/
+
+#endif /* LIBRFID_FIRMWARE */
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
+#include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
#include <librfid/rfid_asic.h>
#include "ccid-driver.h"
#include <librfid/rfid_asic.h>
#include "ccid-driver.h"
+
+#endif /* LIBRFID_FIRMWARE */
#include <librfid/rfid_protocol_mifare_ul.h>
#include <librfid/rfid_protocol_mifare_classic.h>
#include <librfid/rfid_protocol_mifare_ul.h>
#include <librfid/rfid_protocol_mifare_classic.h>
struct rfid_asic_handle rfid_ah;
struct rfid_layer2_handle rfid_l2h;
struct rfid_protocol_handle rfid_ph;
struct rfid_asic_handle rfid_ah;
struct rfid_layer2_handle rfid_l2h;
struct rfid_protocol_handle rfid_ph;
+
+static int
+iso15693_anticol(struct rfid_layer2_handle *handle)
+{
+ return -1;
+}
+
static struct rfid_layer2_handle *
iso15693_init(struct rfid_reader_handle *rh)
{
static struct rfid_layer2_handle *
iso15693_init(struct rfid_reader_handle *rh)
{
h->l2 = &rfid_layer2_iso15693;
h->rh = rh;
h->priv.iso15693.state = ISO15693_STATE_NONE;
h->l2 = &rfid_layer2_iso15693;
h->rh = rh;
h->priv.iso15693.state = ISO15693_STATE_NONE;
ret = h->rh->reader->iso15693.init(h->rh);
if (ret < 0) {
free_layer2_handle(h);
ret = h->rh->reader->iso15693.init(h->rh);
if (ret < 0) {
free_layer2_handle(h);
.name = "ISO 15693",
.fn = {
.init = &iso15693_init,
.name = "ISO 15693",
.fn = {
.init = &iso15693_init,
- //.open = &iso15693_anticol,
+ .open = &iso15693_anticol,
//.transceive = &iso15693_transceive,
//.close = &iso14443a_hlta,
.fini = &iso15693_fini,
//.transceive = &iso15693_transceive,
//.close = &iso14443a_hlta,
.fini = &iso15693_fini,
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-#ifndef LIBRFID_FIRMWARE
-
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <librfid/rfid.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <librfid/rfid.h>
+
+#ifndef LIBRFID_FIRMWARE
+
#include <librfid/rfid_reader.h>
#include <librfid/rfid_asic.h>
#include <librfid/rfid_asic_rc632.h>
#include <librfid/rfid_reader.h>
#include <librfid/rfid_asic.h>
#include <librfid/rfid_asic_rc632.h>
.iso14443b = {
.init = &cm5121_14443b_init,
},
.iso14443b = {
.init = &cm5121_14443b_init,
},
+ .iso15693 = {
+ .init = &cm5121_15693_init,
+ },
.mifare_classic = {
.setkey = &cm5121_mifare_setkey,
.auth = &cm5121_mifare_auth,
.mifare_classic = {
.setkey = &cm5121_mifare_setkey,
.auth = &cm5121_mifare_auth,
static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
unsigned char reg, unsigned char value)
{
static int openpcd_reg_write(struct rfid_asic_transport_handle *rath,
unsigned char reg, unsigned char value)
{
+ return rc632_reg_write(rath, reg, value);
}
static int openpcd_reg_read(struct rfid_asic_transport_handle *rath,
unsigned char reg,
unsigned char *value)
{
}
static int openpcd_reg_read(struct rfid_asic_transport_handle *rath,
unsigned char reg,
unsigned char *value)
{
+ return rc632_reg_write(rath, reg, value);
unsigned char num_bytes,
unsigned char *buf)
{
unsigned char num_bytes,
unsigned char *buf)
{
+ return rc632_reg_write(rath, num_bytes, buf);
}
static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
}
static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath,
const unsigned char *bytes,
unsigned char flags)
{
const unsigned char *bytes,
unsigned char flags)
{
+ return rc632_fifo_write(rath, len, bytes, flags);
}
const struct rfid_asic_transport openpcd_rat = {
}
const struct rfid_asic_transport openpcd_rat = {
snd_hdr = (struct openpcd_hdr *)snd_buf;
rcv_hdr = (struct openpcd_hdr *)rcv_buf;
snd_hdr = (struct openpcd_hdr *)snd_buf;
rcv_hdr = (struct openpcd_hdr *)rcv_buf;
+#ifndef LIBRFID_FIRMWARE
usb_init();
if (usb_find_busses() < 0)
return NULL;
usb_init();
if (usb_find_busses() < 0)
return NULL;
usb_close(hdl);
return NULL;
}
usb_close(hdl);
return NULL;
}
rh = malloc_reader_handle(sizeof(*rh));
if (!rh)
rh = malloc_reader_handle(sizeof(*rh));
if (!rh)
free_rat_handle(rath);
free_reader_handle(rh);
free_rat_handle(rath);
free_reader_handle(rh);
+#ifndef LIBRFID_FIRMWARE
}
const struct rfid_reader rfid_reader_openpcd = {
}
const struct rfid_reader rfid_reader_openpcd = {
.iso14443b = {
.init = &openpcd_14443b_init,
},
.iso14443b = {
.init = &openpcd_14443b_init,
},
+ .iso15693 = {
+ .init = &openpcd_15693_init,
+ },
.mifare_classic = {
.setkey = &openpcd_mifare_setkey,
.auth = &openpcd_mifare_auth,
.mifare_classic = {
.setkey = &openpcd_mifare_setkey,
.auth = &openpcd_mifare_auth,