From 904f41e0f77f7a69ffb52f0bfd7bdf7e06dfb5f0 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 27 Jun 2011 10:33:55 +0000 Subject: [PATCH] drivers/pn53x*: use shared pn53x_ack_frame[] and pn53x_nack_frame[] instead of local declaration. --- libnfc/chips/pn53x.c | 4 ++-- libnfc/chips/pn53x.h | 3 +++ libnfc/drivers/pn532_uart.c | 5 +---- libnfc/drivers/pn53x_usb.c | 8 ++------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 8099765..24cb497 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -48,8 +48,8 @@ // TODO: Count max bytes for InJumpForDEP reply const byte_t pncmd_initiator_jump_for_dep[68] = { 0xD4, 0x56 }; -static const byte_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 }; -static const byte_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 }; +const byte_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 }; +const byte_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 }; static const byte_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff, 0x7f, 0x81, 0x00 }; /* prototypes */ diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 04fa4da..8ba8589 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -250,6 +250,9 @@ typedef enum { PTM_ISO14443_4_PICC_ONLY = 0x04 } pn53x_target_mode_t; +extern const byte_t pn53x_ack_frame[6]; +extern const byte_t pn53x_nack_frame[6]; + bool pn53x_init(nfc_device_t * pnd); bool pn53x_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t *pszRx); diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index aa76264..fbf63f6 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -46,9 +46,6 @@ #define PN532_UART_DEFAULT_SPEED 115200 #define PN532_UART_DRIVER_NAME "PN532_UART" -// TODO Move this one level up for libnfc-1.6 -static const byte_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 }; - int pn532_uart_ack (nfc_device_t * pnd); int pn532_uart_wakeup (nfc_device_t * pnd); @@ -422,7 +419,7 @@ pn532_uart_ack (nfc_device_t * pnd) return -1; } } - return (0 == uart_send (DRIVER_DATA(pnd)->port, ack_frame, sizeof (ack_frame))) ? 0 : -1; + return (0 == uart_send (DRIVER_DATA(pnd)->port, pn53x_ack_frame, sizeof (pn53x_ack_frame))) ? 0 : -1; } bool diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index deb7686..7ff2dfd 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -156,10 +156,6 @@ pn53x_usb_get_device_model (uint16_t vendor_id, uint16_t product_id) return UNKNOWN; } -// TODO Move this HACK1 into an upper level in order to benefit to other devices that use PN53x -static const byte_t ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 }; -static const byte_t nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 }; - int pn53x_usb_ack (nfc_device_t * pnd); // Find transfer endpoints for bulk transfers @@ -449,7 +445,7 @@ pn53x_usb_send (nfc_device_t * pnd, const byte_t * pbtData, const size_t szData) // response packet. With this hack, the nextly executed function (ie. // pn53x_usb_receive()) will be able to retreive the correct response // packet. - int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *)nack_frame, sizeof(nack_frame)); + int res = pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *)pn53x_nack_frame, sizeof(pn53x_nack_frame)); if (res < 0) { pnd->iLastError = DEIO; // try to interrupt current device state @@ -593,7 +589,7 @@ read: int pn53x_usb_ack (nfc_device_t * pnd) { - return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *) ack_frame, sizeof (ack_frame)); + return pn53x_usb_bulk_write (DRIVER_DATA (pnd), (byte_t *) pn53x_ack_frame, sizeof (pn53x_ack_frame)); } bool