nfc_target_init() now update nfc_target_t baud rate

This commit is contained in:
Romuald Conty
2010-10-14 16:27:50 +00:00
parent 7294e4fbaf
commit 7c76e1bf32
11 changed files with 45 additions and 37 deletions

View File

@@ -1108,7 +1108,7 @@ pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, cons
}
bool
pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_target_t nt, byte_t * pbtRx, size_t * pszRx)
pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx)
{
// Save the current configuration settings
bool bCrc = pnd->bCrc;
@@ -1165,18 +1165,18 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_ta
const byte_t * pbtGBt = NULL;
size_t szGBt = 0;
switch(nt.nm.nmt) {
switch(pnt->nm.nmt) {
case NMT_ISO14443A: {
// Set ATQA (SENS_RES)
abtMifareParams[0] = nt.nti.nai.abtAtqa[1];
abtMifareParams[1] = nt.nti.nai.abtAtqa[0];
abtMifareParams[0] = pnt->nti.nai.abtAtqa[1];
abtMifareParams[1] = pnt->nti.nai.abtAtqa[0];
// Set UID
// Note: in this mode we can only emulate a single size (4 bytes) UID where the first is hard-wired by PN53x as 0x08
abtMifareParams[2] = nt.nti.nai.abtUid[1];
abtMifareParams[3] = nt.nti.nai.abtUid[2];
abtMifareParams[4] = nt.nti.nai.abtUid[3];
abtMifareParams[2] = pnt->nti.nai.abtUid[1];
abtMifareParams[3] = pnt->nti.nai.abtUid[2];
abtMifareParams[4] = pnt->nti.nai.abtUid[3];
// Set SAK (SEL_RES)
abtMifareParams[5] = nt.nti.nai.btSak;
abtMifareParams[5] = pnt->nti.nai.btSak;
pbtMifareParams = abtMifareParams;
}
@@ -1184,20 +1184,20 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_ta
case NMT_FELICA:
// Set NFCID2t
memcpy(abtFeliCaParams, nt.nti.nfi.abtId, 8);
memcpy(abtFeliCaParams, pnt->nti.nfi.abtId, 8);
// Set PAD
memcpy(abtFeliCaParams+8, nt.nti.nfi.abtPad, 8);
memcpy(abtFeliCaParams+8, pnt->nti.nfi.abtPad, 8);
// Set SystemCode
memcpy(abtFeliCaParams+16, nt.nti.nfi.abtSysCode, 2);
memcpy(abtFeliCaParams+16, pnt->nti.nfi.abtSysCode, 2);
pbtFeliCaParams = abtFeliCaParams;
break;
case NMT_DEP:
// Set NFCID3
pbtNFCID3t = nt.nti.ndi.abtNFCID3;
pbtNFCID3t = pnt->nti.ndi.abtNFCID3;
// Set General Bytes, if relevant
szGBt = nt.nti.ndi.szGB;
if (szGBt) pbtGBt = nt.nti.ndi.abtGB;
szGBt = pnt->nti.ndi.szGB;
if (szGBt) pbtGBt = pnt->nti.ndi.abtGB;
break;
case NMT_ISO14443B:
case NMT_JEWEL:
@@ -1241,7 +1241,10 @@ target_activation:
}
// XXX When using DEP, shouldn't we update target modulation ?
if(nm.nmt != nt.nm.nmt) goto target_activation;
if(nm.nmt != pnt->nm.nmt) {
goto target_activation;
}
pnt->nm.nbr = nm.nbr;
// Restore the CRC & parity setting to the original value (if needed)
if (!bCrc)

View File

@@ -193,7 +193,7 @@ bool pn53x_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtT
bool pn53x_initiator_transceive_bytes (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx,
byte_t * pbtRx, size_t * pszRx);
// NFC device as Target functions
bool pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_target_t nt, byte_t * pbtRx, size_t * pszRx);
bool pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx);
bool pn53x_target_receive_bits (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRxBits, byte_t * pbtRxPar);
bool pn53x_target_receive_bytes (nfc_device_t * pnd, byte_t * pbtRx, size_t * pszRx);
bool pn53x_target_send_bits (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTxBits,

View File

@@ -538,6 +538,11 @@ nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const s
*
* @param pnd \a nfc_device_t struct pointer that represent currently used device
* @param ntm target mode restriction that you want to emulate (eg. NTM_PASSIVE_ONLY)
* @param pnt pointer to \a nfc_target_t struct that represents the wanted emulated target
*
* @note \a pnt can be updated by this function: if you set NBR_UNDEFINED
* and/or NDM_UNDEFINED (ie. for DEP mode), these fields will be updated.
*
* @param[out] pbtRx Rx buffer pointer
* @param[out] pszRx received bytes count
*
@@ -550,11 +555,11 @@ nfc_initiator_transceive_bits (nfc_device_t * pnd, const byte_t * pbtTx, const s
* receive functions can be used.
*/
bool
nfc_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, const nfc_target_t nt, byte_t * pbtRx, size_t * pszRx)
nfc_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, nfc_target_t * pnt, byte_t * pbtRx, size_t * pszRx)
{
pnd->iLastError = 0;
return pn53x_target_init (pnd, ntm, nt, pbtRx, pszRx);
return pn53x_target_init (pnd, ntm, pnt, pbtRx, pszRx);
}
/**