libnfc/libnfc/drivers/pn533_usb.c
Romain Tartiere cd53efb038 Enforce ISO C conformance about empty files.
ISO C forbids empty source files.  Instead of compiling possibly empty source
files depending on the compiler parameters, only compile required files to
build the library as requested at the ./configure stage.

Windows users (and more precisely non-autotools users), you may have to update
whatever you use to build the libnfc to fit your needs.  The Makefile shipped
in the windows directory compiles all drivers as it is written so you should
not notice any difference, but if you don't use _that_ makefile, then you will
have to do some adjustment.

For now, keep the defines in CFLAGS just in case.  Planned for removal in circa
one week.

While here, pet `./configure` output (--help format and summary).
2010-07-31 13:21:56 +00:00

71 lines
1.9 KiB
C

/*-
* Public platform independent Near Field Communication (NFC) library
*
* Copyright (C) 2009, Roel Verdult
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file pn533_usb.c
* @brief Driver for PN533 chip using USB
*/
/*
Thanks to d18c7db and Okko for example code
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#include <stdlib.h>
#include "../drivers.h"
#include <nfc/nfc-messages.h>
nfc_device_desc_t * pn533_usb_pick_device (void)
{
nfc_device_desc_t *pndd;
if ((pndd = malloc (sizeof (*pndd)))) {
size_t szN;
if (!pn533_usb_list_devices (pndd, 1, &szN)) {
DBG("%s", "pn533_usb_list_devices failed");
return NULL;
}
if (szN == 0) {
DBG("%s", "No device found");
return NULL;
}
}
return pndd;
}
bool pn533_usb_list_devices(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound)
{
// array of {vendor,product} pairs for USB devices
usb_candidate_t candidates[]= {{0x04CC,0x2533},{0x04E6,0x5591}};
return pn53x_usb_list_devices(&pnddDevices[0], szDevices, pszDeviceFound, &candidates[0], sizeof(candidates) / sizeof(usb_candidate_t),PN533_USB_DRIVER_NAME);
}
nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
{
return pn53x_usb_connect(pndd, pndd->acDevice, NC_PN533);
}