Exemple #1
0
void mfrc522_init()
{
	mfrc522_reset();

//	mfrc522_write(TModeReg, 0x8D);
//
//	mfrc522_write(TPrescalerReg, 0x3E);
//	mfrc522_write(TReloadReg_1, 30);
//	mfrc522_write(TReloadReg_2, 0);

	// Config timer to periodically trigger PCD to check PICC.
	mfrc522_write(TModeReg, 0x00);

	// Prescaler is 169, timer tick is 2x169 + 1 = 339 tacts, fq is 13.56Mhz,
	// so 339 * 1 / 13.56 = 0.000025 = 25us per timer tick.
	mfrc522_write(TPrescalerReg, 0xa9);
	// Reload val is 1600. 1600 * 0.000025 (25us) = 40ms.
	mfrc522_write(TReloadReg_1, 0x6);
	mfrc522_write(TReloadReg_2, 0x40);

	mfrc522_write(TxASKReg, 0x40);
	mfrc522_write(ModeReg, 0x3D);

	uint8_t byte = mfrc522_read(TxControlReg);
	if(!(byte & 0x03))
	{
		mfrc522_write(TxControlReg, byte | 0x03);
	}

	// Activate IRQ signal.
	mfrc522_write(ComIEnReg, 1 << RxIEn | TimerIEn);
	mfrc522_write(DivIEnReg, 1 << IRQPushPull);
}
Exemple #2
0
void mfrc522_init( void ){
	mfrc522_pin_init();
	mfrc522_reset();

	__mfrc522_writeReg( MFRC522_REG_TMode, 0x82 );
	__mfrc522_writeReg( MFRC522_REG_TPrescaler, 0xa6 );

	mfrc522_delay_ms( 1 );
}
void mfrc522_init()
{
	uint8_t byte;
	mfrc522_reset();
	
	mfrc522_write(TModeReg, 0x8D);
    mfrc522_write(TPrescalerReg, 0x3E);
    mfrc522_write(TReloadReg_1, 30);   
    mfrc522_write(TReloadReg_2, 0);	
	mfrc522_write(TxASKReg, 0x40);	
	mfrc522_write(ModeReg, 0x3D);
	
	byte = mfrc522_read(TxControlReg);
	if(!(byte&0x03))
	{
		mfrc522_write(TxControlReg,byte|0x03);
	}
}