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];
|
2010-12-29 13:15:49 +00:00
|
|
|
size_t device_count;
|
|
|
|
bool res;
|
|
|
|
|
2011-11-23 15:55:40 +00:00
|
|
|
nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &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
|
|
|
|
2011-11-23 15:55:40 +00:00
|
|
|
device = nfc_connect (&(connstrings[0]));
|
2010-12-29 13:15:49 +00:00
|
|
|
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 */
|
2011-05-10 15:13:19 +00:00
|
|
|
res = pn53x_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0xAA);
|
2011-03-02 15:00:44 +00:00
|
|
|
cut_assert_true (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-03-02 15:00:44 +00:00
|
|
|
cut_assert_true (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-03-02 15:00:44 +00:00
|
|
|
cut_assert_true (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-03-02 15:00:44 +00:00
|
|
|
cut_assert_true (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"));
|
|
|
|
|
|
|
|
nfc_disconnect (device);
|
|
|
|
}
|