SLOA192B April 2014 – March 2019 TRF7970A , TRF7970A
The NFC_run switches between target and initiator until an NFC-enabled device is presented to the TRF7970A RF field. Once the peer-to-peer communication is established and eTempNFCState is NFC_DATA_EXCHANGE_PROTOCOL, the firmware checks whether button S1 or button S2 has been pressed. When button S1 is pressed, a text RTD is queued to the SNEP TX buffer. When button S2 is pressed, a MIME RTD is queued to the SNEP TX buffer. When the size of the NDEF packet is smaller than the SNEP queue, the NFC_P2P_sendNdefPacket() is only executed once because the number of remaining bytes return by the function would be 0. When the size of the NDEF packet is larger than the SNEP queue, the NFC_P2P_sendNdefPacket() continues to queue fragments of the complete packet until the number of remaining bytes is 0.
eTempNFCState = NFC_run();
if(eTempNFCState == NFC_DATA_EXCHANGE_PROTOCOL)
{
else if(NFC_P2P_getModeStatus(&sP2PMode,&sP2PBitrate))
{
// Check for button input
if ((buttonsPressed & BUTTON_S1) && (buttonDebounce == 2))
{
ui16TxIndex = 0x00;
buttonDebounce = 0x00;
// Total Length of the packet.
ui32PacketLength = 46;
ui32PacketRemaining = ui32PacketLength;
// Send Text String
pui8NdefPointer = (uint8_t *) (pui8NfcPoweredByTexasInstruments+2);
if(ui32PacketRemaining < LLCP_MIU)
{
ui8FragmentSize = (uint8_t) ui32PacketRemaining;
}
else
{
ui8FragmentSize = LLCP_MIU;
}
ui8TXBytes = NFC_P2P_sendNdefPacket(pui8NdefPointer,true,ui8FragmentSize,ui32PacketLength);
if(ui8TXBytes)
{
ui32PacketRemaining = ui32PacketRemaining - (uint16_t) (ui8TXBytes);
ui16TxIndex = ui16TxIndex + (uint16_t) ui8TXBytes;
// Toggle TX LED
NFC_TX_LED_POUT ^= NFC_TX_LED_BIT;
}
}
else if((buttonsPressed & BUTTON_S2) && (buttonDebounce == 2))
{
ui16TxIndex = 0x00;
buttonDebounce = 0x00;
// Total Length of the packet.
ui32PacketLength = 3597;
ui32PacketRemaining = ui32PacketLength;
// Send TI Logo
pui8NdefPointer = (uint8_t *) (pui8TiLogo + 2);
if(ui32PacketRemaining < LLCP_MIU)
{
ui8FragmentSize = (uint8_t) ui32PacketRemaining;
}
else
{
ui8FragmentSize = LLCP_MIU;
}
ui8TXBytes = NFC_P2P_sendNdefPacket(pui8NdefPointer,true,ui8FragmentSize,ui32PacketLength);
if(ui8TXBytes)
{
ui32PacketRemaining = ui32PacketRemaining - (uint16_t) (ui8TXBytes);
ui16TxIndex = ui16TxIndex + (uint16_t) ui8TXBytes;
// Toggle TX LED
NFC_TX_LED_POUT ^= NFC_TX_LED_BIT;
}
}
else if(ui32PacketRemaining > 0)
{
if(ui32PacketRemaining < LLCP_MIU)
{
ui8FragmentSize = (uint8_t) ui32PacketRemaining;
}
else
{
ui8FragmentSize = LLCP_MIU;
}
ui8TXBytes = NFC_P2P_sendNdefPacket((uint8_t *) (pui8NdefPointer+ui16TxIndex),false,ui8FragmentSize,(uint32_t) ui32PacketLength);
if(ui8TXBytes)
{
ui32PacketRemaining = ui32PacketRemaining - (uint16_t) (ui8TXBytes);
ui16TxIndex = ui16TxIndex + (uint16_t) ui8TXBytes;
// Toggle TX LED
NFC_TX_LED_POUT ^= NFC_TX_LED_BIT;
}
}
else if(buttonDebounce == 0x00)
{
// Enable the button debounce.
buttonDebounce = 0x01;
}
else if (ui32PacketRemaining == 0)
{
// Clear TX LED
NFC_TX_LED_POUT &= ~NFC_TX_LED_BIT;
}
}
}