/* Made these as static global variables */
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Reads cards, beep and long light flash for good card read, short light flash for no card read, lights mostly on for NFC chip not talking right
void TestNFC_ReadTag (void) {
bool success;
static flag = 0;
/************************************ Everytime Try Reading a Card ***********************************/
// Check for a good card read
success = PN532_readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength, 1000);
if (success) {
if(flag == 0){
testPN532WritePage();
flag = 1;
}
else{
testPN532ReadPage();
flag = 0;
}
LIGHT_ON();
EventTimerCreate(200,1,TestingLightsOff);
for (int nfcBeep = 0; nfcBeep < 300; nfcBeep++) {
DACB.CH0DATA = 0x700;
_delay_us(200);
DACB.CH0DATA = 0x900;
_delay_us(200);
}
DACB.CH0DATA = 0x800;
_delay_ms(500); // Reduced from 1000ms to 500ms to avoid WDT reset - Vinay
}
// If Invalid card read then short light flash no beep
else {
LIGHT_ON();
_delay_ms(10);
LIGHT_OFF();
}
}
void TestNFCInterrupt_ReadTag (void){
/* Read the tag and write/read to NTAG213 user memory */
TestNFC_ReadTag();
/* Needs to restart the scan to detect the NTAG passively */
PN532_StartScan();
}
/* Made these as static global variables */
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Reads cards, beep and long light flash for good card read, short light flash for no card read, lights mostly on for NFC chip not talking right
void TestNFC_ReadTag (void) {
bool success;
static flag = 0;
/************************************ Everytime Try Reading a Card ***********************************/
// Check for a good card read
success = PN532_readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength, 1000);
if (success) {
if(flag == 0){
testPN532WritePage();
flag = 1;
}
else{
testPN532ReadPage();
flag = 0;
}
LIGHT_ON();
EventTimerCreate(200,1,TestingLightsOff);
for (int nfcBeep = 0; nfcBeep < 300; nfcBeep++) {
DACB.CH0DATA = 0x700;
_delay_us(200);
DACB.CH0DATA = 0x900;
_delay_us(200);
}
DACB.CH0DATA = 0x800;
_delay_ms(500); // Reduced from 1000ms to 500ms to avoid WDT reset - Vinay
}
// If Invalid card read then short light flash no beep
else {
LIGHT_ON();
_delay_ms(10);
LIGHT_OFF();
}
}
void TestNFCInterrupt_ReadTag (void){
/* Read the tag and write/read to NTAG213 user memory */
TestNFC_ReadTag();
/* Needs to restart the scan to detect the NTAG passively */
PN532_StartScan();
}