Commit 1d36547d authored by Matej Frančeškin's avatar Matej Frančeškin
Browse files

Remove reference to NXP NFC Library. Keep only QtNFC.

parent a97230c7
/*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
/***** NFC dedicated setting ****************************************/
/* Following definitions specifies which settings will apply when NxpNci_ConfigureSettings()
* API is called from the application
*/
#define NXP_CORE_CONF 1
#define NXP_CORE_CONF_EXTN 1
#define NXP_CORE_STANDBY 1
#define NXP_CLK_CONF 1 // 1=Xtal, 2=PLL
#define NXP_TVDD_CONF 1 // 1=CFG1, 2=CFG2
#define NXP_RF_CONF 1
#if NXP_CORE_CONF
/* NCI standard dedicated settings
* Refer to NFC Forum NCI standard for more details
*/
uint8_t NxpNci_CORE_CONF[]={0x20, 0x02, 0x05, 0x01, /* CORE_SET_CONFIG_CMD */
0x00, 0x02, 0x00, 0x01 /* TOTAL_DURATION */
};
#endif
#if NXP_CORE_CONF_EXTN
/* NXP-NCI extension dedicated setting
* Refer to NFC controller User Manual for more details
*/
uint8_t NxpNci_CORE_CONF_EXTN[]={0x20, 0x02, 0x0D, 0x03, /* CORE_SET_CONFIG_CMD */
0xA0, 0x40, 0x01, 0x00, /* TAG_DETECTOR_CFG */
0xA0, 0x41, 0x01, 0x04, /* TAG_DETECTOR_THRESHOLD_CFG */
0xA0, 0x43, 0x01, 0x00 /* TAG_DETECTOR_FALLBACK_CNT_CFG */
};
#endif
#if NXP_CORE_STANDBY
/* NXP-NCI standby enable setting
* Refer to NFC controller User Manual for more details
*/
uint8_t NxpNci_CORE_STANDBY[]={0x2F, 0x00, 0x01, 0x01}; /* last byte indicates enable/disable */
#endif
#if NXP_CLK_CONF
/* NXP-NCI CLOCK configuration
* Refer to NFC controller Hardware Design Guide document for more details
*/
#if (NXP_CLK_CONF == 1)
/* Xtal configuration */
uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x05, 0x01, /* CORE_SET_CONFIG_CMD */
0xA0, 0x03, 0x01, 0x08 /* CLOCK_SEL_CFG */
};
#else
/* PLL configuration */
uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x09, 0x02, /* CORE_SET_CONFIG_CMD */
0xA0, 0x03, 0x01, 0x11, /* CLOCK_SEL_CFG */
0xA0, 0x04, 0x01, 0x01 /* CLOCK_TO_CFG */
};
#endif
#endif
#if NXP_TVDD_CONF
/* NXP-NCI TVDD configuration
* Refer to NFC controller Hardware Design Guide document for more details
*/
/* RF configuration related to 1st generation of NXP-NCI controller (e.g PN7120) */
uint8_t NxpNci_TVDD_CONF_1stGen[]={0x20, 0x02, 0x05, 0x01, 0xA0, 0x13, 0x01, 0x00};
/* RF configuration related to 2nd generation of NXP-NCI controller (e.g PN7150)*/
#if (NXP_TVDD_CONF == 1)
/* CFG1: Vbat is used to generate the VDD(TX) through TXLDO */
uint8_t NxpNci_TVDD_CONF_2ndGen[]={0x20, 0x02, 0x07, 0x01, 0xA0, 0x0E, 0x03, 0x02, 0x09, 0x00};
#else
/* CFG2: external 5V is used to generate the VDD(TX) through TXLDO */
uint8_t NxpNci_TVDD_CONF_2ndGen[]={0x20, 0x02, 0x07, 0x01, 0xA0, 0x0E, 0x03, 0x06, 0x64, 0x00};
#endif
#endif
#if NXP_RF_CONF
/* NXP-NCI RF configuration
* Refer to NFC controller Antenna Design and Tuning Guidelines document for more details
*/
/* RF configuration related to 1st generation of NXP-NCI controller (e.g PN7120) */
/* Following configuration is the default settings of PN7120 NFC Controller */
uint8_t NxpNci_RF_CONF_1stGen[]={0x20, 0x02, 0x38, 0x07,
0xA0, 0x0D, 0x06, 0x06, 0x42, 0x01, 0x00, 0xF1, 0xFF, /* RF_CLIF_CFG_TARGET CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x06, 0x06, 0x44, 0xA3, 0x90, 0x03, 0x00, /* RF_CLIF_CFG_TARGET CLIF_ANA_RX_REG */
0xA0, 0x0D, 0x06, 0x34, 0x2D, 0xDC, 0x50, 0x0C, 0x00, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x04, 0x06, 0x03, 0x00, 0x70, /* RF_CLIF_CFG_TARGET CLIF_TRANSCEIVE_CONTROL_REG */
0xA0, 0x0D, 0x03, 0x06, 0x16, 0x00, /* RF_CLIF_CFG_TARGET CLIF_TX_UNDERSHOOT_CONFIG_REG */
0xA0, 0x0D, 0x03, 0x06, 0x15, 0x00, /* RF_CLIF_CFG_TARGET CLIF_TX_OVERSHOOT_CONFIG_REG */
0xA0, 0x0D, 0x06, 0x32, 0x4A, 0x53, 0x07, 0x01, 0x1B /* RF_CLIF_CFG_BR_106_I_TXA CLIF_ANA_TX_SHAPE_CONTROL_REG */
};
/* RF configuration related to 2nd generation of NXP-NCI controller (e.g PN7150)*/
/* Following configuration relates to performance optimization of OM5578/PN7150 NFC Controller demo kit */
uint8_t NxpNci_RF_CONF_2ndGen[]={0x20, 0x02, 0xB7, 0x14,
0xA0, 0x0D, 0x06, 0x04, 0x35, 0x90, 0x01, 0xF4, 0x01, /* RF_CLIF_CFG_INITIATOR CLIF_AGC_INPUT_REG */
0xA0, 0x0D, 0x06, 0x06, 0x44, 0x01, 0x90, 0x03, 0x00, /* RF_CLIF_CFG_TARGET CLIF_ANA_RX_REG */
0xA0, 0x0D, 0x06, 0x06, 0x30, 0xB0, 0x01, 0x10, 0x00, /* RF_CLIF_CFG_TARGET CLIF_SIGPRO_ADCBCM_THRESHOLD_REG */
0xA0, 0x0D, 0x06, 0x06, 0x42, 0x02, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_TARGET CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x03, 0x06, 0x3F, 0x04, /* RF_CLIF_CFG_TARGET CLIF_TEST_CONTROL_REG */
0xA0, 0x0D, 0x06, 0x20, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_TECHNO_I_TX15693 CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x04, 0x22, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_TECHNO_I_RX15693 CLIF_ANA_RX_REG */
0xA0, 0x0D, 0x06, 0x22, 0x2D, 0x50, 0x34, 0x0C, 0x00, /* RF_CLIF_CFG_TECHNO_I_RX15693 CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x06, 0x32, 0x42, 0xF8, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_106_I_TXA CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x06, 0x34, 0x2D, 0x24, 0x37, 0x0C, 0x00, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x06, 0x34, 0x33, 0x86, 0x80, 0x00, 0x70, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_AGC_CONFIG0_REG */
0xA0, 0x0D, 0x04, 0x34, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_ANA_RX_REG */
0xA0, 0x0D, 0x06, 0x42, 0x2D, 0x15, 0x45, 0x0D, 0x00, /* RF_CLIF_CFG_BR_848_I_RXA CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x04, 0x46, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_BR_106_I_RXB CLIF_ANA_RX_REG */
0xA0, 0x0D, 0x06, 0x46, 0x2D, 0x05, 0x59, 0x0E, 0x00, /* RF_CLIF_CFG_BR_106_I_RXB CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x06, 0x44, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_106_I_TXB CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x06, 0x56, 0x2D, 0x05, 0x9F, 0x0C, 0x00, /* RF_CLIF_CFG_BR_212_I_RXF_P CLIF_SIGPRO_RM_CONFIG1_REG */
0xA0, 0x0D, 0x06, 0x54, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_212_I_TXF CLIF_ANA_TX_AMPLITUDE_REG */
0xA0, 0x0D, 0x06, 0x0A, 0x33, 0x80, 0x86, 0x00, 0x70, /* RF_CLIF_CFG_I_ACTIVE CLIF_AGC_CONFIG0_REG */
0xA0, 0x1D, 0x11, 0x57, 0x33, 0x14, 0x17, 0x00, 0xAA, 0x85, 0x00, 0x80, 0x55, 0x2A, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00
};
#endif
/*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
#define NDEF_EMPTY 0x00
#define NDEF_WELL_KNOWN 0x01
#define NDEF_MEDIA 0x02
#define NDEF_ABSOLUTE_URI 0x03
#define NDEF_EXTERNAL 0x04
#define NDEF_UNKNOWN 0x05
#define NDEF_UNCHANGED 0x06
#define NDEF_RESERVED 0x07
#define NDEF_RECORD_MB_MASK 0x80
#define NDEF_RECORD_ME_MASK 0x40
#define NDEF_RECORD_CF_MASK 0x20
#define NDEF_RECORD_SR_MASK 0x10
#define NDEF_RECORD_IL_MASK 0x08
#define NDEF_RECORD_TNF_MASK 0x07
typedef enum
{
WELL_KNOWN_SIMPLE_TEXT,
WELL_KNOWN_SIMPLE_URI,
WELL_KNOWN_SMART_POSTER,
WELL_KNOWN_HANDOVER_SELECT,
WELL_KNOWN_HANDOVER_REQUEST,
WELL_KNOWN_ALTERNATIVE_CARRIER,
WELL_KNOWN_COLLISION_RESOLUTION,
MEDIA_VCARD,
MEDIA_HANDOVER_WIFI,
MEDIA_HANDOVER_BT,
MEDIA_HANDOVER_BLE,
MEDIA_HANDOVER_BLE_SECURE,
ABSOLUTE_URI,
UNSUPPORTED_NDEF_RECORD = 0xFF
}NdefRecordType_e;
typedef struct
{
NdefRecordType_e recordType;
unsigned char * recordPayload;
unsigned int recordPayloadSize;
} NdefRecord_t;
const char* ndef_helper_WifiAuth(unsigned char auth);
const char* ndef_helper_WifiEnc(unsigned char enc);
const char* ndef_helper_UriHead(unsigned char head);
NdefRecord_t DetectNdefRecordType(unsigned char *pNdefRecord);
unsigned char* GetNextRecord(unsigned char *pNdefRecord);
/*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
extern "C" {
void task_nfc(void);
}
/*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <NfcTask/inc/ndef_helper.h>
const char* ndef_helper_WifiAuth(unsigned char auth)
{
switch (auth)
{
case 0x01: return "Open";
case 0x02: return "WPA-Personal";
case 0x04: return "Shared";
case 0x08: return "WPA-Enterprise";
case 0x10: return "WPA2-Enterprise";
case 0x20: return "WPA2-Personal";
default: return "unknown";
}
}
const char* ndef_helper_WifiEnc(unsigned char enc)
{
switch (enc)
{
case 0x01: return "None";
case 0x02: return "WEP";
case 0x04: return "TKIP";
case 0x08: return "AES";
case 0x10: return "AES/TKIP";
default: return "unknown";
}
}
const char* ndef_helper_UriHead(unsigned char head)
{
switch (head) {
case 0: return ("");
case 1: return ("http://www.");
case 2: return ("https://www.");
case 3: return ("http://");
case 4: return ("https://");
case 5: return ("tel:");
case 6: return ("mailto:");
default:return ("!!!unknown!!!");
}
}
NdefRecord_t DetectNdefRecordType(unsigned char *pNdefRecord)
{
NdefRecord_t record;
uint8_t typeField;
/* Short or normal record ?*/
if (pNdefRecord[0] & NDEF_RECORD_SR_MASK)
{
record.recordPayloadSize = pNdefRecord[2];
typeField = 3;
}
else
{
record.recordPayloadSize = (pNdefRecord[2]<<24) + (pNdefRecord[3]<<16) + (pNdefRecord[4]<<8) + pNdefRecord[5];
typeField = 6;
}
/* ID present ?*/
if(pNdefRecord[0] & NDEF_RECORD_IL_MASK)
{
record.recordPayload = pNdefRecord + typeField + pNdefRecord[1] + 1 + pNdefRecord[typeField];
typeField++;
}
else
{
record.recordPayload = pNdefRecord + typeField + pNdefRecord[1];
}
/* Well known Record Type ?*/
if ((pNdefRecord[0] & NDEF_RECORD_TNF_MASK) == NDEF_WELL_KNOWN)
{
if (pNdefRecord[1] == 0x1)
{
switch (pNdefRecord[typeField])
{
case 'T':
record.recordType = WELL_KNOWN_SIMPLE_TEXT;
break;
case 'U':
record.recordType = WELL_KNOWN_SIMPLE_URI;
break;
default:
record.recordType = UNSUPPORTED_NDEF_RECORD;
break;
}
} else if (pNdefRecord[1] == 0x2)
{
if (memcmp(&pNdefRecord[typeField], "Sp", pNdefRecord[1]) == 0x0)
{
record.recordType = WELL_KNOWN_SMART_POSTER;
}
else if (memcmp(&pNdefRecord[typeField], "Hs", pNdefRecord[1]) == 0x0)
{
record.recordType = WELL_KNOWN_HANDOVER_SELECT;
}
else if (memcmp(&pNdefRecord[typeField], "Hr", pNdefRecord[1]) == 0x0)
{
record.recordType = WELL_KNOWN_HANDOVER_REQUEST;
}
else if (memcmp(&pNdefRecord[typeField], "ac", pNdefRecord[1]) == 0x0)
{
record.recordType = WELL_KNOWN_ALTERNATIVE_CARRIER;
}
else if (memcmp(&pNdefRecord[typeField], "cr", pNdefRecord[1]) == 0x0)
{
record.recordType = WELL_KNOWN_COLLISION_RESOLUTION;
}
else
{
record.recordType = UNSUPPORTED_NDEF_RECORD;
}
}
}
/* Media Record Type ?*/
else if ((pNdefRecord[0] & NDEF_RECORD_TNF_MASK) == NDEF_MEDIA)
{
if ((memcmp(&pNdefRecord[typeField], "text/x-vCard", pNdefRecord[1]) == 0x0) ||
(memcmp(&pNdefRecord[typeField], "text/vcard", pNdefRecord[1]) == 0x0))
{
record.recordType = MEDIA_VCARD;
}
else if (memcmp(&pNdefRecord[typeField], "application/vnd.wfa.wsc", pNdefRecord[1]) == 0x0)
{
record.recordType = MEDIA_HANDOVER_WIFI;
}
else if (memcmp(&pNdefRecord[typeField], "application/vnd.bluetooth.ep.oob", pNdefRecord[1]) == 0x0)
{
record.recordType = MEDIA_HANDOVER_BT;
}
else if (memcmp(&pNdefRecord[typeField], "application/vnd.bluetooth.le.oob", pNdefRecord[1]) == 0x0)
{
record.recordType = MEDIA_HANDOVER_BLE;
}
else if (memcmp(&pNdefRecord[typeField], "application/vnd.bluetooth.secure.le.oob", pNdefRecord[1]) == 0x0)
{
record.recordType = MEDIA_HANDOVER_BLE_SECURE;
}
else
{
record.recordType = UNSUPPORTED_NDEF_RECORD;
}
}
/* Absolute URI Record Type ?*/
else if ((pNdefRecord[0] & NDEF_RECORD_TNF_MASK) == NDEF_ABSOLUTE_URI)
{
record.recordType = ABSOLUTE_URI;
}
else
{
record.recordType = UNSUPPORTED_NDEF_RECORD;
}
return record;
}
unsigned char* GetNextRecord(unsigned char *pNdefRecord)
{
unsigned char *temp = NULL;
/* Message End ?*/
if (!(pNdefRecord[0] & NDEF_RECORD_ME_MASK)) {
/* Short or normal record ?*/
if (pNdefRecord[0] & NDEF_RECORD_SR_MASK)
{
/* ID present ?*/
if(pNdefRecord[0] & NDEF_RECORD_IL_MASK)
temp = (pNdefRecord + 4 + pNdefRecord[1] + pNdefRecord[2] + pNdefRecord[3]);
else
temp = (pNdefRecord + 3 + pNdefRecord[1] + pNdefRecord[2]);
}
else
{
/* ID present ?*/
if(pNdefRecord[0] & NDEF_RECORD_IL_MASK)
temp = (pNdefRecord + 7 + pNdefRecord[1] + (pNdefRecord[2]<<24) + (pNdefRecord[3]<<16) + (pNdefRecord[4]<<8) + pNdefRecord[5] + pNdefRecord[6]);
else
temp = (pNdefRecord + 6 + pNdefRecord[1] + (pNdefRecord[2]<<24) + (pNdefRecord[3]<<16) + (pNdefRecord[4]<<8) + pNdefRecord[5]);
}
}
return temp;
}
This diff is collapsed.
......@@ -457,7 +457,7 @@ PairingManager::pairingLinkTypeStrings()
static QStringList list;
int i = 0;
if (!list.size()) {
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
#if defined QGC_ENABLE_QTNFC
list += tr("NFC");
_nfcIndex = i++;
#endif
......@@ -501,14 +501,14 @@ PairingManager::startMicrohardPairing()
void
PairingManager::stopPairing()
{
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
#if defined QGC_ENABLE_QTNFC
pairingNFC.stop();
#endif
_stopUpload();
setPairingStatus(PairingIdle, "");
}
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
#if defined QGC_ENABLE_QTNFC
//-----------------------------------------------------------------------------
void
PairingManager::startNFCScan()
......
......@@ -20,9 +20,6 @@
#include "QGCToolbox.h"
#include "QGCLoggingCategory.h"
#include "Fact.h"
#if defined QGC_ENABLE_NFC
#include "PairingNFC.h"
#endif
#if defined QGC_ENABLE_QTNFC
#include "QtNFC.h"
#endif
......@@ -79,7 +76,7 @@ public:
Q_INVOKABLE void connectToPairedDevice (QString name);
Q_INVOKABLE void removePairedDevice (QString name);
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
#if defined defined QGC_ENABLE_QTNFC
Q_INVOKABLE void startNFCScan();
#endif
#if QGC_GST_MICROHARD_ENABLED
......@@ -150,7 +147,7 @@ private:
QString _pairingCacheFile (QString uavName);
void _updatePairedDeviceNameList ();
#if defined QGC_ENABLE_NFC || defined QGC_ENABLE_QTNFC
#if defined QGC_ENABLE_QTNFC
PairingNFC pairingNFC;
#endif
};
/****************************************************************************
*
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "PairingManager.h"
#include "PairingNFC.h"
#include "QGCApplication.h"
#include <QSoundEffect>
QGC_LOGGING_CATEGORY(PairingNFCLog, "PairingNFCLog")
extern "C" {
#include <TML/inc/tool.h>
#include <NfcTask/inc/ndef_helper.h>
//-----------------------------------------------------------------------------
void logmsg(char *buf)
{
QString s = buf;
s.replace("\n", "");
qCDebug(PairingNFCLog) << s;
}
//-----------------------------------------------------------------------------
void NdefPull_Cb(unsigned char *pNdefMessage, unsigned short NdefMessageSize)
{
Q_UNUSED(NdefMessageSize);
unsigned char *pNdefRecord = pNdefMessage;
NdefRecord_t NdefRecord;
unsigned char save;
if (!pNdefMessage)
{
qCDebug(PairingNFCLog) << "Issue during NDEF message reception (check provisioned buffer size)";
return;
}
QSoundEffect _nfcSound;
_nfcSound.setSource(QUrl::fromUserInput("qrc:/auterion/wav/beep.wav"));
_nfcSound.setVolume(0.9);
_nfcSound.play();
while (pNdefRecord)
{
qCDebug(PairingNFCLog) << "NDEF record received";
NdefRecord = DetectNdefRecordType(pNdefRecord);
switch(NdefRecord.recordType)
{
case MEDIA_VCARD:
save = NdefRecord.recordPayload[NdefRecord.recordPayloadSize];
NdefRecord.recordPayload[NdefRecord.recordPayloadSize] = '\0';
qCDebug(PairingNFCLog) << " vCard: " << reinterpret_cast<char *>(NdefRecord.recordPayload);
NdefRecord.recordPayload[NdefRecord.recordPayloadSize] = save;
break;
case WELL_KNOWN_SIMPLE_TEXT:
{
save = NdefRecord.recordPayload[NdefRecord.recordPayloadSize];
NdefRecord.recordPayload[NdefRecord.recordPayloadSize] = '\0';
QString text = reinterpret_cast<char *>(&NdefRecord.recordPayload[NdefRecord.recordPayload[0]+1]);
qCDebug(PairingNFCLog) << " Text: " << text;
qgcApp()->toolbox()->pairingManager()->jsonReceived(text);
NdefRecord.recordPayload[NdefRecord.recordPayloadSize] = save;
break;
}
default:
qCDebug(PairingNFCLog) << " Unsupported NDEF record, cannot parse";
break;
}
pNdefRecord = GetNextRecord(pNdefRecord);
}
}
//-----------------------------------------------------------------------------
}
// Discovery loop configuration according to the targeted modes of operation
static unsigned char discoveryTechnologies[] = {
MODE_POLL | TECH_PASSIVE_NFCA,
MODE_POLL | TECH_PASSIVE_NFCF,
MODE_POLL | TECH_PASSIVE_NFCB,
MODE_POLL | TECH_PASSIVE_15693,
};
//-----------------------------------------------------------------------------
PairingNFC::PairingNFC()
{
}
//-----------------------------------------------------------------------------
void PairingNFC::start()
{
if (!isRunning()) {
_exitThread = false;
QThread::start();
}
}
//-----------------------------------------------------------------------------
void PairingNFC::stop()
{
if (isRunning()) {
_exitThread = true;
}
}
//-----------------------------------------------------------------------------
void PairingNFC::run()
{
NxpNci_RfIntf_t RfInterface;
// Register callback for reception of NDEF message from remote cards
RW_NDEF_RegisterPullCallback(reinterpret_cast<void*>(*NdefPull_Cb));
// Open connection to NXPNCI device
if (NxpNci_Connect() == NFC_ERROR) {
qCDebug(PairingNFCLog) << "Error: cannot connect to NXPNCI device";
return;
}
if (NxpNci_ConfigureSettings() == NFC_ERROR) {
qCDebug(PairingNFCLog) << "Error: cannot configure NXPNCI settings";
return;
}
if (NxpNci_ConfigureMode(NXPNCI_MODE_RW) == NFC_ERROR)
{
qCDebug(PairingNFCLog) << "Error: cannot configure NXPNCI";
return;
}
// Start Discovery
if (NxpNci_StartDiscovery(discoveryTechnologies,sizeof(discoveryTechnologies)) != NFC_SUCCESS)
{
qCDebug(PairingNFCLog) << "Error: cannot start discovery";
return;
}
while(!_exitThread)
{
qCDebug(PairingNFCLog) << "Waiting for NFC connection";
qgcApp()->toolbox()->pairingManager()->setStatusMessage(PairingManager::PairingActive, tr("Waiting for NFC connection"));
// Wait until a peer is discovered
while(NxpNci_WaitForDiscoveryNotification(&RfInterface) != NFC_SUCCESS);
if ((RfInterface.ModeTech & MODE_MASK) == MODE_POLL)
{
task_nfc_reader(RfInterface);
}
else
{
qCDebug(PairingNFCLog) << "Wrong discovery";
}
}
qgcApp()->toolbox()->pairingManager()->setStatusMessage(PairingManager::PairingIdle, "");
qCDebug(PairingNFCLog) << "NFC: Stop";
}
//-----------------------------------------------------------------------------
void PairingNFC::task_nfc_reader(NxpNci_RfIntf_t RfIntf)
{
qgcApp()->toolbox()->pairingManager()->setStatusMessage(PairingManager::PairingActive, tr("Device detected"));
qCDebug(PairingNFCLog) << "NFC: Device detected";
// For each discovered cards
while(!_exitThread) {
// What's the detected card type ?
switch(RfIntf.Protocol) {
case PROT_T1T:
case PROT_T2T:
case PROT_T3T:
case PROT_ISODEP:
// Process NDEF message read
NxpNci_ProcessReaderMode(RfIntf, READ_NDEF);
break;
case PROT_ISO15693:
break;
case PROT_MIFARE:
break;
default:
break;
}
// If more cards (or multi-protocol card) were discovered (only same technology are supported) select next one
if (RfIntf.MoreTags) {
if (NxpNci_ReaderActivateNext(&RfIntf) == NFC_ERROR)
break;
}
// Otherwise leave
else
break;
}
// Wait for card removal
NxpNci_ProcessReaderMode(RfIntf, PRESENCE_CHECK);
qgcApp()->toolbox()->pairingManager()->setStatusMessage(PairingManager::PairingActive, tr("Device removed"));
qCDebug(PairingNFCLog) << "NFC device removed";
// Restart discovery loop
NxpNci_StopDiscovery();
NxpNci_StartDiscovery(discoveryTechnologies, sizeof(discoveryTechnologies));
}
//-----------------------------------------------------------------------------
/****************************************************************************
*
* (c) 2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include <QObject>
#include <QThread>
#include "QGCLoggingCategory.h"
extern "C" {
#include <NfcLibrary/inc/Nfc.h>
}
Q_DECLARE_LOGGING_CATEGORY(PairingNFCLog)
class PairingNFC : public QThread
{
Q_OBJECT
public:
PairingNFC();
virtual void start();
virtual void stop();
signals:
void parsePairingJson(QString json);
private:
bool _exitThread = false; ///< true: signal thread to exit
// Override from QThread
virtual void run(void);
void task_nfc_reader(NxpNci_RfIntf_t RfIntf);
};
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef FRAMEWORK_ALLOCATOR_H
#define FRAMEWORK_ALLOCATOR_H
#include <stddef.h>
void* framework_AllocMem(size_t size);
void framework_FreeMem(void *ptr);
#endif //ndef FRAMEWORK_ALLOCATOR_H
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef FRAMEWORK_CONTAINER_H
#define FRAMEWORK_CONTAINER_H
#include "TML/inc/framework_Interface.h"
typedef enum CONTAINER_STATUS
{
CONTAINER_SUCCESS,
CONTAINER_FAILED,
CONTAINER_INVALID_PARAM,
CONTAINER_INVALID_CONTAINER
}CONTAINER_STATUS;
CONTAINER_STATUS container_create(void** lContainer, uint32_t size);
CONTAINER_STATUS container_delete(void* lContainer);
CONTAINER_STATUS container_add(void* pContainer, void* _ptr);
CONTAINER_STATUS container_set(void* pContainer, uint32_t index,void*_ptr, void** _old);
CONTAINER_STATUS container_remove(void* pContainer, uint32_t index, void** _old);
CONTAINER_STATUS container_get(void* pContainer, uint32_t index, void** _out);
CONTAINER_STATUS container_size(void* pContainer, uint32_t* size);
CONTAINER_STATUS container_clear(void* pContainer);
CONTAINER_STATUS container_flushMallocedContent(void* pContainer);
CONTAINER_STATUS container_removePtr(void* pContainer, void* ref, void** out);
#endif /* FRAMEWORK_CONTAINER_H*/
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef FRAMEWORK_INTERFACE_H
#define FRAMEWORK_INTERFACE_H
//typedef unsigned long long uint64_t;
#include <stdint.h>
typedef enum _eResult
{
FRAMEWORK_SUCCESS,
FRAMEWORK_FAILED
}eResult;
/**
* Create a thread using the given function in parameters
* @param threadHandle Obfuscated thread handle allocated by this function.
* @param threadedFunc function to start in new thread. ( void* myFunc(void* ctx) )
* @param ctx Parameters given to threadedFunc.
* @return SUCCESS if no error.
*/
eResult framework_CreateThread(void** threadHandle,void *(*threadedFunc)(void*),void *ctx);
/**
* Wait until the given thread finish to run.
* @param threadHandle Obfuscated thread handle allocated by framework_CreateThread()
*/
void framework_JoinThread(void* threadHandle);
/**
* Delete the given thread. NOTE : framework_JoinThread() will be called before this function. So
* the Thread is already stopped.
* @param threadHandle Obfuscated thread handle allocated by framework_CreateThread()
*/
void framework_DeleteThread(void* threadHandle);
/**
* Return the calling thread ID.
* @return thread id.
*/
void* framework_GetCurrentThreadId();
/**
* Get the thread id of the given thread handle.
* @param threadHandle Obfuscated thread handle allocated by framework_CreateThread()
* @return thread id.
*/
void* framework_GetThreadId(void* threadHandle);
/**
* Create a mutex object. To gain performances, do not implement this function using interprocess
* lock mechanism such as Semaphore.
* @param mutexHandle Obfuscated mutex handle allocated by this function.
* @return SUCCESS if no error.
*/
eResult framework_CreateMutex(void** mutexHandle);
/**
* Lock the mutex.
* @param mutexHandle Obfuscated mutex handle allocated by framework_CreateMutex().
*/
void framework_LockMutex(void* mutexHandle);
/**
* Unlock the mutex
* @param mutexHandle Obfuscated mutex handle allocated by framework_CreateMutex().
*/
void framework_UnlockMutex(void* mutexHandle);
/**
* Block the current thread until wake up by framework_NotifyMutex().
* The mutex need to be locked before blocking the thread. (needLock parameter can be used)
* @param mutexHandle Obfuscated mutex handle allocated by framework_CreateMutex().
* @param needLock Indicate if the mutex need to be locked internaly or not. This avoid to call lock();wait();unlock();
*/
void framework_WaitMutex(void* mutexHandle,uint8_t needLock);
/**
* Wake up a thread blocked by the mutex. The mutex must be locked before waking up another thread.
* The mutex need to be locked before waking up a thread. (needLock parameter can be used)
* @param mutexHandle Obfuscated mutex handle allocated by framework_CreateMutex().
* @param needLock Indicate if the mutex need to be locked internaly or not. This avoid to call lock();wait();unlock();
*/
void framework_NotifyMutex(void* mutexHandle,uint8_t needLock);
/**
* Delete the mutex. If the mutex is locked, any locked thread will be unlocked.
* @param mutexHandle Obfuscated mutex handle allocated by framework_CreateMutex().
*/
void framework_DeleteMutex(void* mutexHandle);
/**
* Cause the calling thread to sleep until ms milliseconds elapsed.
* @param ms Milliseconds to wait until wakeup.
*/
void framework_MilliSleep(uint32_t ms);
// **************************************** Generic/Portable function.
/**
* Create a Semaphore. This semaphore have a counter of 1.
* This implementation of Semaphore is supposed to be generic. It uses previous Mutex API.
* There is no need to reimplement it until you have a good reason.
* @param semaphoreHandle Obfuscated semaphore handle allocated by this function.
* @return
*/
eResult framework_CreateSemaphore(void** semaphoreHandle);
/**
* Wait semaphore. Block until a PostSemaphore get called.
* @param semaphoreHandle Obfuscated semaphore handle allocated by framework_CreateSemaphore();
*/
void framework_WaitSemaphore(void* semaphoreHandle);
/**
* Post semaphore. Unblock any waiting semaphore. If nobody wait for this semaphore, the next "waiter"
* will not be blocked.
* @param semaphoreHandle Obfuscated semaphore handle allocated by framework_CreateSemaphore();
*/
void framework_PostSemaphore(void* semaphoreHandle);
/**
* @param semaphoreHandle Obfuscated semaphore handle allocated by framework_CreateSemaphore();
*/
void framework_DeleteSemaphore(void* semaphoreHandle);
#endif // ndef FRAMEWORK_INTERFACE_H
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef MAP_H
#define MAP_H
typedef enum STATUS
{
SUCCESS,
FAILED,
NOT_FOUND,
INVALID_MAP,
INVALID_PARAM,
ALREADY_EXISTS
}STATUS;
STATUS map_create(void ** map);
STATUS map_destroy(void* map);
STATUS map_add(void * map, void* id, void* object);
STATUS map_remove(void* map, void* id);
STATUS map_get(void* map, void* id, void ** object);
STATUS map_getAll(void* map, void ** elements, int * lenght);
#endif /*MAP_H*/
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef FRAMEWORK_PARCEL_H
#define FRAMEWORK_PARCEL_H
#include "TML/inc/framework_Interface.h"
void framework_ParcelCreate(void **parcel);
void framework_ParcelDelete(void *parcel);
uint8_t framework_ParcelReadByte(void *parcel);
void framework_ParcelWriteByte(void *parcel,uint8_t i);
uint16_t framework_ParcelReadShort(void *parcel);
void framework_ParcelWriteShort(void *parcel,uint16_t i);
uint32_t framework_ParcelReadInt32(void *parcel);
void framework_ParcelWriteInt32(void *parcel,uint32_t i);
uint64_t framework_ParcelReadInt64(void *parcel);
void framework_ParcelWriteInt64(void *parcel,uint64_t i);
float framework_ParcelReadFloat(void *parcel);
void framework_ParcelWriteFloat(void *parcel,float f);
double framework_ParcelReadDouble(void *parcel);
void framework_ParcelWriteDouble(void *parcel,double d);
const char* framework_ParcelReadString(void *parcel);
void framework_ParcelWriteString(void *parcel,const char* s);
void framework_ParcelReadRaw(void *parcel,void* outBuffer, uint32_t len);
void framework_ParcelWriteRaw(void *parcel,const void* buffer, uint32_t len);
const uint8_t* framework_ParcelDataAtCurrentPosition(void *parcel);
uint32_t framework_ParcelGetRemainingDataSize(void *parcel);
const uint8_t *framework_ParcelGetData(void *parcel);
uint32_t framework_ParcelGetSize(void *parcel);
void framework_ParcelSetData(void *parcel,const uint8_t* data,uint32_t size);
void framework_ParcelRewind(void *parcel);
void framework_ParcelForward(void *parcel,uint32_t nbBytes);
void framework_ParcelClear(void *parcel);
void framework_ParcelSerialize(void *dstParcel,void *srcParcel);
void framework_ParcelDeserialize(void *dstParcel,void *srcParcel);
#endif // ndef FRAMEWORK_PARCEL_H
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#ifndef FRAMEWORK_TIMER_H
#define FRAMEWORK_TIMER_H
#include "TML/inc/framework_Interface.h"
typedef void (framework_TimerCallBack)(void*);
void framework_TimerCreate(void **timer);
void framework_TimerStart(void *timer,uint32_t delay,framework_TimerCallBack *cb,void *usercontext);
void framework_TimerStop(void *timer);
void framework_TimerDelete(void *timer);
#endif // ndef FRAMEWORK_TIMER_H
/**************************************************************************
* Copyright (C) 2015 Eff'Innov Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Developped by Eff'Innov Technologies : contact@effinnov.com
*
**************************************************************************/
#include "TML/inc/framework_Interface.h"
#include <stdlib.h>
/**
* Internal function, log a buffer to log output as Hexadecimal + ASCII display.
* @param buffer
* @param size
*/
void HexDump(const void * buffer, uint32_t size);
void framework_Error(const char* format, ...);
This diff is collapsed.
This diff is collapsed.
/*
* @brief Protocol definitions for LPCUSBSIO's I2C interface
*
* @note
* Copyright(C) NXP Semiconductors, 2013
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under any
* patent, copyright, mask work right, or any other intellectual property rights in
* or to any products. NXP Semiconductors reserves the right to make changes
* in the software without notification. NXP Semiconductors also makes no
* representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#ifndef __LPCUSBSIO_I2C_H_
#define __LPCUSBSIO_I2C_H_
#ifdef __cplusplus
extern "C"
{
#endif
#pragma pack(1)
/** @defgroup LPCUSBSIO_I2C LPCUSBSIO protocol definitions for I2C interface
* @ingroup LPCUSBSIO
* This package defines the LPCUSBSIO packet structure for I2C interface.
* Both the firmware and PC (host) libraries use this definitions to construct
* the I2C payloads.
* @{
*/
#define HID_I2C_MAX_PACKETS 4 /*!< Maximum packets allowed in processing queue */
#define HID_I2C_PACKET_SZ 64 /*!< Packet size of each I2C command packet */
#define HID_I2C_HEADER_SZ 5 /*!< Size of the header in I2C command packet */
/* HID_I2C Requests */
#define HID_I2C_REQ_RESET 0 /*!< Request to abort and flush all pending requests */
#define HID_I2C_REQ_INIT_PORT 1 /*!< Request to initialize the I2C port */
#define HID_I2C_REQ_DEINIT_PORT 2 /*!< Request to de-initialize the I2C port */
#define HID_I2C_REQ_DEVICE_WRITE 3 /*!< Request to write data to the I2C port */
#define HID_I2C_REQ_DEVICE_READ 4 /*!< Request to read data from the I2C port */
#define HID_I2C_REQ_DEVICE_XFER 5 /*!< Request to write and then read data from the I2C port */
/*AL ! Add GPIO Requests */
#define HID_GPIO_REQ_SET_VEN 6 /*!< Request to set the VEN GPIO State*/
#define HID_GPIO_REQ_SET_DWL 7 /*!< Request to set the DWL GPIO State*/
/**
* @brief HID to I2C bridge Request structure.
* Defines the structure of HID to I2C Request packet. This is same as
* HID OUT report.
*/
typedef struct __HIDI2C_OUT_REPORT {
uint16_t length; /*!< Length of the HID_I2C Request structure including cmd, transId and length fields. */
uint8_t transId; /*!< I2C_HID transaction identifier. Rolls over after 255. */
uint8_t sesId; /*!< I2C_HID session identifier. */
uint8_t req; /*!< I2C_HID Request */
uint8_t data[]; /*!< Data corresponding to the Request */
} HID_I2C_OUT_REPORT_T;
/** HID_I2C responses. The response code below 0x10 should match with I2CM_STATUS codes. */
#define HID_I2C_RES_OK 0x00 /*!< Requested Request was executed successfully. */
#define HID_I2C_RES_ERROR 0x01 /*!< Unknown error condition. */
#define HID_I2C_RES_NAK 0x02 /*!< No device responded for given slave address. */
#define HID_I2C_RES_BUS_ERROR 0x03 /*!< I2C bus error */
#define HID_I2C_RES_SLAVE_NAK 0x04 /*!< NAK received after SLA+W or SLA+R */
#define HID_I2C_RES_ARBLOST 0x05 /*!< Arbitration lost */
#define HID_I2C_RES_TIMEOUT 0x10 /*!< Transaction timed out. */
#define HID_I2C_RES_INVALID_CMD 0x11 /*!< Invalid HID_I2C Request or Request not supported in this version. */
#define HID_I2C_RES_INVALID_PARAM 0x12 /*!< Invalid parameters are provided for the given Request. */
#define HID_I2C_RES_PARTIAL_DATA 0x13 /*!< Partial transfer completed. */
/**
* @brief HID to I2C bridge response structure.
* Defines the structure of HID to I2C Request packet. This is same as
* HID OUT report.
*/
typedef struct __HIDI2C_IN_REPORT {
uint16_t length; /*!< Length of the HID_I2C response structure including resp, transId and length fields.*/
uint8_t transId; /*!< I2C_HID transaction identifier. */
uint8_t sesId; /*!< I2C_HID session identifier. */
uint8_t resp; /*!< I2C_HID reponse */
uint8_t data[]; /*!< Data corresponding to the response */
} HID_I2C_IN_REPORT_T;
/**
* @brief Port configuration information
*/
typedef struct __HIDI2C_PortConfig_t {
uint32_t busSpeed; /*!< I2C bus speed */
uint32_t Options; /*!< Configuration options */
} HID_I2C_PORTCONFIG_T;
/** I2C_IO_OPTIONS Options to I2C_DeviceWrite & I2C_DeviceRead routines
* @{
*/
/** Generate start condition before transmitting */
#define HID_I2C_TRANSFER_OPTIONS_START_BIT 0x0001
/** Generate stop condition at the end of transfer */
#define HID_I2C_TRANSFER_OPTIONS_STOP_BIT 0x0002
/** Continue transmitting data in bulk without caring about Ack or nAck from device if this bit is
not set. If this bit is set then stop transmitting the data in the buffer when the device nAcks*/
#define HID_I2C_TRANSFER_OPTIONS_BREAK_ON_NACK 0x0004
/** lpcusbsio-I2C generates an ACKs for every byte read. Some I2C slaves require the I2C
master to generate a nACK for the last data byte read. Setting this bit enables working with such
I2C slaves */
#define HID_I2C_TRANSFER_OPTIONS_NACK_LAST_BYTE 0x0008
/* Setting this bit would mean that the address field should be ignored.
The address is either a part of the data or this is a special I2C
frame that doesn't require an address. For example when transferring a
frame greater than the USB_HID packet this option can be used. */
#define HID_I2C_TRANSFER_OPTIONS_NO_ADDRESS 0x00000040
/** @} */
/**
* @brief HID to I2C bridge read and write transfer parameters structure.
* Defines the structure of HID to I2C read-write transfer parameters.
*/
typedef struct __HIDI2C_RW_PARAMS {
uint16_t length; /*!< Length of the transfer.*/
uint8_t options; /*!< check @ref I2C_IO_OPTIONS. */
uint8_t slaveAddr; /*!< I2C slave device address. */
uint8_t data[]; /*!< Data corresponding to the response */
} HID_I2C_RW_PARAMS_T;
/** I2C_FAST_XFER_OPTIONS I2C master faster transfer options
* @{
*/
/** Ignore NACK during data transfer. By default transfer is aborted. */
#define I2C_FAST_XFER_OPTION_IGNORE_NACK 0x01
/** ACK last byte received. By default we NACK last byte we receive per I2C spec. */
#define I2C_FAST_XFER_OPTION_LAST_RX_ACK 0x02
/**
* @}
*/
/**
* @brief HID to I2C bridge fast transfer parameters structure.
* Defines the parameters structure for HID_I2C_REQ_DEVICE_XFER command.
*/
typedef struct __HIDI2C_XFER_PARAMS {
uint8_t txLength; /*!< Length of the Tx transfer.*/
uint8_t rxLength; /*!< Length of the Rx transfer. */
uint8_t options; /*!< check @ref I2C_FAST_XFER_OPTIONS. */
uint8_t slaveAddr; /*!< I2C slave device address. */
uint8_t data[]; /*!< Data corresponding to the response */
} HID_I2C_XFER_PARAMS_T;
/**
* @}
*/
#pragma pack()
#ifdef __cplusplus
}
#endif
#endif /* __LPCUSBSIO_I2C_H_ */
/*
* Copyright (c), NXP Semiconductors Caen / France
*
* (C)NXP Semiconductors
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* NXP reserves the right to make changes without notice at any time.
* NXP makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. NXP must not be liable for any loss or damage
* arising from its use.
*/
#define TIMEOUT_INFINITE 0
#define TIMEOUT_100MS 100
#define TIMEOUT_1S 1000
#define TIMEOUT_1200MS 1200
#define TIMEOUT_2S 2000
void tml_Connect(void);
void tml_Disconnect(void);
void tml_Send(uint8_t *pBuffer, uint16_t BufferLen, uint16_t *pBytesSent);
void tml_Receive(uint8_t *pBuffer, uint16_t BufferLen, uint16_t *pBytes, uint16_t timeout);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment