Adding AntennaOff and get/set of AntennaGain

This commit is contained in:
mdxs
2014-11-10 13:58:09 +01:00
parent 0ee8e53b4a
commit 1ee8cbd7fd
3 changed files with 64 additions and 1 deletions

View File

@@ -242,6 +242,36 @@ void MFRC522::PCD_AntennaOn() {
}
} // End PCD_AntennaOn()
/**
* Turns the antenna off by disabling pins TX1 and TX2.
*/
void MFRC522::PCD_AntennaOff() {
PCD_ClearRegisterBitMask(RFCfgReg, 0x03);
} // End PCD_AntennaOff()
/**
* Get the current MFRC522 Receiver Gain (RxGain[2:0]) value.
* See 9.3.3.6 / table 98 in http://www.nxp.com/documents/data_sheet/MFRC522.pdf
* NOTE: Return value scrubbed with (0x07<<4)=01110000b as RCFfgReg may use reserved bits.
*
* @return Value of the RxGain, scrubbed to the 3 bits used.
*/
byte MFRC522::PCD_GetAntennaGain() {
return PCD_ReadRegister(RFCfgReg) & (0x07<<4);
} // End PCD_GetAntennaGain()
/**
* Set the MFRC522 Receiver Gain (RxGain) to value specified by given mask.
* See 9.3.3.6 / table 98 in http://www.nxp.com/documents/data_sheet/MFRC522.pdf
* NOTE: Given mask is scrubbed with (0x07<<4)=01110000b as RCFfgReg may use reserved bits.
*/
void MFRC522::PCD_SetAntennaGain(byte mask) {
if (PCD_GetAntennaGain() != mask) { // only bother if there is a change
PCD_ClearRegisterBitMask(RFCfgReg, (0x07<<4)); // clear needed to allow 000 pattern
PCD_SetRegisterBitMask(RFCfgReg, mask & (0x07<<4)); // only set RxGain[2:0] bits
}
} // End PCD_SetAntennaGain()
/////////////////////////////////////////////////////////////////////////////////////
// Functions for communicating with PICCs
/////////////////////////////////////////////////////////////////////////////////////