mirror of https://github.com/ARMmbed/mbed-os.git
Enable NFC debug
parent
17b5e2ef3e
commit
e7b2ec347f
|
@ -138,6 +138,8 @@ void NFCController::polling_callback(nfc_err_t ret)
|
|||
// Polling has completed
|
||||
_discovery_running = false;
|
||||
|
||||
NFC_DBG("Polling finished with result %u", ret);
|
||||
|
||||
if (ret == NFC_OK) {
|
||||
// Check if a remote initiator was detected and if so, instantiate it
|
||||
if (!transceiver_is_initiator_mode(_transceiver)) {
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#define MBED_NFC_DEBUG_H
|
||||
|
||||
#if NFC_DEBUG && !defined(NDEBUG)
|
||||
#ifdef __MODULE__
|
||||
#define __NFC_MODULE__ __MODULE__
|
||||
#else
|
||||
#define __NFC_MODULE__ __FILE__
|
||||
#endif
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
static inline void nfc_dbg_print(const char *type, const char *module, unsigned int line, const char *fmt, ...)
|
||||
|
@ -34,15 +40,15 @@ static inline void nfc_dbg_print(const char *type, const char *module, unsigned
|
|||
}
|
||||
|
||||
#if !defined(NFC_DBG)
|
||||
#define NFC_DBG(...) nfc_dbg_print("DBG", __MODULE__, __LINE__, __VA_ARGS__)
|
||||
#define NFC_DBG(...) nfc_dbg_print("DBG", __NFC_MODULE__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if !defined(NFC_WARN)
|
||||
#define NFC_WARN(...) nfc_dbg_print("WARN", __MODULE__, __LINE__, __VA_ARGS__)
|
||||
#define NFC_WARN(...) nfc_dbg_print("WARN", __NFC_MODULE__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if !defined(NFC_ERR)
|
||||
#define NFC_ERR(...) nfc_dbg_print("ERR", __MODULE__, __LINE__, __VA_ARGS__)
|
||||
#define NFC_ERR(...) nfc_dbg_print("ERR", __NFC_MODULE__, __LINE__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define NFC_DBG_BLOCK(x) x
|
||||
|
|
|
@ -238,7 +238,7 @@ void pn512_initiator_isoa_anticollision_atqa(pn512_t *pPN512, nfc_err_t ret)
|
|||
}
|
||||
|
||||
NFC_DBG("Got ATQA:");
|
||||
NFC_DBG_BLOCK(buffer_dump(pResp);)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(pResp);)
|
||||
|
||||
// Ignore ATQA as there can be collisions
|
||||
ac_buffer_read_n_bytes(pResp, pPN512->transceiver.remote_targets[pPN512->transceiver.remote_targets_count].nfcA.atqa, 2);
|
||||
|
@ -582,7 +582,7 @@ void pn512_initiator_isob_anticollision_atqb(pn512_t *pPN512, nfc_err_t ret)
|
|||
}
|
||||
|
||||
NFC_DBG("Got ATQB:");
|
||||
NFC_DBG_BLOCK(buffer_dump(pResp);)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(pResp);)
|
||||
|
||||
// Check first byte
|
||||
uint8_t atqb0 = ac_buffer_read_nu8(pResp);
|
||||
|
@ -669,7 +669,7 @@ void pn512_initiator_isob_anticollision_haltb_resp(pn512_t *pPN512, nfc_err_t re
|
|||
}
|
||||
|
||||
NFC_DBG("Got HALTB response:");
|
||||
NFC_DBG_BLOCK(buffer_dump(pResp);)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(pResp);)
|
||||
|
||||
// Check byte
|
||||
uint8_t haltbr = ac_buffer_read_nu8(pResp);
|
||||
|
@ -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:");
|
||||
NFC_DBG_BLOCK(buffer_dump(pResp);)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(pResp);)
|
||||
|
||||
while (ac_buffer_reader_readable(pResp) > 0) {
|
||||
if (ac_buffer_reader_readable(pResp) != 18 + 1) { // ATQC is 18 bytes, 1 byte for errors added by PN512
|
||||
|
|
|
@ -278,7 +278,7 @@ void pn512_transceive_hw_rx_task(uint32_t events, void *pUserData)
|
|||
pn512_fifo_read(pPN512, &pPN512->readBufBldr);
|
||||
|
||||
NFC_DBG("Received");
|
||||
buffer_dump(ac_buffer_builder_buffer(&pPN512->readBufBldr));
|
||||
ac_buffer_dump(ac_buffer_builder_buffer(&pPN512->readBufBldr));
|
||||
|
||||
NFC_DBG("Computed CRC = %02X %02X", pn512_register_read(pPN512, PN512_REG_CRCRESULT_MSB), pn512_register_read(pPN512, PN512_REG_CRCRESULT_LSB));
|
||||
|
||||
|
@ -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:");
|
||||
NFC_DBG_BLOCK(buffer_dump(ac_buffer_builder_buffer(&pPN512->readBufBldr));)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(ac_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:");
|
||||
NFC_DBG_BLOCK(buffer_dump(&pPN512->writeBuf);)
|
||||
NFC_DBG_BLOCK(ac_buffer_dump(&pPN512->writeBuf);)
|
||||
|
||||
//Transmit a frame to remote target/initiator
|
||||
irqs_en = PN512_IRQ_TX | PN512_IRQ_IDLE;
|
||||
|
|
Loading…
Reference in New Issue