Package jpigpio.sensors
Class MFRC522
java.lang.Object
jpigpio.sensors.MFRC522
public class MFRC522
extends java.lang.Object
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidPCD_AntennaOff()Turns the antenna off by disabling pins TX1 and TX2.voidPCD_AntennaOn()Turns the antenna on by enabling pins TX1 and TX2.bytePCD_CalculateCRC(byte[] data, byte length, byte[] result)Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.voidPCD_ClearRegisterBitMask(byte reg, byte mask)Clears the bits given in mask from register reg.bytePCD_GetAntennaGain()Get the current MFRC522 Receiver Gain (RxGain[2:0]) value.voidPCD_Init()Initializes the MFRC522 chip.bytePCD_ReadRegister(byte reg)Reads a byte from the specified register in the MFRC522 chip.voidPCD_ReadRegister(byte reg, byte[] values, byte rxAlign)Reads a number of bytes from the specified register in the MFRC522 chip.voidPCD_Reset()Performs a soft reset on the MFRC522 chip and waits for it to be ready again.voidPCD_SetAntennaGain(byte mask)Set the MFRC522 Receiver Gain (RxGain) to value specified by given mask.voidPCD_SetRegisterBitMask(byte reg, byte mask)Sets the bits given in mask in register reg.voidPCD_WriteRegister(byte reg, byte value)Write single byte to specified registervoidPCD_WriteRegister(byte reg, byte[] values)Write set of values (bytearray) to specified register.
-
Constructor Details
-
MFRC522
Object constructor- Parameters:
pigpio- JPiogpio objectchipSelectPin- Chip select pinresetPowerDownPin- Reset power down pin- Throws:
PigpioException
-
-
Method Details
-
PCD_WriteRegister
Write single byte to specified register- Parameters:
reg- The register to write to. One of the PCD_Register enums.value- The value to write.- Throws:
PigpioException
-
PCD_WriteRegister
Write set of values (bytearray) to specified register.- Parameters:
reg- The register to write to. One of the PCD_Register enums.values- The values to write. Byte array.- Throws:
PigpioException
-
PCD_ReadRegister
Reads a byte from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.- Parameters:
reg- The register to read from. One of the PCD_Register enums.- Returns:
- byte from specified register
- Throws:
PigpioException
-
PCD_ReadRegister
Reads a number of bytes from the specified register in the MFRC522 chip. The interface is described in the datasheet section 8.1.2.- Parameters:
reg- The register to read from. One of the PCD_Register enums.rxAlign- Byte array to store the values in.values- Only bit positions rxAlign..7 in values[0] are updated.- Throws:
PigpioException
-
PCD_SetRegisterBitMask
Sets the bits given in mask in register reg.- Parameters:
reg- The register to update. One of the PCD_Register enums.mask- The bits to set.- Throws:
PigpioException
-
PCD_ClearRegisterBitMask
Clears the bits given in mask from register reg.- Parameters:
mask- The bits to clear.reg- The register to update. One of the PCD_Register enums.- Throws:
PigpioException
-
PCD_CalculateCRC
Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.- Parameters:
data- Pointer to the data to transfer to the FIFO for CRC calculation.length- The number of bytes to transfer.result- Pointer to result buffer. Result is written to result[0..1], low byte first.- Returns:
- STATUS_OK on success, STATUS_??? otherwise.
- Throws:
PigpioException
-
PCD_Init
Initializes the MFRC522 chip.- Throws:
PigpioException
-
PCD_Reset
Performs a soft reset on the MFRC522 chip and waits for it to be ready again.- Throws:
PigpioException
-
PCD_AntennaOn
Turns the antenna on by enabling pins TX1 and TX2. After a reset these pins are disabled.- Throws:
PigpioException
-
PCD_AntennaOff
Turns the antenna off by disabling pins TX1 and TX2.- Throws:
PigpioException
-
PCD_GetAntennaGain
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.- Returns:
- Value of the RxGain, scrubbed to the 3 bits used.
- Throws:
PigpioException
-
PCD_SetAntennaGain
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.- Parameters:
mask-- Throws:
PigpioException
-