SLOA192B April 2014 – March 2019 TRF7970A , TRF7970A
For the low-level initialization, the MCU is initialized in MCU_init() by setting the MSP430F5529 main clock frequency to 25 MHz. The TRF7970A hardware connections and the MSP430F5529 SPI module (SPI clock running at 4 MHz – minimum recommended is 2 MHz) is initialized in TRF79x0_init(). The local variables are needed for transmit and receive and the peer-to-peer stack initialization. The Buttons_init function set the GPIO direction to inputs and the Buttons_interruptEnable() enable the interrupt for buttons S1 and S2.
#include "msp430.h"
#include "nfc_controller.h"
#include "ndef_image.h"
#include "lp_buttons.h"
uint16_t g_ui16ListenTime;
t_sNfcP2PMode g_sP2PSupportedModes;
t_sNfcP2PCommBitrate g_sP2PSupportedTargetBitrates;
t_sNfcP2PCommBitrate g_sP2PSupportedInitiatorBitrates;
t_sNfcDEP_P2PSetup g_sP2PSetupOptions;
uint8_t g_ui8NfcDepInitiatorDID;
void main(void)
{
tNfcState eTempNFCState;
tNfcState eCurrentNFCState;
uint32_t ui32PacketRemaining;
uint8_t ui8TXBytes;
uint16_t ui16TxIndex;
uint32_t ui32PacketLength;
uint8_t * pui8NdefPointer;
uint8_t ui8FragmentSize;
// Peer to peer RX Status
tNfcP2PRxStatus sP2PRxStatus;
t_sNfcP2PMode sP2PMode;
t_sNfcP2PCommBitrate sP2PBitrate;
// Bytes Received from Peer to Peer
uint16_t ui16BytesReceived = 0x00;
// Initialize MCU
MCU_init();
//Enable interrupts globally
__enable_interrupt();
// Initialize TRF7970
TRF79x0_init();
// Initialize S1 and S2 buttons
Buttons_init(BUTTON_ALL);
Buttons_interruptEnable(BUTTON_ALL);
// Initialize TRF7970A Idle Mode
TRF79x0_idleMode();
// Initialize the NFC Controller
NFC_init();
// This function will configure all the settings for each protocol
NFC_configuration();
// Initialize IDs for NFC-A, NFC-B and NFC-F
NFC_initIDs();