Esempio n. 1
0
void write_emul_tag_uid(const uint8_t* tag_uid_buffer)
{
	uint8_t data_buf[11];
	int i;

	data_buf[0] = NFCID;
	for(i = 1; i < 11; i++) {
		data_buf[i] = tag_uid_buffer[i-1];
	}
	Trf797xWriteCont(data_buf, 11);
}
Esempio n. 2
0
//-------------------------------------------------------
//This is the main NFC send function that has to follow
//the RFAnticollisionAvoidance function - in active mode.
//-------------------------------------------------------
u08_t
NfcSend(u08_t *pbuf)
{
	u08_t length, k = 0;
	
	IRQ_OFF;
	Trf797xReset();

	nfc_state = *pbuf;	//nfc_state global variable is the main transmit counter
	length = *pbuf;	
	if(length > FIFO_LEN)
	{	
		length = FIFO_LEN;
	}
//kputchar('S');
//Put_byte(length);
//kputchar('S');

	*(pbuf - 5) = 0x8f;
	*(pbuf - 4) = 0x91;		//buffer setup for FIFO writing
	*(pbuf - 3) = 0x3d;
	*(pbuf - 2) = (char)(nfc_state >> 4);
	*(pbuf - 1) = (char)(nfc_state << 4);
	//RAWwrite(command, 5, 1, 0);	//send the request using RAW writing
	Trf797xRawWrite((pbuf - 5), (length + 5));
	IRQ_ON;
/*
	*(pbuf - 1) = 0x1F;
	WriteCont(pbuf - 1, length + 1);	//send the request using RAW writing
					//Write FIFO_LEN bytes the first time you write to FIFO	*/

	nfc_state = nfc_state - FIFO_LEN;
	i_reg = 0x01;
	pbuf += length;
	
	irq_flag = 0x00;
	
	while(nfc_state > 0)
	{
		McuCounterSet();		//TimerA set
		COUNT_VALUE = 0xf000;	//74ms
		START_COUNTER;		//start timer up mode
		while(irq_flag == 0x00)
		{
		}
		if(irq_flag == 0x03)	// Timer Event
		{
			buf[0] = 0x00;
			buf[1] = 0x01;
			Trf797xWriteSingle(buf, 2);
			Trf797xResetIrqStatus();
			return 0;
		}
		
		if(nfc_state > FIFO_MORE)		//the number of unsent bytes is in the NFCstate global	
		{
			length = FIFO_MORE + 1;		//count variable has to be 10 : 9 bytes for FIFO and 1 address
		}
		else if(nfc_state < 1)
		{	
			break;			//return from interrupt if all bytes have been sent to FIFO
		}
		else
		{
			length = nfc_state + 1;	//all data has been sent out
		}//if
		*(pbuf - 1) = FIFO;		//writes FIFO_MORE or less bytes to FIFO for transmitting
		Trf797xWriteCont(pbuf - 1, length);
		nfc_state = nfc_state - FIFO_MORE;//write FIFO_MORE bytes to FIFO
		pbuf += FIFO_MORE;
	}//while
	i_reg = 0x01;
	while(i_reg != 0x00 && k < 2){		//end of TX recieved
			k++;
			McuCounterSet();		//TimerA set
			COUNT_VALUE = 0xf000;	//74ms
			START_COUNTER;		//start timer up mode
			irq_flag = 0x00;
			while(irq_flag == 0x00)
			{
			}	
	}

	Trf797xResetIrqStatus();
//kputchar('=');
//kputchar('=');
	return 1;
}//NFCSend