From 59a93eab457a4a3ddec24b13928c5aa97a30db8f Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 29 Dec 2010 13:15:49 +0000 Subject: [PATCH] Add register access test. --- test/Makefile.am | 4 ++++ test/test_register_access.c | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/test_register_access.c diff --git a/test/Makefile.am b/test/Makefile.am index 4dde6bb..89f9b96 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -9,6 +9,7 @@ TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)" noinst_LTLIBRARIES = \ test_access_storm.la \ + test_register_access.la test_register_endianness.la AM_LDFLAGS = -module -rpath $(libdir) -avoid-version -no-undefined @@ -16,6 +17,9 @@ AM_LDFLAGS = -module -rpath $(libdir) -avoid-version -no-undefined test_access_storm_la_SOURCES = test_access_storm.c test_access_storm_la_LIBADD = $(top_builddir)/libnfc/libnfc.la +test_register_access_la_SOURCES = test_register_access.c +test_register_access_la_LIBADD = $(top_builddir)/libnfc/libnfc.la + test_register_endianness_la_SOURCES = test_register_endianness.c test_register_endianness_la_LIBADD = $(top_builddir)/libnfc/libnfc.la diff --git a/test/test_register_access.c b/test/test_register_access.c new file mode 100644 index 0000000..b2b5941 --- /dev/null +++ b/test/test_register_access.c @@ -0,0 +1,48 @@ +#include + +#include +#include "../libnfc/chips/pn53x.h" + +#define MAX_DEVICE_COUNT 1 +#define MAX_TARGET_COUNT 1 + +bool pn53x_get_reg(nfc_device_t* pnd, uint16_t ui16Reg, uint8_t* ui8Value); + +void +test_register_endianness (void) +{ + nfc_device_desc_t devices[MAX_DEVICE_COUNT]; + size_t device_count; + bool res; + + nfc_list_devices (devices, MAX_DEVICE_COUNT, &device_count); + if (!device_count) + cut_omit ("No NFC device found"); + + nfc_device_t *device; + + device = nfc_connect (&(devices[0])); + cut_assert_not_null (device, cut_message ("nfc_connect")); + + uint8_t value; + + /* Set a 0xAA test value in writable register memory to test register access */ + res = pn53x_set_reg (device, REG_CIU_TX_MODE, 0xFF, 0xAA); + cut_assert_true (res, cut_message ("set a register value to 0xAA")); + + /* Get test value from register memory */ + res = pn53x_get_reg (device, REG_CIU_TX_MODE, &value); + cut_assert_true (res, cut_message ("get register value")); + cut_assert_equal_uint (0xAA, value, cut_message ("check register value")); + + /* Set a 0x55 test value in writable register memory to test register access */ + res = pn53x_set_reg (device, REG_CIU_TX_MODE, 0xFF, 0x55); + cut_assert_true (res, cut_message ("set a register value to 0x55")); + + /* Get test value from register memory */ + res = pn53x_get_reg (device, REG_CIU_TX_MODE, &value); + cut_assert_true (res, cut_message ("get register value")); + cut_assert_equal_uint (0x55, value, cut_message ("check register value")); + + nfc_disconnect (device); +}