Fix a bunch of compilation issues, thanks @pan-

pull/7822/head
Donatien Garnier 2018-08-21 18:25:52 +01:00
parent 3970f5f77a
commit 483fcdfc83
53 changed files with 275 additions and 153 deletions

View File

@ -35,7 +35,10 @@ public:
/**
* Called when the PN512 asserts the interrupt line
*/
void on_hw_interrupt();
virtual void on_hw_interrupt() {}
protected:
~Delegate() {}
};
/**
@ -43,6 +46,11 @@ public:
*/
PN512TransportDriver();
/**
* PN512TransportDriver destructor.
*/
virtual ~PN512TransportDriver();
/**
* Initialize transport driver and perform a chip reset
*/

View File

@ -36,6 +36,7 @@ class Type4RemoteInitiator;
* This base class represents an ISO7816-4 application.
*/
class ISO7816App {
public:
/**
* This class describes an ISO7816-4 exchange (Command/Response).
*/
@ -91,7 +92,12 @@ class ISO7816App {
/**
* Construct ISO7816 app instance
*/
ISO7816App();
ISO7816App() {}
/**
* ISO7816App destructor
*/
virtual ~ISO7816App();
private:
friend class Type4RemoteInitiator;

View File

@ -80,6 +80,9 @@ public:
* @param[in] the NFCRemoteTarget instance
*/
virtual void on_nfc_target_discovered(const SharedPtr<NFCRemoteTarget> &nfc_target) {}
protected:
~Delegate() { }
};
/**

View File

@ -22,7 +22,7 @@
#include "stack/nfc_errors.h"
#include "stack/transceiver/transceiver.h"
#include "stack/platform/scheduler.h"
#include "stack/platform/nfc_scheduler.h"
namespace mbed {
namespace nfc {
@ -37,11 +37,17 @@ namespace nfc {
* Implementers need to derive from this class and implement its methods.
*/
class NFCControllerDriver {
public:
/**
* Instantiate a NFCControllerDriver
*/
NFCControllerDriver();
/**
* NFCControllerDriver destructor
*/
virtual ~NFCControllerDriver();
/**
* The NFCControllerDriver delegate
*/
@ -50,6 +56,9 @@ class NFCControllerDriver {
* Called when the controller asserts the interrupt line
*/
virtual void on_hw_interrupt() {}
protected:
virtual ~Delegate() {}
};
/**

View File

@ -18,6 +18,7 @@
#define MBED_NFC_EEPROM_H
#include <stdint.h>
#include "events/EventQueue.h"
#include "NFCDefinitions.h"
#include "NFCTarget.h"
@ -58,6 +59,29 @@ public:
* The NFCEEPROM delegate. Users of the NFCEEPROM class need to implement this delegate's methods to receive events.
*/
struct Delegate : NFCTarget::Delegate {
/**
* The NDEF message erasing request completed.
*
* @param[in] result NFC_OK or an error code on failure
*/
virtual void on_ndef_message_erased(nfc_err_t result) {}
/**
* The NDEF message writing request completed.
*
* @param[in] result NFC_OK or an error code on failure
*/
virtual void on_ndef_message_written(nfc_err_t result) {}
/**
* The NDEF message reading request completed.
*
* @param[in] result NFC_OK or an error code on failure
*/
virtual void on_ndef_message_read(nfc_err_t result) {}
protected:
~Delegate() {}
};
/**
@ -96,7 +120,7 @@ private:
void continue_read();
void continue_erase();
enum class nfc_eeprom_operation_t {
enum nfc_eeprom_operation_t {
nfc_eeprom_idle,
nfc_eeprom_write_start_session,
@ -104,7 +128,7 @@ private:
nfc_eeprom_write_write_size,
nfc_eeprom_write_end_session,
nfc_eeprom_write_start_session,
nfc_eeprom_read_start_session,
nfc_eeprom_read_read_size,
nfc_eeprom_read_read_bytes,
nfc_eeprom_read_end_session,
@ -119,7 +143,7 @@ private:
bool _initialized;
nfc_eeprom_operation_t _current_op;
buffer_t _ndef_buffer_reader;
ac_buffer_t _ndef_buffer_reader;
size_t _ndef_buffer_read_sz;
uint32_t _eeprom_address;
nfc_err_t _operation_result;

View File

@ -42,6 +42,11 @@ public:
*/
NFCEEPROMDriver();
/**
* NFCEEPROM driver destructor.
*/
virtual ~NFCEEPROMDriver();
/**
* The NFCEEPROMDriver delegate.
* Methods in this class are called by the driver on completion of long-running operations.
@ -96,6 +101,9 @@ public:
* @param[in] count number of bytes actually erased
*/
virtual void on_bytes_erased(size_t count) = 0;
protected:
~Delegate() {}
};
/**

View File

@ -71,6 +71,9 @@ public:
{
return 0;
}
protected:
~Delegate() {}
};
/**
@ -104,10 +107,10 @@ protected:
private:
// Callbacks from NDEF stack
static nfc_err_t s_ndef_encode(ndef_msg_t *pTag, buffer_builder_t *pBufferBldr, void *pUserData);
static nfc_err_t s_ndef_decode(ndef_msg_t *pTag, buffer_t *pBuffer, void *pUserData);
nfc_err_t ndef_encode(buffer_builder_t *pBufferBldr);
nfc_err_t ndef_decode(buffer_t *pBuffer);
static nfc_err_t s_ndef_encode(ndef_msg_t *pTag, ac_buffer_builder_t *pBufferBldr, void *pUserData);
static nfc_err_t s_ndef_decode(ndef_msg_t *pTag, ac_buffer_t *pBuffer, void *pUserData);
nfc_err_t ndef_encode(ac_buffer_builder_t *pBufferBldr);
nfc_err_t ndef_decode(ac_buffer_t *pBuffer);
Delegate *_delegate;

View File

@ -37,7 +37,13 @@ class NFCController;
*/
class NFCRemoteEndpoint {
public:
NFCRemoteEndpoint();
/**
* Create a NFCRemoteEndpointinstance
* @param[in] controller the NFCController instance that detected this endpoint
*/
NFCRemoteEndpoint(NFCController *controller);
virtual ~NFCRemoteEndpoint();
/**
* The NFCRemoteEndpoint base delegate.
@ -46,12 +52,15 @@ public:
/**
* This method is called when the endpoint is connected
*/
virtual void on_connected() {};
virtual void on_connected() {}
/**
* This method is called when the endpoint is lost (air interface link disconnnected)
*/
virtual void on_disconnected() {};
virtual void on_disconnected() {}
protected:
~Delegate() {}
};
/**

View File

@ -42,17 +42,19 @@ class NFCRemoteInitiator : public NFCRemoteEndpoint, public NFCNDEFCapable {
public:
/**
* Create a NFCRemoteInitiator.
* @param[in] controller the NFCController instance that detected this endpoint
* @param[in] buffer a bytes array used to store NDEF messages
* @param[in] buffer_size the array size in bytes
*/
NFCRemoteInitiator(uint8_t *buffer, size_t buffer_size);
NFCRemoteInitiator(NFCController *controller, uint8_t *buffer, size_t buffer_size);
virtual ~NFCRemoteInitiator();
/**
* The NFCRemoteInitiator delegate. Users of the NFCRemoteInitiator class need to implement this delegate's methods to receive events.
*/
struct Delegate : NFCEndpoint::Delegate, NFCNDEFCapable::Delegate {
struct Delegate : NFCRemoteEndpoint::Delegate, NFCNDEFCapable::Delegate {
protected:
~Delegate() {}
};
/**

View File

@ -45,6 +45,10 @@ public:
* @param[in] buffer_size the array size in bytes
*/
NFCTarget(uint8_t *buffer, size_t buffer_size);
/**
* NFCTarget destructor
*/
virtual ~NFCTarget();
struct Delegate {
@ -68,6 +72,9 @@ public:
* @param[in] result NFC_OK or an error code on failure
*/
virtual void on_ndef_message_read(nfc_err_t result) {}
protected:
~Delegate() {}
};
/**

View File

@ -48,11 +48,16 @@ private:
*/
Type4RemoteInitiator(NFCController *controller, uint8_t *buffer, size_t buffer_size);
/**
* Type4RemoteInitiator destructor.
*/
virtual ~Type4RemoteInitiator();
// NFCRemoteEndpoint implementation
virtual nfc_err_t connect();
virtual nfc_err_t disconnect();
virtual bool is_connected();
virtual bool is_disconnected();
virtual bool is_connected() const;
virtual bool is_disconnected() const;
virtual nfc_rf_protocols_bitmask_t rf_protocols();
// NFCRemoteInitiator implementation

View File

@ -15,6 +15,10 @@
*/
#include "PN512Driver.h"
#include "nfc/stack/platform/nfc_debug.h"
using namespace mbed;
using namespace mbed::nfc;
PN512Driver::PN512Driver(PN512TransportDriver *transport_driver) : NFCControllerDriver(), _transport_driver(transport_driver)
{
@ -26,14 +30,14 @@ nfc_transceiver_t *PN512Driver::initialize(nfc_scheduler_timer_t *scheduler_time
// Initialize transport
_transport_driver->initialize();
nfc_err_t ret = pn512_init(&pn512, _transport_driver->get_transport(), scheduler_timer);
nfc_err_t ret = pn512_init(&_pn512, _transport_driver->get_transport(), scheduler_timer);
if (ret != NFC_OK) {
NFC_ERR("PN512 init error (%d)", ret);
return NULL;
}
NFC_DBG("PN512 Initialized");
return pn512_get_transceiver(&pn512);
return pn512_get_transceiver(&_pn512);
}
void PN512Driver::get_supported_nfc_techs(nfc_tech_t *initiator, nfc_tech_t *target) const

View File

@ -22,7 +22,7 @@
using namespace mbed;
using namespace mbed::nfc;
PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, PinName sclk, PinName ssel, PinName irq, PinName rst)) :
PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, PinName sclk, PinName ssel, PinName irq, PinName rst) :
_spi(mosi, miso, sclk),
_ssel(ssel, 1),
_irq(irq, PullNone),
@ -70,7 +70,7 @@ void PN512SPITransportDriver::transport_write(uint8_t address, const uint8_t *ou
address = (address << 1) | 0x00;
_ssel = 0;
_spi.write(address); // First write address byte
_spi.write(outBuf, outLen, NULL, 0); // Ignore read bytes
_spi.write((const char *) outBuf, outLen, (char *) NULL, 0); // Ignore read bytes
_ssel = 1;
}
@ -93,7 +93,7 @@ void PN512SPITransportDriver::transport_read(uint8_t address, uint8_t *inBuf, si
_ssel = 0;
_spi.write(address); // First write address byte
_spi.write(inBuf, inLen, inBuf, inLen);
_spi.write((const char *) inBuf, inLen, (char *) inBuf, inLen);
_ssel = 1;
}

View File

@ -24,6 +24,11 @@ PN512TransportDriver::PN512TransportDriver() : _delegate(NULL)
}
PN512TransportDriver::~PN512TransportDriver()
{
}
void PN512TransportDriver::set_delegate(Delegate *delegate)
{
_delegate = delegate;

View File

@ -24,7 +24,7 @@ using namespace mbed;
using namespace mbed::nfc;
NFCController::NFCController(NFCControllerDriver *driver, events::EventQueue *queue, uint8_t *ndef_buffer, size_t ndef_buffer_sz) :
_driver(driver), _queue(queue), _transceiver(NULL), _scheduler(NULL), _delegate(NULL), _discovery_running(false), _ndef_buffer_sz(ndef_buffer_sz)
_driver(driver), _queue(queue), _transceiver(NULL), _scheduler(NULL), _delegate(NULL), _discovery_running(false), _ndef_buffer(ndef_buffer), _ndef_buffer_sz(ndef_buffer_sz)
{
_driver->set_delegate(this);
}
@ -44,6 +44,8 @@ nfc_err_t NFCController::initialize()
// Run scheduler for the first time
_queue->call(this, NFCController::scheduler_process, false);
return NFC_OK;
}
void NFCController::set_delegate(Delegate *delegate)
@ -99,6 +101,8 @@ nfc_err_t NFCController::configure_rf_protocols(nfc_rf_protocols_bitmask_t rf_pr
polling_options_t options = {0};
transceiver_set_protocols(_transceiver, initiator_tech, target_tech, options);
return NFC_OK;
}
nfc_err_t NFCController::start_discovery()
@ -109,6 +113,8 @@ nfc_err_t NFCController::start_discovery()
}
transceiver_poll(_transceiver, &NFCController::s_polling_callback, this /* use this as callback argument */);
return NFC_OK;
}
nfc_err_t NFCController::cancel_discovery()
@ -118,6 +124,8 @@ nfc_err_t NFCController::cancel_discovery()
}
transceiver_abort(_transceiver);
return NFC_OK;
}
nfc_transceiver_t *NFCController::transceiver() const
@ -138,7 +146,7 @@ void NFCController::polling_callback(nfc_err_t ret)
Type4RemoteInitiator type4_remote_initiator_ptr = new (std::nothrow) Type4RemoteInitiator(_transceiver, _ndef_buffer, _ndef_buffer_sz);
if (type4_remote_initiator_ptr == NULL) {
// No memory :(
SharedPtr<Type4RemoteInitiator> type4_remote_initiator(type4_remote_initiator_ptr);
SharedPtr<NFCRemoteInitiator> type4_remote_initiator(type4_remote_initiator_ptr);
if (_delegate != NULL) {
_delegate->on_nfc_initiator_discovered(type4_remote_initiator);
}
@ -148,7 +156,7 @@ void NFCController::polling_callback(nfc_err_t ret)
}
if (_delegate != NULL) {
nfc_discovery_terminated_reason_t reason;
NFCController::Delegate::nfc_discovery_terminated_reason_t reason;
// Map reason
switch (ret) {
@ -170,18 +178,18 @@ void NFCController::polling_callback(nfc_err_t ret)
void NFCController::scheduler_process(bool hw_interrupt)
{
_timer.detach(); // Cancel timeout - if it triggers, it's ok as we'll have an "early" iteration which will likely be a no-op
_timeout.detach(); // Cancel timeout - if it triggers, it's ok as we'll have an "early" iteration which will likely be a no-op
// Process stack events
uint32_t timeout = nfc_scheduler_iteration(_scheduler, hw_interrupt ? EVENT_HW_INTERRUPT : EVENT_NONE);
_timer.attach(callback(this, &NFCController::on_timeout));
_timeout.attach(callback(this, &NFCController::on_timeout), timeout);
}
void NFCController::on_hw_interrupt()
{
// Run scheduler - this is called in interrupt context
_timer.detach(); // Cancel timeout - if it triggers anyways, it's ok
_timeout.detach(); // Cancel timeout - if it triggers anyways, it's ok
_queue->call(this, NFCController::scheduler_process, true);
}

View File

@ -24,6 +24,11 @@ NFCControllerDriver::NFCControllerDriver() : _delegate(NULL)
}
NFCControllerDriver::~NFCControllerDriver()
{
}
void NFCControllerDriver::set_delegate(Delegate *delegate)
{
_delegate = delegate;

View File

@ -21,7 +21,7 @@ using namespace mbed;
using namespace mbed::nfc;
NFCEEPROM(NFCEEPROMDriver *driver, events::EventQueue *queue, uint8_t *ndef_buffer, size_t ndef_buffer_sz) : NFCTarget(ndef_buffer, ndef_buffer_sz)
_driver(driver), _initialized(false), _current_op(nfc_eeprom_idle), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
_driver(driver), _initialized(false), _current_op(nfc_eeprom_idle), _ndef_buffer_read_sz(0), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
{
_driver->set_delegate(this);
_driver->set_event_queue(queue);
@ -34,6 +34,7 @@ nfc_err_t NFCEEPROM::initialize()
// Initialize driver
_driver->reset();
_initialized = true;
return NFC_OK;
}
void NFCEEPROM::set_delegate(NFCEEPROM::Delegate *delegate)

View File

@ -24,6 +24,11 @@ NFCEEPROMDriver::NFCEEPROMDriver() : _delegate(NULL), _event_queue(NULL)
}
NFCEEPROMDriver::~NFCEEPROMDriver()
{
}
void NFCEEPROMDriver::set_delegate(Delegate *delegate)
{
_delegate = delegate;

View File

@ -27,7 +27,7 @@ using namespace mbed::nfc;
NFCNDEFCapable::NFCNDEFCapable(uint8_t *buffer, size_t buffer_size) : _delegate(NULL)
{
ndef_msg_init(&_ndef_message, s_encode_callback, s_decode_callback);
ndef_msg_init(&_ndef_message, s_ndef_encode, s_ndef_decode, buffer, buffer_size, this);
}
void NFCNDEFCapable::set_ndef_delegate(NFCNDEFCapable::Delegate *delegate)
@ -52,26 +52,26 @@ void NFCNDEFCapable::build_ndef_message(ac_buffer_builder_t &buffer_builder)
}
}
nfc_err_t NFCNDEFCapable::s_ndef_encode(ndef_msg_t *pTag, buffer_builder_t *pBufferBldr, void *pUserData)
nfc_err_t NFCNDEFCapable::s_ndef_encode(ndef_msg_t *pTag, ac_buffer_builder_t *pBufferBldr, void *pUserData)
{
NFCNDEFCapable *self = (NFCNDEFCapable *)pUserData;
self->ndef_encode(pBufferBldr);
return self->ndef_encode(pBufferBldr);
}
nfc_err_t NFCNDEFCapable::s_ndef_decode(ndef_msg_t *pTag, buffer_t *pBuffer, void *pUserData)
nfc_err_t NFCNDEFCapable::s_ndef_decode(ndef_msg_t *pTag, ac_buffer_t *pBuffer, void *pUserData)
{
NFCNDEFCapable *self = (NFCNDEFCapable *)pUserData;
self->ndef_decode(pBuffer);
return self->ndef_decode(pBuffer);
}
nfc_err_t NFCNDEFCapable::ndef_encode(buffer_builder_t *pBufferBldr)
nfc_err_t NFCNDEFCapable::ndef_encode(ac_buffer_builder_t *pBufferBldr)
{
build_ndef_message(buffer_builder);
build_ndef_message(*pBufferBldr);
return NFC_OK;
}
nfc_err_t NFCNDEFCapable::ndef_decode(buffer_t *pBuffer)
nfc_err_t NFCNDEFCapable::ndef_decode(ac_buffer_t *pBuffer)
{
parse_ndef_message(pBuffer);
parse_ndef_message(*pBuffer);
return NFC_OK;
}

View File

@ -30,7 +30,6 @@ NFCRemoteInitiator::~NFCRemoteInitiator()
}
void NFCRemoteInitiator::set_remote_initiator_delegate(Delegate *delegate)
{
_delegate = delegate;

View File

@ -42,7 +42,7 @@ Type4RemoteInitiator::Type4RemoteInitiator(NFCController *controller, uint8_t *b
nfc_err_t Type4RemoteInitiator::connect()
{
if (_is_connected) {
return NFC_BUSY;
return NFC_ERR_BUSY;
}
if (_is_disconnected) {
@ -54,6 +54,8 @@ nfc_err_t Type4RemoteInitiator::connect()
// Call callback as it's a synchronous API
connected();
return NFC_OK;
}
nfc_err_t Type4RemoteInitiator::disconnect()
@ -68,6 +70,8 @@ nfc_err_t Type4RemoteInitiator::disconnect()
// Disconnect ISO7816 stack
nfc_tech_iso7816_disconnect(&_iso7816);
return NFC_OK;
}
bool Type4RemoteInitiator::is_connected() const

View File

@ -22,7 +22,6 @@
*/
#include "inc/nfc.h"
#include "ndef.h"
/** \addtogroup NDEF

View File

@ -33,7 +33,8 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "acore/buffer.h"
#include "acore/buffer_builder.h"
//Generic interface for NDEF messages
@ -43,18 +44,18 @@ typedef struct __ndef_msg ndef_msg_t;
* \param pTag pointer to ndef_tag_t instance
* \param type pMem buffer in which to store the generated content
*/
typedef nfc_err_t (*ndef_encode_fn_t)(ndef_msg_t *pTag, buffer_builder_t *pBufferBldr, void *pUserData);
typedef nfc_err_t (*ndef_encode_fn_t)(ndef_msg_t *pTag, ac_buffer_builder_t *pBufferBldr, void *pUserData);
/** Function called to decode the tag's content on write (target mode) or read (reader mode)
* \param pTag pointer to ndef_tag_t instance
* \param type pMem buffer containing the tag's content
*/
typedef nfc_err_t (*ndef_decode_fn_t)(ndef_msg_t *pTag, buffer_t *pBuffer, void *pUserData);
typedef nfc_err_t (*ndef_decode_fn_t)(ndef_msg_t *pTag, ac_buffer_t *pBuffer, void *pUserData);
typedef struct __ndef_msg {
ndef_encode_fn_t encode;
ndef_decode_fn_t decode;
buffer_builder_t bufferBldr;
ac_buffer_builder_t bufferBldr;
void *pUserData;
} ndef_msg_t;
@ -76,7 +77,7 @@ static inline nfc_err_t ndef_msg_decode(ndef_msg_t *pNdef)
return pNdef->decode(pNdef, buffer_builder_buffer(&pNdef->bufferBldr), pNdef->pUserData);
}
static inline buffer_builder_t *ndef_msg_buffer_builder(ndef_msg_t *pNdef)
static inline ac_buffer_builder_t *ndef_msg_buffer_builder(ndef_msg_t *pNdef)
{
return &pNdef->bufferBldr;
}

View File

@ -45,6 +45,8 @@ static inline void nfc_dbg_print(const char *type, const char *module, unsigned
#define NFC_ERR(...) nfc_dbg_print("ERR", __MODULE__, __LINE__, __VA_ARGS__)
#endif
#define NFC_DBG_BLOCK(x) x
#else
#if !defined(NFC_DBG)
@ -58,6 +60,9 @@ static inline void nfc_dbg_print(const char *type, const char *module, unsigned
#if !defined(NFC_ERR)
#define NFC_ERR(...)
#endif
#define NFC_DBG_BLOCK(x)
#endif
#endif

View File

@ -20,6 +20,10 @@
* \author Donatien Garnier
*/
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#define __DEBUG__ 0
#ifndef __MODULE__
#define __MODULE__ "nfc_scheduler.c"

View File

@ -27,7 +27,7 @@
* @{
*/
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "nfc_transport.h"
/** Initialize transport with a specific implementation

View File

@ -33,7 +33,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include <stddef.h>
/** Function called to write a register's value
* \param address address of the register to write to

View File

@ -25,7 +25,7 @@
#define __MODULE__ "iso7816.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "iso7816.h"
#include "iso7816_app.h"
@ -45,8 +45,8 @@ static void iso_dep_received_cb(nfc_tech_isodep_t *pIsodep, nfc_err_t ret, void
static void iso_dep_transmitted_cb(nfc_tech_isodep_t *pIsodep, nfc_err_t ret, void *pUserData);
static void iso_dep_disconnected_cb(nfc_tech_isodep_t *pIsodep, bool deselected, void *pUserData);
static void iso_dep_stream_transmit_cb(buffer_t *ppDataIn, bool *pClose, size_t maxLength, void *pUserParam);
static void iso_dep_stream_receive_cb(buffer_t *pDataOut, bool closed, void *pUserParam);
static void iso_dep_stream_transmit_cb(ac_buffer_t *ppDataIn, bool *pClose, size_t maxLength, void *pUserParam);
static void iso_dep_stream_receive_cb(ac_buffer_t *pDataOut, bool closed, void *pUserParam);
void nfc_tech_iso7816_init(nfc_tech_iso7816_t *pIso7816, nfc_transceiver_t *pTransceiver, nfc_tech_iso7816_disconnected_cb disconnectedCb, void *pUserData)
{
@ -101,7 +101,7 @@ nfc_err_t nfc_tech_iso7816_reply(nfc_tech_iso7816_t *pIso7816)
buffer_append(&pIso7816->rApdu.dataOut, buffer_builder_buffer(&pIso7816->txBldr));
NFC_DBG("R-ADPU: (LE):%02X SW:%04X", buffer_reader_readable(&pIso7816->rApdu.dataOut), pIso7816->rApdu.sw);
DBG_BLOCK(buffer_dump(&pIso7816->rApdu.dataOut);)
NFC_DBG_BLOCK(buffer_dump(&pIso7816->rApdu.dataOut);)
ret = iso7816_transmit(pIso7816);
if (ret) {
@ -128,7 +128,7 @@ nfc_err_t iso7816_parse(nfc_tech_iso7816_t *pIso7816)
buffer_init(&pIso7816->rApdu.dataOut, NULL, 0);
pIso7816->rApdu.sw = ISO7816_SW_OK;
DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pIso7816->rxBldr));)
NFC_DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pIso7816->rxBldr));)
if (buffer_reader_readable(buffer_builder_buffer(&pIso7816->rxBldr)) < 4) {
NFC_ERR("C-APDU is too small");
@ -302,7 +302,7 @@ void iso_dep_disconnected_cb(nfc_tech_isodep_t *pIsodep, bool deselected, void *
iso7816_disconnected(pIso7816, deselected);
}
void iso_dep_stream_transmit_cb(buffer_t *pDataIn, bool *pClose, size_t maxLength, void *pUserParam)
void iso_dep_stream_transmit_cb(ac_buffer_t *pDataIn, bool *pClose, size_t maxLength, void *pUserParam)
{
nfc_tech_iso7816_t *pIso7816 = (nfc_tech_iso7816_t *) pUserParam;
@ -319,7 +319,7 @@ void iso_dep_stream_transmit_cb(buffer_t *pDataIn, bool *pClose, size_t maxLengt
buffer_split(pDataIn, &pIso7816->rApdu.dataOut, &pIso7816->rApdu.dataOut, maxLength);
}
void iso_dep_stream_receive_cb(buffer_t *pDataOut, bool closed, void *pUserParam)
void iso_dep_stream_receive_cb(ac_buffer_t *pDataOut, bool closed, void *pUserParam)
{
nfc_tech_iso7816_t *pIso7816 = (nfc_tech_iso7816_t *) pUserParam;

View File

@ -27,9 +27,9 @@
extern "C" {
#endif
#include "acore/fwk.h"
#include "transceiver/protocols.h"
#include "acore/stream.h"
#include "transceiver/protocols.h"
#include "tech/isodep/isodep_target.h"
struct nfc_tech_iso7816_c_apdu {
@ -37,12 +37,12 @@ struct nfc_tech_iso7816_c_apdu {
uint8_t ins;
uint8_t p1;
uint8_t p2;
buffer_t dataIn;
ac_buffer_t dataIn;
size_t maxRespLength;
};
struct nfc_tech_iso7816_r_apdu {
buffer_t dataOut;
ac_buffer_t dataOut;
uint16_t sw;
};
@ -74,18 +74,18 @@ struct nfc_tech_iso7816 {
nfc_tech_iso7816_disconnected_cb disconnectedCb;
void *pUserData;
buffer_t hist; //Historical bytes
ac_buffer_t hist; //Historical bytes
istream_t inputStream;
ostream_t outputStream;
//PDU buffer (tx)
uint8_t txBuf[2];
buffer_builder_t txBldr;
ac_buffer_builder_t txBldr;
//Receive buffer
uint8_t rxBuf[ISO7816_RX_BUFFER_SIZE];
buffer_builder_t rxBldr;
ac_buffer_builder_t rxBldr;
};
void nfc_tech_iso7816_init(nfc_tech_iso7816_t *pIso7816, nfc_transceiver_t *pTransceiver, nfc_tech_iso7816_disconnected_cb disconnectedCb, void *pUserData);

View File

@ -26,7 +26,6 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "iso7816.h"
struct nfc_tech_iso7816;

View File

@ -25,9 +25,9 @@
#define __MODULE__ "isodep_target.c"
#endif
#include "inc/nfc.h"
#include "isodep_target.h"
#include "stack/nfc_errors.h"
#include "transceiver/transceiver.h"
//Private defines
@ -84,12 +84,12 @@ enum __dep_type {
static void dep_init(nfc_tech_isodep_target_t *pIsodepTarget);
static bool dep_ready(nfc_tech_isodep_target_t *pIsodepTarget);
static void dep_req_information(nfc_tech_isodep_target_t *pIsodepTarget, buffer_t *pReq, bool moreInformation, uint8_t blockNumber);
static void dep_req_information(nfc_tech_isodep_target_t *pIsodepTarget, ac_buffer_t *pReq, bool moreInformation, uint8_t blockNumber);
static void dep_req_response(nfc_tech_isodep_target_t *pIsodepTarget, bool ack, uint8_t blockNumber);
static void dep_req_supervisory(nfc_tech_isodep_target_t *pIsodepTarget, bool wtxNDeselect, uint8_t wtxm);
static dep_type_t dep_res_type(nfc_tech_isodep_target_t *pIsodepTarget);
static void dep_res_information(nfc_tech_isodep_target_t *pIsodepTarget, size_t maxLength, buffer_t **ppRes, bool *pMoreInformation, uint8_t *pBlockNumber);
static void dep_res_information(nfc_tech_isodep_target_t *pIsodepTarget, size_t maxLength, ac_buffer_t **ppRes, bool *pMoreInformation, uint8_t *pBlockNumber);
static void dep_res_response(nfc_tech_isodep_target_t *pIsodepTarget, bool *pAck, uint8_t *pBlockNumber);
static void dep_res_supervisory(nfc_tech_isodep_target_t *pIsodepTarget, bool *pWtxNDeselect, uint8_t *pWtxm);
@ -108,7 +108,7 @@ static void command_transceiver_cb(nfc_transceiver_t *pTransceiver, nfc_err_t re
//High-level Target functions
void nfc_tech_isodep_target_init(nfc_tech_isodep_target_t *pIsodepTarget, nfc_transceiver_t *pTransceiver,
buffer_t *pHist, nfc_tech_isodep_disconnected_cb disconnectedCb, void *pUserData)
ac_buffer_t *pHist, nfc_tech_isodep_disconnected_cb disconnectedCb, void *pUserData)
{
pIsodepTarget->pTransceiver = pTransceiver;
@ -206,7 +206,7 @@ bool dep_ready(nfc_tech_isodep_target_t *pIsodepTarget)
}
}
void dep_req_information(nfc_tech_isodep_target_t *pIsodepTarget, buffer_t *pReq, bool moreInformation, uint8_t blockNumber)
void dep_req_information(nfc_tech_isodep_target_t *pIsodepTarget, ac_buffer_t *pReq, bool moreInformation, uint8_t blockNumber)
{
(void) blockNumber;
@ -303,7 +303,7 @@ dep_type_t dep_res_type(nfc_tech_isodep_target_t *pIsodepTarget)
return depType;
}
void dep_res_information(nfc_tech_isodep_target_t *pIsodepTarget, size_t maxLength, buffer_t **ppRes, bool *pMoreInformation, uint8_t *pBlockNumber)
void dep_res_information(nfc_tech_isodep_target_t *pIsodepTarget, size_t maxLength, ac_buffer_t **ppRes, bool *pMoreInformation, uint8_t *pBlockNumber)
{
*pBlockNumber = pIsodepTarget->dep.blockNumber;
if (pIsodepTarget->dep.frameState != ISO_DEP_TARGET_DEP_FRAME_NACK_RECEIVED) {
@ -505,7 +505,7 @@ nfc_err_t command_dep_res(nfc_tech_isodep_target_t *pIsodepTarget)
pcb |= PFB_DID;
}*/
buffer_t *pDepBuf = NULL;
ac_buffer_t *pDepBuf = NULL;
bool moreInformation = false;
bool ack = false;
bool wtxNDeselect = false;
@ -588,7 +588,7 @@ void command_reply(nfc_tech_isodep_target_t *pIsodepTarget, bool depWait)
transceiver_set_transceive_options(pIsodepTarget->pTransceiver, true, true, false);
}
DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pIsodepTarget->commands.respBldr));)
NFC_DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pIsodepTarget->commands.respBldr));)
//Send next frame
transceiver_set_write(pIsodepTarget->pTransceiver, buffer_builder_buffer(&pIsodepTarget->commands.respBldr));
@ -637,9 +637,9 @@ void command_transceiver_cb(nfc_transceiver_t *pTransceiver, nfc_err_t ret, void
}
NFC_DBG("Reading data from initiator");
buffer_t *pDataInitiator = transceiver_get_read(pTransceiver); //In buffer
ac_buffer_t *pDataInitiator = transceiver_get_read(pTransceiver); //In buffer
DBG_BLOCK(buffer_dump(pDataInitiator);)
NFC_DBG_BLOCK(buffer_dump(pDataInitiator);)
//Framing is handled by transceiver
if ((buffer_reader_readable(pDataInitiator) < 1)) {
@ -653,7 +653,7 @@ void command_transceiver_cb(nfc_transceiver_t *pTransceiver, nfc_err_t ret, void
pIsodepTarget->commands.pReq = pDataInitiator;
//Duplicate to peek on req
buffer_t dataInitiatorDup;
ac_buffer_t dataInitiatorDup;
buffer_dup(&dataInitiatorDup, pDataInitiator);
uint8_t req = buffer_read_nu8(&dataInitiatorDup);

View File

@ -27,7 +27,6 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "transceiver/transceiver.h"
#include "isodep.h"
@ -49,7 +48,7 @@ struct nfc_tech_isodep_target {
nfc_tech_isodep_cb_t resCb;
void *pResUserData;
buffer_t res;
ac_buffer_t res;
bool chaining;
uint8_t blockNumber;
@ -84,13 +83,13 @@ struct nfc_tech_isodep_target {
size_t inPayloadSize;
buffer_builder_t respBldr;
ac_buffer_builder_t respBldr;
uint8_t respBuf[32];
buffer_t *pReq;
ac_buffer_t *pReq;
} commands;
buffer_t *pHist;
ac_buffer_t *pHist;
nfc_tech_isodep_disconnected_cb disconnectedCb;
void *pUserData;
@ -98,7 +97,7 @@ struct nfc_tech_isodep_target {
//High-level Target functions
void nfc_tech_isodep_target_init(nfc_tech_isodep_target_t *pIsodepTarget, nfc_transceiver_t *pTransceiver,
buffer_t *pHist, nfc_tech_isodep_disconnected_cb disconnectedCb, void *pUserData);
ac_buffer_t *pHist, nfc_tech_isodep_disconnected_cb disconnectedCb, void *pUserData);
nfc_err_t nfc_tech_isodep_target_connect(nfc_tech_isodep_target_t *pIsodepTarget);
void nfc_tech_isodep_target_disconnect(nfc_tech_isodep_target_t *pIsodepTarget);

View File

@ -25,7 +25,7 @@
#define __MODULE__ "type4_target.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "type4_target.h"
#include "tech/iso7816/iso7816_defs.h"
@ -45,8 +45,8 @@ static void app_selected(nfc_tech_iso7816_app_t *pIso7816App, void *pUserData);
static void app_deselected(nfc_tech_iso7816_app_t *pIso7816App, void *pUserData);
static void app_apdu(nfc_tech_iso7816_app_t *pIso7816App, void *pUserData);
static nfc_err_t data_read(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint16_t file, size_t off, size_t len);
static nfc_err_t data_write(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint16_t file, size_t off);
static nfc_err_t data_read(nfc_tech_type4_target_t *pType4Target, ac_buffer_t *pBuf, uint16_t file, size_t off, size_t len);
static nfc_err_t data_write(nfc_tech_type4_target_t *pType4Target, ac_buffer_t *pBuf, uint16_t file, size_t off);
void nfc_tech_type4_target_init(nfc_tech_type4_target_t *pType4Target, nfc_tech_iso7816_t *pIso7816, ndef_msg_t *pNdef)
{
@ -187,7 +187,7 @@ void app_apdu(nfc_tech_iso7816_app_t *pIso7816App, void *pUserData)
ret = data_read(pType4Target, &pRApdu->dataOut, pType4Target->selFile, (pCApdu->p1 << 8) | pCApdu->p2, pCApdu->maxRespLength);
if (ret == NFC_OK) {
DBG("Read %d bytes", buffer_reader_readable(&pRApdu->dataOut));
DBG_BLOCK(buffer_dump(&pRApdu->dataOut);)
NFC_DBG_BLOCK(buffer_dump(&pRApdu->dataOut);)
pRApdu->sw = ISO7816_SW_OK;
} else {
DBG("Failed with ret code %d", ret);
@ -215,9 +215,9 @@ void app_apdu(nfc_tech_iso7816_app_t *pIso7816App, void *pUserData)
nfc_tech_iso7816_app_reply(pIso7816App);
}
nfc_err_t data_read(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint16_t file, size_t off, size_t len)
nfc_err_t data_read(nfc_tech_type4_target_t *pType4Target, ac_buffer_t *pBuf, uint16_t file, size_t off, size_t len)
{
buffer_t *pFile;
ac_buffer_t *pFile;
switch (file) {
case CC_FILE:
pFile = buffer_builder_buffer(&pType4Target->ccFileBldr);
@ -244,9 +244,9 @@ nfc_err_t data_read(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint1
return NFC_OK;
}
nfc_err_t data_write(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint16_t file, size_t off)
nfc_err_t data_write(nfc_tech_type4_target_t *pType4Target, ac_buffer_t *pBuf, uint16_t file, size_t off)
{
buffer_t *pFile;
ac_buffer_t *pFile;
switch (file) {
case NDEF_FILE:
pFile = buffer_builder_buffer(&pType4Target->ndefFileBldr);
@ -270,7 +270,7 @@ nfc_err_t data_write(nfc_tech_type4_target_t *pType4Target, buffer_t *pBuf, uint
while (len > 0) {
size_t cpy;
buffer_builder_t builder;
ac_buffer_builder_t builder;
buffer_dup(buffer_builder_buffer(&builder), pFile);
buffer_builder_from_buffer(&builder);
cpy = buffer_builder_writeable(&builder);

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "tech/iso7816/iso7816.h"
#include "tech/iso7816/iso7816_app.h"
@ -43,10 +43,10 @@ struct nfc_tech_type4_target {
ndef_msg_t *pNdef;
uint8_t ccFileBuf[15];
buffer_builder_t ccFileBldr;
ac_buffer_builder_t ccFileBldr;
uint8_t ndefFileBuf[2];
buffer_builder_t ndefFileBldr;
ac_buffer_builder_t ndefFileBldr;
uint16_t selFile;

View File

@ -25,7 +25,7 @@
#ifndef __MODULE__
#define __MODULE__ "pn512.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "stdlib.h"
@ -141,7 +141,7 @@ nfc_err_t pn512_init(pn512_t *pPN512, nfc_transport_t *pTransport, nfc_scheduler
pn512_cmd_wait_idle(pPN512, -1);
const uint8_t null_array_buf[25] = {0}; //FIXME
buffer_t null_array;
ac_buffer_t null_array;
buffer_init(&null_array, null_array_buf, 25);
//Perform self test
@ -159,7 +159,7 @@ nfc_err_t pn512_init(pn512_t *pPN512, nfc_transport_t *pTransport, nfc_scheduler
DBGX_ENTER();
NFC_DBG("Test result:");
while (pn512_fifo_length(pPN512)) {
buffer_builder_t read_byte;
ac_buffer_builder_t read_byte;
buffer_builder_init(&read_byte, null_array_buf, 1);
pn512_fifo_read(pPN512, &read_byte);
@ -171,7 +171,7 @@ nfc_err_t pn512_init(pn512_t *pPN512, nfc_transport_t *pTransport, nfc_scheduler
r = pn512_register_read(pPN512, PN512_REG_VERSION);
DBG_BLOCK(
NFC_DBG_BLOCK(
NFC_DBG("PN512 version %02x", r);
)
@ -274,7 +274,7 @@ void pn512_set_transceive_framing(nfc_transceiver_t *pTransceiver, nfc_framing_t
}
}
void pn512_set_write(nfc_transceiver_t *pTransceiver, buffer_t *pWriteBuf)
void pn512_set_write(nfc_transceiver_t *pTransceiver, ac_buffer_t *pWriteBuf)
{
pn512_t *pPN512 = (pn512_t *) pTransceiver;
if (pWriteBuf == NULL) {
@ -284,7 +284,7 @@ void pn512_set_write(nfc_transceiver_t *pTransceiver, buffer_t *pWriteBuf)
buffer_dup(&pPN512->writeBuf, pWriteBuf);
}
buffer_t *pn512_get_read(nfc_transceiver_t *pTransceiver)
ac_buffer_t *pn512_get_read(nfc_transceiver_t *pTransceiver)
{
pn512_t *pPN512 = (pn512_t *) pTransceiver;
return buffer_builder_buffer(&pPN512->readBufBldr);

View File

@ -75,8 +75,8 @@ typedef struct __pn512 {
uint16_t irqsEn;
uint8_t payload[256]; //Incoming buffer
buffer_builder_t readBufBldr;
buffer_t writeBuf;
ac_buffer_builder_t readBufBldr;
ac_buffer_t writeBuf;
uint8_t readFirstByteAlign;
uint8_t readLastByteLength;

View File

@ -26,7 +26,7 @@
#ifndef __MODULE__
#define __MODULE__ "pn512_cmd.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_cmd.h"
@ -57,7 +57,7 @@ void pn512_cmd_init(pn512_t *pPN512)
* \param pPN512 pointer to pn512_t structure
* \param pData buffer to write
*/
void pn512_fifo_write(pn512_t *pPN512, buffer_t *pData)
void pn512_fifo_write(pn512_t *pPN512, ac_buffer_t *pData)
{
uint8_t fifo_space = pn512_fifo_space(pPN512); //Do not call this fn twice
size_t len = buffer_reader_readable(pData);
@ -71,7 +71,7 @@ void pn512_fifo_write(pn512_t *pPN512, buffer_t *pData)
* \param pPN512 pointer to pn512_t structure
* \param pData buffer in which to read
*/
void pn512_fifo_read(pn512_t *pPN512, buffer_builder_t *pData)
void pn512_fifo_read(pn512_t *pPN512, ac_buffer_builder_t *pData)
{
uint8_t fifo_len = pn512_fifo_length(pPN512); //Do not call this fn twice
size_t len = buffer_builder_writeable(pData);

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"
@ -51,8 +51,8 @@ void pn512_cmd_init(pn512_t *pPN512);
//Fifo read / write
void pn512_fifo_write(pn512_t *pPN512, buffer_t *pData);
void pn512_fifo_read(pn512_t *pPN512, buffer_builder_t *pData);
void pn512_fifo_write(pn512_t *pPN512, ac_buffer_t *pData);
void pn512_fifo_read(pn512_t *pPN512, ac_buffer_builder_t *pData);
//Fifo clear
void pn512_fifo_clear(pn512_t *pPN512);

View File

@ -21,7 +21,7 @@
* \details Format and execute PN512 frames
*/
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_hw.h"

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"
@ -59,7 +59,7 @@ static inline void pn512_hw_read(pn512_t *pPN512, uint8_t addr, uint8_t *buf, si
nfc_transport_read(((nfc_transceiver_t *)pPN512)->pTransport, addr, buf, len);
}
static inline void pn512_hw_write_buffer(pn512_t *pPN512, uint8_t addr, buffer_t *pData, size_t len)
static inline void pn512_hw_write_buffer(pn512_t *pPN512, uint8_t addr, ac_buffer_t *pData, size_t len)
{
while (len > 0) {
if (buffer_reader_readable(pData) == 0) {
@ -72,7 +72,7 @@ static inline void pn512_hw_write_buffer(pn512_t *pPN512, uint8_t addr, buffer_t
}
}
static inline void pn512_hw_read_buffer(pn512_t *pPN512, uint8_t addr, buffer_builder_t *pData, size_t len)
static inline void pn512_hw_read_buffer(pn512_t *pPN512, uint8_t addr, ac_buffer_builder_t *pData, size_t len)
{
while (len > 0) {
if (buffer_builder_writeable(pData) == 0) {

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "transceiver/transceiver_internal.h"
@ -41,8 +41,8 @@ void pn512_set_crc(nfc_transceiver_t *pTransceiver, bool crc_out, bool crc_in);
void pn512_set_timeout(nfc_transceiver_t *pTransceiver, int timeout);
void pn512_set_transceive_options(nfc_transceiver_t *pTransceiver, bool transmit, bool receive, bool repoll);
void pn512_set_transceive_framing(nfc_transceiver_t *pTransceiver, nfc_framing_t framing);
void pn512_set_write(nfc_transceiver_t *pTransceiver, buffer_t *pWriteBuf);
buffer_t *pn512_get_read(nfc_transceiver_t *pTransceiver);
void pn512_set_write(nfc_transceiver_t *pTransceiver, ac_buffer_t *pWriteBuf);
ac_buffer_t *pn512_get_read(nfc_transceiver_t *pTransceiver);
size_t pn512_get_last_byte_length(nfc_transceiver_t *pTransceiver);
void pn512_set_last_byte_length(nfc_transceiver_t *pTransceiver, size_t lastByteLength);
void pn512_set_first_byte_align(nfc_transceiver_t *pTransceiver, size_t firstByteAlign);

View File

@ -25,7 +25,7 @@
#ifndef __MODULE__
#define __MODULE__ "pn512_irq.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_irq.h"
#include "pn512_registers.h"

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"
#include "pn512_registers.h"

View File

@ -25,7 +25,7 @@
#define __MODULE__ "pn512_poll.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"
#include "pn512_poll.h"
@ -111,7 +111,7 @@ void pn512_target_anticollision_complete(pn512_t *pPN512, nfc_err_t ret)
pn512_register_write(pPN512, PN512_REG_MIFNFC, 0x62 | 0x04);
//Copy buffer to peek
buffer_t readBufDup;
ac_buffer_t readBufDup;
buffer_dup(&readBufDup, buffer_builder_buffer(&pPN512->readBufBldr));
uint8_t b0 = buffer_read_nu8(&readBufDup);
@ -203,7 +203,7 @@ void pn512_initiator_isoa_anticollision(pn512_t *pPN512, pn512_cb_t cb)
void pn512_initiator_isoa_anticollision_reqa(pn512_t *pPN512)
{
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
pPN512->transceiver.remote_targets[pPN512->transceiver.remote_targets_count].nfcA.uidLength = 0;
@ -229,7 +229,7 @@ void pn512_initiator_isoa_anticollision_atqa(pn512_t *pPN512, nfc_err_t ret)
return;
}
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
if (buffer_reader_readable(pResp) != 2) {
NFC_WARN("Wrong length (%u bytes)", buffer_reader_readable(pResp));
@ -238,7 +238,7 @@ void pn512_initiator_isoa_anticollision_atqa(pn512_t *pPN512, nfc_err_t ret)
}
NFC_DBG("Got ATQA:");
DBG_BLOCK(buffer_dump(pResp);)
NFC_DBG_BLOCK(buffer_dump(pResp);)
// Ignore ATQA as there can be collisions
buffer_read_n_bytes(pResp, pPN512->transceiver.remote_targets[pPN512->transceiver.remote_targets_count].nfcA.atqa, 2);
@ -254,7 +254,7 @@ void pn512_initiator_isoa_anticollision_atqa(pn512_t *pPN512, nfc_err_t ret)
void pn512_initiator_isoa_anticollision_cascade_1(pn512_t *pPN512)
{
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
//SEL
@ -285,7 +285,7 @@ void pn512_initiator_isoa_anticollision_cascade_1(pn512_t *pPN512)
void pn512_initiator_isoa_anticollision_cascade_2(pn512_t *pPN512, nfc_err_t ret)
{
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
// Load & clear collisions register
// FIXME PN512 Anomaly: pn512_register_write(pPN512, PN512_REG_COLL, 0x80); // Set MSB to 1, to treat collisions as errors
@ -384,7 +384,7 @@ void pn512_initiator_isoa_anticollision_cascade_2(pn512_t *pPN512, nfc_err_t ret
pPN512->transceiver.remote_targets[pPN512->transceiver.remote_targets_count].nfcA.uidLength += 4;
}
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
//Select and get SAK
@ -404,7 +404,7 @@ void pn512_initiator_isoa_anticollision_cascade_2(pn512_t *pPN512, nfc_err_t ret
static void pn512_initiator_isoa_anticollision_cascade_3(pn512_t *pPN512, nfc_err_t ret)
{
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
if (ret) {
NFC_WARN("Did not receive response: error %d", ret);
@ -465,7 +465,7 @@ static void pn512_initiator_isoa_anticollision_cascade_3(pn512_t *pPN512, nfc_er
&& pPN512->anticollision.iso_a.more_targets
&& (pPN512->transceiver.remote_targets_count < MUNFC_MAX_REMOTE_TARGETS)) {
// Halt target and continue with others
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
//HALTA
@ -527,7 +527,7 @@ void pn512_initiator_isob_anticollision(pn512_t *pPN512, pn512_cb_t cb)
void pn512_initiator_isob_anticollision_reqb(pn512_t *pPN512)
{
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
if (pPN512->anticollision.iso_b.slot_number == 0) {
@ -558,7 +558,7 @@ void pn512_initiator_isob_anticollision_atqb(pn512_t *pPN512, nfc_err_t ret)
// - 1 response --> store response, halt PICC and check next slot number
// - No response --> check next slot number
// - Collision --> check next slot number but we will have to increment number of slots
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
if (ret && (ret != NFC_ERR_COLLISION) && (ret != NFC_ERR_WRONG_COMM) && (ret != NFC_ERR_TIMEOUT)) {
NFC_WARN("Did not receive ATQB: error %u", ret);
@ -582,7 +582,7 @@ void pn512_initiator_isob_anticollision_atqb(pn512_t *pPN512, nfc_err_t ret)
}
NFC_DBG("Got ATQB:");
DBG_BLOCK(buffer_dump(pResp);)
NFC_DBG_BLOCK(buffer_dump(pResp);)
// Check first byte
uint8_t atqb0 = buffer_read_nu8(pResp);
@ -608,7 +608,7 @@ void pn512_initiator_isob_anticollision_atqb(pn512_t *pPN512, nfc_err_t ret)
&& (pPN512->anticollision.iso_b.more_targets || (pPN512->anticollision.iso_b.slot_number < (1 << pPN512->anticollision.iso_b.slots_num_exponent)))
&& (pPN512->transceiver.remote_targets_count < MUNFC_MAX_REMOTE_TARGETS)) {
// Halt target and continue with others
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
// Halt PICC and move on to the next slot
@ -660,7 +660,7 @@ void pn512_initiator_isob_anticollision_haltb_resp(pn512_t *pPN512, nfc_err_t re
return;
}
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
if (buffer_reader_readable(pResp) != 1) {
NFC_WARN("Wrong length (%u bytes)", buffer_reader_readable(pResp));
@ -669,7 +669,7 @@ void pn512_initiator_isob_anticollision_haltb_resp(pn512_t *pPN512, nfc_err_t re
}
NFC_DBG("Got HALTB response:");
DBG_BLOCK(buffer_dump(pResp);)
NFC_DBG_BLOCK(buffer_dump(pResp);)
// Check byte
uint8_t haltbr = buffer_read_nu8(pResp);
@ -712,7 +712,7 @@ void pn512_initiator_felica_anticollision(pn512_t *pPN512, pn512_cb_t cb)
void pn512_initiator_felica_anticollision_reqc(pn512_t *pPN512)
{
buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataOutBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataOutBldr);
buffer_builder_write_nu8(pDataOutBldr, 6); //Length
@ -732,7 +732,7 @@ void pn512_initiator_felica_anticollision_reqc(pn512_t *pPN512)
void pn512_initiator_felica_anticollision_atqc(pn512_t *pPN512, nfc_err_t ret)
{
buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
ac_buffer_t *pResp = pn512_get_read((nfc_transceiver_t *)pPN512);
if (ret || (buffer_reader_readable(pResp) == 0)) {
NFC_WARN("Did not receive ATQC: error %d", ret);
@ -742,7 +742,7 @@ void pn512_initiator_felica_anticollision_atqc(pn512_t *pPN512, nfc_err_t ret)
// We might have multiple responses
NFC_DBG("Got ATQC:");
DBG_BLOCK(buffer_dump(pResp);)
NFC_DBG_BLOCK(buffer_dump(pResp);)
while (buffer_reader_readable(pResp) > 0) {
if (buffer_reader_readable(pResp) != 18 + 1) { // ATQC is 18 bytes, 1 byte for errors added by PN512
@ -827,7 +827,7 @@ void pn512_poll_setup(pn512_t *pPN512)
//Setup ATQA, SAK and Felica polling response
pn512_fifo_clear(pPN512);
buffer_builder_t *pDataCfgBldr = &pPN512->readBufBldr;
ac_buffer_builder_t *pDataCfgBldr = &pPN512->readBufBldr;
buffer_builder_reset(pDataCfgBldr);
//Write ATQA

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
void pn512_poll_setup(pn512_t *pPN512);

View File

@ -27,7 +27,7 @@
#ifndef __MODULE__
#define __MODULE__ "pn512_registers.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_registers.h"
#include "pn512_hw.h"
@ -111,7 +111,7 @@ void pn512_register_write(pn512_t *pPN512, uint8_t address, uint8_t data)
uint8_t pn512_register_read(pn512_t *pPN512, uint8_t address)
{
uint8_t data;
DBG_BLOCK(
NFC_DBG_BLOCK(
uint8_t __dbg_addr;
__dbg_addr = address; //FIXME
)

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"

View File

@ -25,7 +25,7 @@
#define __MODULE__ "pn512_rf.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_callback.h"
#include "pn512_rf.h"

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_callback.h"
#include "pn512.h"
#include "pn512_rf.h"

View File

@ -20,7 +20,7 @@
* \author Donatien Garnier
*/
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512_timer.h"
#include "pn512_registers.h"

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
typedef struct __pn512 pn512_t;

View File

@ -25,7 +25,7 @@
#define __MODULE__ "pn512_transceive.c"
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
#include "pn512.h"
#include "pn512_transceive.h"
@ -273,7 +273,7 @@ void pn512_transceive_hw_rx_task(uint32_t events, void *pUserData)
irqs &= ~PN512_IRQ_ERR;
irqs |= PN512_IRQ_RX;
} else {
DBG_BLOCK(
NFC_DBG_BLOCK(
//Empty FIFO into buffer
pn512_fifo_read(pPN512, &pPN512->readBufBldr);
@ -333,7 +333,7 @@ void pn512_transceive_hw_rx_task(uint32_t events, void *pUserData)
pn512_irq_clear(pPN512, PN512_IRQ_RX | PN512_IRQ_HIGH_ALERT);
NFC_DBG("Received:");
DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pPN512->readBufBldr));)
NFC_DBG_BLOCK(buffer_dump(buffer_builder_buffer(&pPN512->readBufBldr));)
if ((pPN512->transceive.mode == pn512_transceive_mode_target_autocoll) || (pPN512->transceive.mode == pn512_transceive_mode_transmit_and_target_autocoll)) {
//Check if target was activated
@ -423,7 +423,7 @@ void pn512_transceive_hw(pn512_t *pPN512, pn512_transceive_mode_t mode, pn512_cb
return;
} else {
NFC_DBG("Sending:");
DBG_BLOCK(buffer_dump(&pPN512->writeBuf);)
NFC_DBG_BLOCK(buffer_dump(&pPN512->writeBuf);)
//Transmit a frame to remote target/initiator
irqs_en = PN512_IRQ_TX | PN512_IRQ_IDLE;

View File

@ -27,7 +27,7 @@
extern "C" {
#endif
#include "inc/nfc.h"
#include "stack/nfc_errors.h"
typedef struct __nfc_tech nfc_tech_t;
typedef struct __transceiver nfc_transceiver_t;
typedef struct __transceiver_impl transceiver_impl_t;
@ -76,8 +76,8 @@ typedef void (*set_crc_fn_t)(nfc_transceiver_t *pTransceiver, bool crcOut, bool
typedef void (*set_timeout_fn_t)(nfc_transceiver_t *pTransceiver, int timeout);
typedef void (*set_transceive_options_fn_t)(nfc_transceiver_t *pTransceiver, bool transmit, bool receive, bool repoll);
typedef void (*set_transceive_framing_fn_t)(nfc_transceiver_t *pTransceiver, nfc_framing_t framing);
typedef void (*set_write_fn_t)(nfc_transceiver_t *pTransceiver, buffer_t *pWriteBuf); //Set write buffer
typedef buffer_t *(*get_read_fn_t)(nfc_transceiver_t *pTransceiver); //Get read buffer
typedef void (*set_write_fn_t)(nfc_transceiver_t *pTransceiver, ac_buffer_t *pWriteBuf); //Set write buffer
typedef ac_buffer_t *(*get_read_fn_t)(nfc_transceiver_t *pTransceiver); //Get read buffer
typedef size_t (*get_last_byte_length_fn_t)(nfc_transceiver_t *pTransceiver);
typedef void (*set_last_byte_length_fn_t)(nfc_transceiver_t *pTransceiver, size_t lastByteLength);
typedef size_t (*get_first_byte_align_fn_t)(nfc_transceiver_t *pTransceiver);
@ -188,12 +188,12 @@ static inline void transceiver_set_transceive_framing(nfc_transceiver_t *pTransc
pTransceiver->fn->set_transceive_framing(pTransceiver, framing);
}
static inline void transceiver_set_write(nfc_transceiver_t *pTransceiver, buffer_t *pWriteBuf)
static inline void transceiver_set_write(nfc_transceiver_t *pTransceiver, ac_buffer_t *pWriteBuf)
{
pTransceiver->fn->set_write(pTransceiver, pWriteBuf);
}
static inline buffer_t *transceiver_get_read(nfc_transceiver_t *pTransceiver)
static inline ac_buffer_t *transceiver_get_read(nfc_transceiver_t *pTransceiver)
{
return pTransceiver->fn->get_read(pTransceiver);
}