libnfc/test/test_register_access.c
Audrey Diacre c718fafee7 Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs
- Remove _t suffix from types
- Fix tests using connstrings
2011-11-23 15:55:40 +00:00

46 lines
1.5 KiB
C

#include <cutter.h>
#include <nfc/nfc.h>
#include "chips/pn53x.h"
#define MAX_DEVICE_COUNT 1
#define MAX_TARGET_COUNT 1
void
test_register_endianness (void)
{
nfc_connstring connstrings[MAX_DEVICE_COUNT];
size_t device_count;
bool res;
nfc_list_devices (connstrings, MAX_DEVICE_COUNT, &device_count);
if (!device_count)
cut_omit ("No NFC device found");
nfc_device *device;
device = nfc_connect (&(connstrings[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_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0xAA);
cut_assert_true (res, cut_message ("write register value to 0xAA"));
/* Get test value from register memory */
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
cut_assert_true (res, cut_message ("read 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_write_register (device, PN53X_REG_CIU_TxMode, 0xFF, 0x55);
cut_assert_true (res, cut_message ("write register value to 0x55"));
/* Get test value from register memory */
res = pn53x_read_register (device, PN53X_REG_CIU_TxMode, &value);
cut_assert_true (res, cut_message ("read register value"));
cut_assert_equal_uint (0x55, value, cut_message ("check register value"));
nfc_disconnect (device);
}