Modified:
/trunk/include/nfc/nfc-types.h
/trunk/include/nfc/nfc.h
/trunk/libnfc/chips/pn53x.c
/trunk/libnfc/chips/pn53x.h
/trunk/libnfc/drivers/acr122.c
/trunk/libnfc/drivers/acr122s.c
/trunk/libnfc/drivers/arygon.c
/trunk/libnfc/drivers/pn532_uart.c
/trunk/libnfc/drivers/pn53x_usb.c
/trunk/libnfc/nfc-internal.h
/trunk/libnfc/nfc.c
=======================================
--- /trunk/include/nfc/nfc-types.h Wed Jan 25 01:56:05 2012
+++ /trunk/include/nfc/nfc-types.h Fri Feb 17 04:09:56 2012
@@ -276,7 +276,7 @@
* @brief NFC modulation type enumeration
*/
typedef enum {
- NMT_ISO14443A,
+ NMT_ISO14443A = 1,
NMT_JEWEL,
NMT_ISO14443B,
NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
@@ -286,6 +286,15 @@
NMT_DEP,
} nfc_modulation_type;
+/**
+ * @enum nfc_mode
+ * @brief NFC mode type enumeration
+ */
+typedef enum {
+ N_TARGET,
+ N_INITIATOR,
+} nfc_mode;
+
/**
* @struct nfc_modulation
* @brief NFC modulation structure
=======================================
--- /trunk/include/nfc/nfc.h Tue Jan 31 01:49:43 2012
+++ /trunk/include/nfc/nfc.h Fri Feb 17 04:09:56 2012
@@ -113,6 +113,8 @@
NFC_EXPORT void iso14443a_crc_append (uint8_t *pbtData, size_t szLen);
NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes (uint8_t *pbtAts,
size_t szAts, size_t *pszTk);
NFC_EXPORT const char *nfc_version (void);
+ NFC_EXPORT int nfc_device_get_supported_modulation (nfc_device *pnd,
const nfc_mode mode, nfc_modulation_type **supported_mt);
+ NFC_EXPORT int nfc_device_get_supported_baud_rate (nfc_device *pnd,
const nfc_modulation_type nmt, nfc_baud_rate **supported_br);
/* Error codes */
/** @ingroup error
=======================================
--- /trunk/libnfc/chips/pn53x.c Tue Jan 31 06:28:45 2012
+++ /trunk/libnfc/chips/pn53x.c Fri Feb 17 04:09:56 2012
@@ -49,6 +49,13 @@
const uint8_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
const uint8_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
static const uint8_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff,
0x7f, 0x81, 0x00 };
+const nfc_baud_rate pn53x_iso14443a_supported_baud_rates[] = { NBR_106, 0
};
+const nfc_baud_rate pn53x_felica_supported_baud_rates[] = { NBR_424,
NBR_212, 0 };
+const nfc_baud_rate pn53x_dep_supported_baud_rates[] = { NBR_424, NBR_212,
NBR_106, 0 };
+const nfc_baud_rate pn53x_jewel_supported_baud_rates[] = { NBR_106, 0 };
+const nfc_baud_rate pn532_iso14443b_supported_baud_rates[] = { NBR_106, 0
};
+const nfc_baud_rate pn533_iso14443b_supported_baud_rates[] = { NBR_847,
NBR_424, NBR_212, NBR_106, 0 };
+const nfc_modulation_type pn53x_supported_modulation_as_target[] =
{NMT_ISO14443A, NMT_FELICA, NMT_DEP, 0};
/* prototypes */
int pn53x_reset_settings (struct nfc_device *pnd);
@@ -68,6 +75,32 @@
return res;
}
+ if (!CHIP_DATA(pnd)->supported_modulation_as_initiator) {
+ CHIP_DATA(pnd)->supported_modulation_as_initiator =
malloc(sizeof(nfc_modulation) * 9);
+ int nbSupportedModulation = 0;
+ if ((pnd->btSupportByte & SUPPORT_ISO14443A)) {
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443A;
+ nbSupportedModulation++;
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_FELICA;
+ nbSupportedModulation++;
+ }
+ if (pnd->btSupportByte & SUPPORT_ISO14443B) {
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443B;
+ nbSupportedModulation++;
+ }
+ if(CHIP_DATA(pnd)->type != PN531) {
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_JEWEL;
+ nbSupportedModulation++;
+ }
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_DEP;
+ nbSupportedModulation++;
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
0;
+ }
+
+ if (!CHIP_DATA(pnd)->supported_modulation_as_target) {
+ CHIP_DATA(pnd)->supported_modulation_as_target =
pn53x_supported_modulation_as_target;
+ }
+
// CRC handling should be enabled by default as declared in
nfc_device_new
// which is the case by default for pn53x, so nothing to do here
// Parity handling should be enabled by default as declared in
nfc_device_new
@@ -2757,6 +2790,51 @@
}
return PTT_UNDEFINED;
}
+
+int
+pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode mode,
nfc_modulation_type **supported_mt)
+{
+ switch (mode) {
+ case N_TARGET:
+ *supported_mt = CHIP_DATA(pnd)->supported_modulation_as_target;
+ break;
+ case N_INITIATOR:
+ *supported_mt = CHIP_DATA(pnd)->supported_modulation_as_initiator;
+ break;
+ default:
+ return NFC_EINVARG;
+ }
+ return NFC_SUCCESS;
+}
+
+int
+pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type
nmt, nfc_baud_rate **supported_br)
+{
+ switch (nmt) {
+ case NMT_FELICA:
+ *supported_br = (nfc_baud_rate*)pn53x_felica_supported_baud_rates;
+ break;
+ case NMT_ISO14443A:
+ *supported_br = (nfc_baud_rate*)pn53x_iso14443a_supported_baud_rates;
+ break;
+ case NMT_ISO14443B: {
+ if ((CHIP_DATA(pnd)->type != PN533)) {
+ *supported_br =
(nfc_baud_rate*)pn532_iso14443b_supported_baud_rates;
+ } else {
+ *supported_br =
(nfc_baud_rate*)pn533_iso14443b_supported_baud_rates;
+ }
+ }
+ break;
+ case NMT_JEWEL:
+ *supported_br = (nfc_baud_rate*)pn53x_jewel_supported_baud_rates;
+ break;
+ case NMT_DEP:
+ *supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates;
+ break;
+ return NFC_EINVARG;
+ }
+ return NFC_SUCCESS;
+}
void
pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io)
@@ -2794,6 +2872,10 @@
// Set default communication timeout (52 ms)
CHIP_DATA (pnd)->timeout_communication = 52;
+
+ CHIP_DATA (pnd)->supported_modulation_as_initiator = NULL;
+
+ CHIP_DATA (pnd)->supported_modulation_as_target = NULL;
}
void
@@ -2802,5 +2884,8 @@
if (CHIP_DATA (pnd)->current_target) {
free (CHIP_DATA (pnd)->current_target);
}
+ if (CHIP_DATA(pnd)->supported_modulation_as_initiator) {
+ free (CHIP_DATA(pnd)->supported_modulation_as_initiator);
+ }
free (pnd->chip_data);
}
=======================================
--- /trunk/libnfc/chips/pn53x.h Tue Jan 31 01:49:43 2012
+++ /trunk/libnfc/chips/pn53x.h Fri Feb 17 04:09:56 2012
@@ -187,6 +187,9 @@
int timeout_atr;
/** Communication timeout */
int timeout_communication;
+/** Supported modulation type */
+ nfc_modulation_type *supported_modulation_as_initiator;
+ nfc_modulation_type *supported_modulation_as_target;
};
#define CHIP_DATA(pnd) ((struct pn53x_data*)(pnd->chip_data))
@@ -377,6 +380,8 @@
int pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t
*pbtRxFrame, const size_t szRxFrameLen);
int pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t
*pbtRxFrame, const size_t szRxFrameLen);
int pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const
uint8_t *pbtData, const size_t szData);
+int pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode
mode, nfc_modulation_type **supported_mt);
+int pn53x_get_supported_baud_rate(nfc_device *pnd, const
nfc_modulation_type nmt, nfc_baud_rate **supported_br);
void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io);
void pn53x_data_free (struct nfc_device *pnd);
=======================================
--- /trunk/libnfc/drivers/acr122.c Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/drivers/acr122.c Fri Feb 17 04:09:56 2012
@@ -488,6 +488,8 @@
.device_set_property_bool = pn53x_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
+ .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_baud_rate = pn53x_get_supported_baud_rate,
.abort_command = NULL, // FIXME: abort is not supported in this driver
.idle = NULL, // FIXME: idle is not supported in this driver
=======================================
--- /trunk/libnfc/drivers/acr122s.c Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/drivers/acr122s.c Fri Feb 17 04:09:56 2012
@@ -743,6 +743,8 @@
.device_set_property_bool = pn53x_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
+ .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_baud_rate = pn53x_get_supported_baud_rate,
.abort_command = acr122s_abort_command,
.idle = NULL,
=======================================
--- /trunk/libnfc/drivers/arygon.c Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/drivers/arygon.c Fri Feb 17 04:09:56 2012
@@ -585,6 +585,8 @@
.device_set_property_bool = pn53x_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
+ .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_baud_rate = pn53x_get_supported_baud_rate,
.abort_command = arygon_abort_command,
.idle = NULL, // FIXME arygon driver does not support idle()
=======================================
--- /trunk/libnfc/drivers/pn532_uart.c Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/drivers/pn532_uart.c Fri Feb 17 04:09:56 2012
@@ -527,6 +527,8 @@
.device_set_property_bool = pn53x_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
+ .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_baud_rate = pn53x_get_supported_baud_rate,
.abort_command = pn532_uart_abort_command,
.idle = pn53x_idle,
=======================================
--- /trunk/libnfc/drivers/pn53x_usb.c Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/drivers/pn53x_usb.c Fri Feb 17 04:09:56 2012
@@ -773,6 +773,8 @@
.device_set_property_bool = pn53x_usb_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
+ .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_baud_rate = pn53x_get_supported_baud_rate,
.abort_command = pn53x_usb_abort_command,
.idle = pn53x_idle,
=======================================
--- /trunk/libnfc/nfc-internal.h Wed Jan 25 01:56:05 2012
+++ /trunk/libnfc/nfc-internal.h Fri Feb 17 04:09:56 2012
@@ -151,6 +151,8 @@
int (*device_set_property_bool) (struct nfc_device *pnd, const
nfc_property property, const bool bEnable);
int (*device_set_property_int) (struct nfc_device *pnd, const
nfc_property property, const int value);
+ int (*get_supported_modulation) (struct nfc_device *pnd, const nfc_mode
mode, nfc_modulation_type **supported_mt);
+ int (*get_supported_baud_rate) (struct nfc_device *pnd, const
nfc_modulation_type nmt, nfc_baud_rate **supported_br);
int (*abort_command) (struct nfc_device *pnd);
int (*idle) (struct nfc_device *pnd);
=======================================
--- /trunk/libnfc/nfc.c Tue Jan 31 07:35:13 2012
+++ /trunk/libnfc/nfc.c Fri Feb 17 04:09:56 2012
@@ -1001,3 +1001,15 @@
return PACKAGE_VERSION;
#endif // SVN_REVISION
}
+
+int
+nfc_device_get_supported_modulation (nfc_device *pnd, const nfc_mode
mode, nfc_modulation_type **supported_mt)
+{
+ HAL (get_supported_modulation, pnd, mode, supported_mt);
+}
+
+int
+nfc_device_get_supported_baud_rate (nfc_device *pnd, const
nfc_modulation_type nmt, nfc_baud_rate **supported_br)
+{
+ HAL (get_supported_baud_rate, pnd, nmt, supported_br);
+}