libnfc/test/test_register_access.c

49 lines
1.5 KiB
C
Raw Normal View History

2010-12-29 13:15:49 +00:00
#include <cutter.h>
#include <nfc/nfc.h>
#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)
{
nfc_connstring connstrings[MAX_DEVICE_COUNT];
int res = 0;
nfc_init (NULL);
2010-12-29 13:15:49 +00:00
size_t device_count = nfc_list_devices (NULL, connstrings, MAX_DEVICE_COUNT);
if (!device_count)
cut_omit ("No NFC device found");
2010-12-29 13:15:49 +00:00
nfc_device *device;
2010-12-29 13:15:49 +00:00
device = nfc_open (NULL, connstrings[0]);
cut_assert_not_null (device, cut_message ("nfc_open"));
2010-12-29 13:15:49 +00:00
uint8_t value;
2010-12-29 13:15:49 +00:00
/* Set a 0xAA test value in writable register memory to test register access */
res = pn53x_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0xAA);
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 */
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
cut_assert_equal_int (0, res, cut_message ("read register value"));
cut_assert_equal_uint (0xAA, value, cut_message ("check register value"));
2010-12-29 13:15:49 +00:00
/* Set a 0x55 test value in writable register memory to test register access */
res = pn53x_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0x55);
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 */
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
cut_assert_equal_int (0, res, cut_message ("read register value"));
cut_assert_equal_uint (0x55, value, cut_message ("check register value"));
2010-12-29 13:15:49 +00:00
nfc_close (device);
nfc_exit (NULL);
2010-12-29 13:15:49 +00:00
}