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 void
PCD_AntennaOff()
Turns the antenna off by disabling pins TX1 and TX2.void
PCD_AntennaOn()
Turns the antenna on by enabling pins TX1 and TX2.byte
PCD_CalculateCRC(byte[] data, byte length, byte[] result)
Use the CRC coprocessor in the MFRC522 to calculate a CRC_A.void
PCD_ClearRegisterBitMask(byte reg, byte mask)
Clears the bits given in mask from register reg.byte
PCD_GetAntennaGain()
Get the current MFRC522 Receiver Gain (RxGain[2:0]) value.void
PCD_Init()
Initializes the MFRC522 chip.byte
PCD_ReadRegister(byte reg)
Reads a byte from the specified register in the MFRC522 chip.void
PCD_ReadRegister(byte reg, byte[] values, byte rxAlign)
Reads a number of bytes from the specified register in the MFRC522 chip.void
PCD_Reset()
Performs a soft reset on the MFRC522 chip and waits for it to be ready again.void
PCD_SetAntennaGain(byte mask)
Set the MFRC522 Receiver Gain (RxGain) to value specified by given mask.void
PCD_SetRegisterBitMask(byte reg, byte mask)
Sets the bits given in mask in register reg.void
PCD_WriteRegister(byte reg, byte value)
Write single byte to specified registervoid
PCD_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
-