2010-12-29 13:15:49 +00:00
|
|
|
#include <cutter.h>
|
|
|
|
|
|
|
|
#include <nfc/nfc.h>
|
2011-03-05 19:54:52 +00:00
|
|
|
#include "chips/pn53x.h"
|
2010-12-29 13:15:49 +00:00
|
|
|
|
|
|
|
#define MAX_DEVICE_COUNT 1
|
|
|
|
#define MAX_TARGET_COUNT 1
|
|
|
|
|
|
|
|
void
|
|
|
|
test_register_endianness (void)
|
|
|
|
{
|
2011-11-23 15:55:40 +00:00
|
|
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
2011-12-20 14:41:17 +00:00
|
|
|
int res = 0;
|
2012-01-18 11:09:01 +00:00
|
|
|
|
2012-01-18 16:22:06 +00:00
|
|
|
nfc_init (NULL);
|
2010-12-29 13:15:49 +00:00
|
|
|
|
2012-01-18 16:22:06 +00:00
|
|
|
size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
|
2010-12-29 13:15:49 +00:00
|
|
|
if (!device_count)
|
|
|
|
cut_omit ("No NFC device found");
|
|
|
|
|
2011-11-23 15:55:40 +00:00
|
|
|
nfc_device *device;
|
2010-12-29 13:15:49 +00:00
|
|
|
|
2012-01-18 16:22:06 +00:00
|
|
|
device = nfc_open (NULL, connstrings[0]);
|
2012-01-17 15:21:56 +00:00
|
|
|
cut_assert_not_null (device, cut_message ("nfc_open"));
|
2010-12-29 13:15:49 +00:00
|
|
|
|
|
|
|
uint8_t value;
|
|
|
|
|
|
|
|
/* Set a 0xAA test value in writable register memory to test register access */
|
2011-05-10 15:13:19 +00:00
|
|
|
res = pn53x_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0xAA);
|
2011-12-20 11:25:33 +00:00
|
|
|
cut_assert_equal_int (0, res, cut_message ("write register value to 0xAA"));
|
2010-12-29 13:15:49 +00:00
|
|
|
|
|
|
|
/* Get test value from register memory */
|
2011-05-10 15:13:19 +00:00
|
|
|
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
|
2011-12-20 14:41:17 +00:00
|
|
|
cut_assert_equal_int (0, res, cut_message ("read register value"));
|
2010-12-29 13:15:49 +00:00
|
|
|
cut_assert_equal_uint (0xAA, value, cut_message ("check register value"));
|
|
|
|
|
|
|
|
/* Set a 0x55 test value in writable register memory to test register access */
|
2011-05-10 15:13:19 +00:00
|
|
|
res = pn53x_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0x55);
|
2011-12-20 11:25:33 +00:00
|
|
|
cut_assert_equal_int (0, res, cut_message ("write register value to 0x55"));
|
2010-12-29 13:15:49 +00:00
|
|
|
|
|
|
|
/* Get test value from register memory */
|
2011-05-10 15:13:19 +00:00
|
|
|
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
|
2011-12-20 14:41:17 +00:00
|
|
|
cut_assert_equal_int (0, res, cut_message ("read register value"));
|
2010-12-29 13:15:49 +00:00
|
|
|
cut_assert_equal_uint (0x55, value, cut_message ("check register value"));
|
|
|
|
|
2012-01-17 14:52:39 +00:00
|
|
|
nfc_close (device);
|
2012-01-18 16:22:06 +00:00
|
|
|
nfc_exit (NULL);
|
2010-12-29 13:15:49 +00:00
|
|
|
}
|