#include "nfc_app.h" #include "trf79xxa.h" #include #include #include #include "clock.h" void Send_UID(void) { uint8_t ui8LoopCount = 0; for (ui8LoopCount = 0; ui8LoopCount < 8; ui8LoopCount++) //8 Byte UID. Po Schleifendurchlauf 1 Byte an Host gesendet { UART_putByte(g_pui8Iso15693UId[7-ui8LoopCount]); // Send UID to host } UART_putNewLine(); //nachdem die UID gesendet wurde wird eine leere Zeile gesendet (zur Übersichtlichkeit) } void main(void) { uint8_t ui8VLOCalibCount = 0; // TODO: Remove LED2 Jumper on G2 LaunchPad if using it, otherwise SPI will not work. // Stop the Watchdog timer, WDTCTL = WDTPW + WDTHOLD; P1DIR |= BIT0; P1OUT &= ~BIT0; // Select DCO to be 8 MHz MCU_initClock(); MCU_delayMillisecond(10); // Calibrate VLO MCU_calculateVLOFreq(); // Set the SPI SS high SLAVE_SELECT_PORT_SET; SLAVE_SELECT_HIGH; // Four millisecond delay between bringing SS high and then EN high per TRF7970A Datasheet MCU_delayMillisecond(4); // Set TRF Enable Pin high TRF_ENABLE_SET; TRF_ENABLE; // Wait until TRF system clock started MCU_delayMillisecond(5); // Set up TRF initial settings TRF79xxA_initialSettings(); TRF79xxA_setTrfPowerSetting(TRF79xxA_5V_FULL_POWER); #ifdef ENABLE_HOST // Set up UART UART_setup(); IE2 |= UCA0RXIE; _BIS_SR(GIE); #endif // Initialize all enabled technology layers NFC_init(); // Enable global interrupts __bis_SR_register(GIE); __enable_interrupt(); // Enable IRQ Pin IRQ_ON; #ifdef ENABLE_HOST // UART_putIntroReaderMsg(); #endif TRF79xxA_setupInitiator(0x02); // The VCD should wait at least 1 ms after it activated the // powering field before sending the first request, to while(1) { UART_putNewLine(); Change_Protect_Status = true; New_Password = true; Write_Data = true; Reset_Data = true; askdiff = true; uint8_t ui8LoopCount = 0; // ensure that the VICCs are ready to receive it. (ISO15693-3) MCU_delayMillisecond(100); ISO15693_resetTagCount(); ISO15693_SingleInventory(); Send_UID(); MCU_delayMillisecond(20); while(UART_Not_Recieved) { } UART_Not_Recieved = true; if(RX== '1') //Read all datablocks { UART_putNewLine(); My_sendReadMultipleBlocks(0x22, 0, 42); MCU_delayMillisecond(80); My_sendReadMultipleBlocks(0x22, 42, 11); } for (ui8LoopCount = 0; ui8LoopCount < 8; ui8LoopCount++) { g_pui8Iso15693UId[ui8LoopCount] = 0; // Send UID to host } // VLO drifts with temperature and over time, so it must be periodically recalibrated // Calibrate the VLO every 25 passes of the NFC polling routine ui8VLOCalibCount++; if (ui8VLOCalibCount == 25) { // Calibrate VLO MCU_calculateVLOFreq(); // Reset Calibration Counter ui8VLOCalibCount = 0; } } }