Broke whole the libnfc :-)

use a new way to handle drivers
use absolute include path instead of relative ones
move some nfc_device_t members in a better place
nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic)
use more readable variables instead of strange coding convention
move PRINT_HEX macro into nfc-internal.h
silent warnings with more strict CFLAGS
chips/pn53x: use the powerful C99 writing to construct PN53x commands
chips/pn53x: remove almost all memcpy()
chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named
chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE)
chips/pn53x: add SAMConfiguration command wrapper (need to be improved)
chips/pn53x: remove almost all const arrays
chips/pn53x: use human readable defines for commands instead of hex values
chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-)
drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later
drivers: use a const structure of functions instead of -dirty- callbacks array
drivers/pn532_uart: major improvement of UART handling
drivers/pn532_uart: check PN53x frames when received
buses/uart: receive() is now based on expected bytes instead of calculated timeouts..
buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
This commit is contained in:
Romuald Conty 2011-03-02 15:00:44 +00:00
parent f1d909ae74
commit 5af845cdfc
20 changed files with 937 additions and 775 deletions

View file

@ -1,13 +1,11 @@
#include <cutter.h>
#include <nfc/nfc.h>
#include "../libnfc/chips/pn53x.h"
#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)
{
@ -27,21 +25,21 @@ test_register_endianness (void)
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"));
res = pn53x_write_register (device, REG_CIU_TX_MODE, 0xFF, 0xAA);
cut_assert_true (res, cut_message ("write 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"));
res = pn53x_read_register (device, REG_CIU_TX_MODE, &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_set_reg (device, REG_CIU_TX_MODE, 0xFF, 0x55);
cut_assert_true (res, cut_message ("set a register value to 0x55"));
res = pn53x_write_register (device, REG_CIU_TX_MODE, 0xFF, 0x55);
cut_assert_true (res, cut_message ("write 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"));
res = pn53x_read_register (device, REG_CIU_TX_MODE, &value);
cut_assert_true (res, cut_message ("read register value"));
cut_assert_equal_uint (0x55, value, cut_message ("check register value"));
nfc_disconnect (device);

View file

@ -5,7 +5,7 @@
#define MAX_DEVICE_COUNT 1
#define MAX_TARGET_COUNT 1
bool pn53x_get_reg(nfc_device_t* pnd, uint16_t ui16Reg, uint8_t* ui8Value);
#include "libnfc/chips/pn53x.h"
void
test_register_endianness (void)
@ -26,11 +26,11 @@ test_register_endianness (void)
uint8_t value;
/* Read valid XRAM memory */
res = pn53x_get_reg (device, 0xF0FF, &value);
res = pn53x_read_register (device, 0xF0FF, &value);
cut_assert_true (res, cut_message ("read register 0xF0FF"));
/* Read invalid SFR register */
res = pn53x_get_reg (device, 0xFFF0, &value);
res = pn53x_read_register (device, 0xFFF0, &value);
cut_assert_false (res, cut_message ("read register 0xFFF0"));
nfc_disconnect (device);