It now compile using Autotools.

This commit is contained in:
Romuald Conty 2009-11-04 10:14:17 +00:00
parent 4a5945e67d
commit 14a9112dea
32 changed files with 193 additions and 192 deletions

View file

@ -0,0 +1,24 @@
# set the include path found by configure
INCLUDES= $(all_includes)
noinst_HEADERS = arygon.h pn532_uart.h
noinst_LTLIBRARIES = libnfcdrivers.la
libnfcdrivers_la_SOURCES = arygon.c pn532_uart.c
libnfcdrivers_la_CFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/buses
libnfcdrivers_la_LIBADD =
if PCSC_LITE_ENABLED
noinst_HEADERS += acr122.h
libnfcdrivers_la_CFLAGS += @LIBPCSCLITE_CFLAGS@ -DHAVE_PCSC_LITE
libnfcdrivers_la_SOURCES += acr122.c
libnfcdrivers_la_LIBADD += @LIBPCSCLITE_LIBS@
endif
if LIBUSB_ENABLED
noinst_HEADERS += pn531.h pn533.h
libnfcdrivers_la_CFLAGS += @LIBUSB_CFLAGS@ -DHAVE_LIBUSB
libnfcdrivers_la_SOURCES += pn531.c pn533.c
libnfcdrivers_la_LIBADD += @LIBUSB_LIBS@
endif
DISTCLEANFILES = Makefile.in

View file

@ -17,11 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_acr122.c
* @file acr122.c
* @brief
*/
#include "dev_acr122.h"
#include "acr122.h"
#include <stdio.h>
#include <stdlib.h>
@ -35,7 +35,6 @@
#include "defines.h"
#include "messages.h"
#include "bitutils.h"
// WINDOWS: #define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE SCARD_CTL_CODE(3500)
#define IOCTL_CCID_ESCAPE_SCARD_CTL_CODE (((0x31) << 16) | ((3500) << 2))
@ -58,7 +57,7 @@ typedef struct {
SCARD_IO_REQUEST ioCard;
} dev_spec_acr122;
dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd)
dev_info* acr122_connect(const nfc_device_desc_t* pndd)
{
char* pacReaders[MAX_DEVICES];
char acList[256+64*MAX_DEVICES];
@ -131,7 +130,7 @@ dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd)
dsa.ioCard.cbPciLength = sizeof(SCARD_IO_REQUEST);
// Retrieve the current firmware version
pcFirmware = dev_acr122_firmware((dev_info*)&dsa);
pcFirmware = acr122_firmware((dev_info*)&dsa);
if (strstr(pcFirmware,FIRMWARE_TEXT) != NULL)
{
// We found a occurence, test if it has the right index
@ -163,7 +162,7 @@ dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd)
return INVALID_DEVICE_INFO;
}
void dev_acr122_disconnect(dev_info* pdi)
void acr122_disconnect(dev_info* pdi)
{
dev_spec_acr122* pdsa = (dev_spec_acr122*)pdi->ds;
SCardDisconnect(pdsa->hCard,SCARD_LEAVE_CARD);
@ -172,7 +171,7 @@ void dev_acr122_disconnect(dev_info* pdi)
free(pdi);
}
bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
byte_t abtRxCmd[5] = { 0xFF,0xC0,0x00,0x00 };
size_t szRxCmdLen = sizeof(abtRxCmd);
@ -234,7 +233,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
return true;
}
char* dev_acr122_firmware(const dev_spec ds)
char* acr122_firmware(const dev_spec ds)
{
byte_t abtGetFw[5] = { 0xFF,0x00,0x48,0x00,0x00 };
uint32_t uiResult;
@ -260,7 +259,7 @@ char* dev_acr122_firmware(const dev_spec ds)
return abtFw;
}
bool dev_acr122_led_red(const dev_spec ds, bool bOn)
bool acr122_led_red(const dev_spec ds, bool bOn)
{
byte_t abtLed[9] = { 0xFF,0x00,0x40,0x05,0x04,0x00,0x00,0x00,0x00 };
dev_spec_acr122* pdsa = (dev_spec_acr122*)ds;

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_acr122.h
* @file acr122.h
* @brief
*/
@ -31,15 +31,15 @@
#include "types.h"
// Functions used by developer to handle connection to this device
dev_info* dev_acr122_connect(const nfc_device_desc_t* pndd);
void dev_acr122_disconnect(dev_info* pdi);
dev_info* acr122_connect(const nfc_device_desc_t* pndd);
void acr122_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
bool acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
// Various additional features this device supports
char* dev_acr122_firmware(const dev_spec ds);
bool dev_acr122_led_red(const dev_spec ds, bool bOn);
char* acr122_firmware(const dev_spec ds);
bool acr122_led_red(const dev_spec ds, bool bOn);
#endif // _LIBNFC_DEV_ACR122_H_

View file

@ -17,14 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_arygon.c
* @file arygon.c
* @brief
*/
#include "dev_arygon.h"
#include "arygon.h"
#include "rs232.h"
#include "bitutils.h"
#include "uart.h"
#include "messages.h"
#ifdef _WIN32
@ -73,7 +72,7 @@
* @note ARYGON-APDB2UA33 (PN532 + ARYGON µC): 9600,n,8,1
*/
dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd)
dev_info* arygon_connect(const nfc_device_desc_t* pndd)
{
uint32_t uiDevNr;
serial_port sp;
@ -95,10 +94,10 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd)
sprintf(acConnect,"%s%d",SERIAL_STRING,uiDevNr);
#endif /* __APPLE__ */
sp = rs232_open(acConnect);
sp = uart_open(acConnect);
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT))
{
rs232_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED);
uart_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED);
break;
}
#ifdef DEBUG
@ -112,12 +111,12 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd)
} else {
DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
strcpy(acConnect,pndd->pcPort);
sp = rs232_open(acConnect);
sp = uart_open(acConnect);
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect);
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect);
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO;
rs232_set_speed(sp, pndd->uiSpeed);
uart_set_speed(sp, pndd->uiSpeed);
}
DBG("Successfully connected to: %s",acConnect);
@ -134,13 +133,13 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd)
return pdi;
}
void dev_arygon_disconnect(dev_info* pdi)
void arygon_disconnect(dev_info* pdi)
{
rs232_close((serial_port)pdi->ds);
uart_close((serial_port)pdi->ds);
free(pdi);
}
bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
byte_t abtTxBuf[BUFFER_LENGTH] = { DEV_ARYGON_PROTOCOL_TAMA, 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
byte_t abtRxBuf[BUFFER_LENGTH];
@ -168,7 +167,7 @@ bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
printf(" TX: ");
print_hex(abtTxBuf,szTxLen+8);
#endif
if (!rs232_send((serial_port)ds,abtTxBuf,szTxLen+8)) {
if (!uart_send((serial_port)ds,abtTxBuf,szTxLen+8)) {
ERR("Unable to transmit data. (TX)");
return false;
}
@ -188,7 +187,7 @@ bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
* For more information, see Issue 23 on development site : http://code.google.com/p/libnfc/issues/detail?id=23
*/
if (!rs232_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) {
if (!uart_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) {
ERR("Unable to receive data. (RX)");
return false;
}

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_arygon.h
* @file arygon.h
* @brief
*/
@ -28,11 +28,11 @@
#include "types.h"
// Functions used by developer to handle connection to this device
dev_info* dev_arygon_connect(const nfc_device_desc_t* pndd);
void dev_arygon_disconnect(dev_info* pdi);
dev_info* arygon_connect(const nfc_device_desc_t* pndd);
void arygon_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
bool arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
#endif // _LIBNFC_DEV_ARYGON_H_

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn531.c
* @file pn531.c
* @brief
*/
@ -32,8 +32,7 @@ Thanks to d18c7db and Okko for example code
#include <string.h>
#include "defines.h"
#include "dev_pn531.h"
#include "bitutils.h"
#include "pn531.h"
#include "messages.h"
#define BUFFER_LENGTH 256
@ -81,7 +80,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn531* pdsp)
}
}
dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd)
dev_info* pn531_connect(const nfc_device_desc_t* pndd)
{
int idvendor = 0x04CC;
int idproduct = 0x0531;
@ -163,7 +162,7 @@ dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd)
return pdi;
}
void dev_pn531_disconnect(dev_info* pdi)
void pn531_disconnect(dev_info* pdi)
{
dev_spec_pn531* pdsp = (dev_spec_pn531*)pdi->ds;
usb_release_interface(pdsp->pudh,0);
@ -172,7 +171,7 @@ void dev_pn531_disconnect(dev_info* pdi)
free(pdi);
}
bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
size_t uiPos = 0;
int ret = 0;

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn531.h
* @file pn531.h
* @brief
*/
@ -31,11 +31,11 @@
#include "types.h"
// Functions used by developer to handle connection to this device
dev_info* dev_pn531_connect(const nfc_device_desc_t* pndd);
void dev_pn531_disconnect(dev_info* pdi);
dev_info* pn531_connect(const nfc_device_desc_t* pndd);
void pn531_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
bool pn531_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
#endif // _LIBNFC_DEV_PN531_H_

View file

@ -17,14 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn532_uart.c
* @file pn532_uart.c
* @brief
*/
#include "dev_pn532_uart.h"
#include "pn532_uart.h"
#include "rs232.h"
#include "bitutils.h"
#include "uart.h"
#include "messages.h"
#ifdef _WIN32
@ -48,7 +47,7 @@
#define SERIAL_DEFAULT_PORT_SPEED 115200
dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd)
dev_info* pn532_uart_connect(const nfc_device_desc_t* pndd)
{
uint32_t uiDevNr;
serial_port sp;
@ -70,10 +69,10 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd)
sprintf(acConnect,"%s%d",SERIAL_STRING,uiDevNr);
#endif /* __APPLE__ */
sp = rs232_open(acConnect);
sp = uart_open(acConnect);
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT))
{
rs232_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED);
uart_set_speed(sp, SERIAL_DEFAULT_PORT_SPEED);
break;
}
#ifdef DEBUG
@ -87,12 +86,12 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd)
} else {
DBG("Connecting to: %s at %d bauds.",pndd->pcPort, pndd->uiSpeed);
strcpy(acConnect,pndd->pcPort);
sp = rs232_open(acConnect);
sp = uart_open(acConnect);
if (sp == INVALID_SERIAL_PORT) ERR("Invalid serial port: %s",acConnect);
if (sp == CLAIMED_SERIAL_PORT) ERR("Serial port already claimed: %s",acConnect);
if ((sp == CLAIMED_SERIAL_PORT) || (sp == INVALID_SERIAL_PORT)) return INVALID_DEVICE_INFO;
rs232_set_speed(sp, pndd->uiSpeed);
uart_set_speed(sp, pndd->uiSpeed);
}
/** @info PN532C106 wakeup. */
/** @todo Put this command in pn53x init process */
@ -100,10 +99,10 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd)
size_t szRxBufLen;
const byte_t pncmd_pn532c106_wakeup[] = { 0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0xFD,0xD4,0x14,0x01,0x17,0x00 };
rs232_send(sp, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup));
uart_send(sp, pncmd_pn532c106_wakeup, sizeof(pncmd_pn532c106_wakeup));
delay_ms(10);
if (!rs232_receive(sp,abtRxBuf,&szRxBufLen)) {
if (!uart_receive(sp,abtRxBuf,&szRxBufLen)) {
ERR("Unable to receive data. (RX)");
return NULL;
}
@ -126,13 +125,13 @@ dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd)
return pdi;
}
void dev_pn532_uart_disconnect(dev_info* pdi)
void pn532_uart_disconnect(dev_info* pdi)
{
rs232_close((serial_port)pdi->ds);
uart_close((serial_port)pdi->ds);
free(pdi);
}
bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
byte_t abtTxBuf[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
byte_t abtRxBuf[BUFFER_LENGTH];
@ -160,7 +159,7 @@ bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const siz
printf(" TX: ");
print_hex(abtTxBuf,szTxLen+7);
#endif
if (!rs232_send((serial_port)ds,abtTxBuf,szTxLen+7)) {
if (!uart_send((serial_port)ds,abtTxBuf,szTxLen+7)) {
ERR("Unable to transmit data. (TX)");
return false;
}
@ -175,7 +174,7 @@ bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const siz
*/
delay_ms(30);
if (!rs232_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) {
if (!uart_receive((serial_port)ds,abtRxBuf,&szRxBufLen)) {
ERR("Unable to receive data. (RX)");
return false;
}

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn532_uart.h
* @file pn532_uart.h
* @brief
*/
@ -28,11 +28,11 @@
#include "types.h"
// Functions used by developer to handle connection to this device
dev_info* dev_pn532_uart_connect(const nfc_device_desc_t* pndd);
void dev_pn532_uart_disconnect(dev_info* pdi);
dev_info* pn532_uart_connect(const nfc_device_desc_t* pndd);
void pn532_uart_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
bool pn532_uart_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
#endif // _LIBNFC_DEV_PN532_UART_H_

View file

@ -17,21 +17,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn533.c
* @file pn533.c
* @brief
*/
/*
Thanks to d18c7db and Okko for example code
*/
#include "dev_pn533.h"
#include "pn533.h"
#include <usb.h>
#include <stdio.h>
#include <string.h>
#include "defines.h"
#include "bitutils.h"
#include "messages.h"
#define BUFFER_LENGTH 256
@ -79,7 +78,7 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
}
}
dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd)
dev_info* pn533_connect(const nfc_device_desc_t* pndd)
{
int idvendor = 0x04e6;
int idproduct = 0x5591;
@ -158,7 +157,7 @@ dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd)
return pdi;
}
void dev_pn533_disconnect(dev_info* pdi)
void pn533_disconnect(dev_info* pdi)
{
dev_spec_pn533* pdsp = (dev_spec_pn533*)pdi->ds;
usb_release_interface(pdsp->pudh,0);
@ -167,7 +166,7 @@ void dev_pn533_disconnect(dev_info* pdi)
free(pdi);
}
bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
size_t uiPos = 0;
int ret = 0;

View file

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file dev_pn533.h
* @file pn533.h
* @brief
*/
@ -28,11 +28,11 @@
#include "types.h"
// Functions used by developer to handle connection to this device
dev_info* dev_pn533_connect(const nfc_device_desc_t* pndd);
void dev_pn533_disconnect(dev_info* pdi);
dev_info* pn533_connect(const nfc_device_desc_t* pndd);
void pn533_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
bool pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
#endif // _LIBNFC_DEV_PN533_H_