Class MFRC522

java.lang.Object
jpigpio.sensors.MFRC522

public class MFRC522
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    MFRC522​(JPigpio pigpio, int chipSelectPin, int resetPowerDownPin)
    Object constructor
  • 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 register
    void PCD_WriteRegister​(byte reg, byte[] values)
    Write set of values (bytearray) to specified register.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MFRC522

      public MFRC522​(JPigpio pigpio, int chipSelectPin, int resetPowerDownPin) throws PigpioException
      Object constructor
      Parameters:
      pigpio - JPiogpio object
      chipSelectPin - Chip select pin
      resetPowerDownPin - Reset power down pin
      Throws:
      PigpioException
  • Method Details

    • PCD_WriteRegister

      public void PCD_WriteRegister​(byte reg, byte value) throws PigpioException
      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

      public void PCD_WriteRegister​(byte reg, byte[] values) throws PigpioException
      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

      public byte PCD_ReadRegister​(byte reg) throws PigpioException
      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

      public void PCD_ReadRegister​(byte reg, byte[] values, byte rxAlign) throws PigpioException
      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

      public void PCD_SetRegisterBitMask​(byte reg, byte mask) throws PigpioException
      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

      public void PCD_ClearRegisterBitMask​(byte reg, byte mask) throws PigpioException
      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

      public byte PCD_CalculateCRC​(byte[] data, byte length, byte[] result) throws PigpioException
      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

      public void PCD_Init() throws PigpioException
      Initializes the MFRC522 chip.
      Throws:
      PigpioException
    • PCD_Reset

      public void PCD_Reset() throws PigpioException
      Performs a soft reset on the MFRC522 chip and waits for it to be ready again.
      Throws:
      PigpioException
    • PCD_AntennaOn

      public void PCD_AntennaOn() throws PigpioException
      Turns the antenna on by enabling pins TX1 and TX2. After a reset these pins are disabled.
      Throws:
      PigpioException
    • PCD_AntennaOff

      public void PCD_AntennaOff() throws PigpioException
      Turns the antenna off by disabling pins TX1 and TX2.
      Throws:
      PigpioException
    • PCD_GetAntennaGain

      public byte PCD_GetAntennaGain() throws PigpioException
      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

      public void PCD_SetAntennaGain​(byte mask) throws PigpioException
      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