|
M5Unit-RFID 0.0.2 git rev:1dc8f67
|
Radio frequency identification unit. More...
#include <unit_MFRC522.hpp>
Classes | |
| struct | config_t |
| Settings for begin. More... | |
Public Member Functions | |
| UnitMFRC522 (const uint8_t addr=DEFAULT_ADDRESS) | |
| Constructor. | |
| virtual | ~UnitMFRC522 () |
| Destructor. | |
| virtual bool | begin () override |
| Begin the unit. | |
| virtual void | update (const bool force=false) override |
| Update internal state. | |
| m5::nfc::NFC | NFCMode () const |
| Gets the current operating mode. | |
| virtual bool | configureNFCMode (const m5::nfc::NFC mode) |
| Configure NFC mode. | |
| bool | softReset (const bool blocking=true) |
| Software reset. | |
| bool | selfTest () |
| Self test. | |
Settings for begin | |
| config_t | config () |
| Gets the configuration. | |
| void | config (const config_t &cfg) |
| Set the configuration. | |
Antenna | |
| bool | readAntennaStatus (bool &status) |
| Read the antenna status. | |
| bool | turnOnAntenna () |
| Turn on the antenna. | |
| bool | turnOffAntenna () |
| Turn off the antenna. | |
| bool | readReceiverGain (mfrc522::ReceiverGain &gain) |
| Gets the receiver gain. | |
| bool | writeReceiverGain (const mfrc522::ReceiverGain gain) |
| Write the receiver gain. | |
GsN (N-driver conductance) / CWGsP / ModGsP (P-driver conductance) | |
| bool | readGsN (uint8_t &value) |
| Read the GsN register (N-driver conductance: CWGsN[7:4] / ModGsN[3:0]) | |
| bool | writeGsN (const uint8_t value) |
| Write the GsN register. | |
| bool | readCWGsP (uint8_t &value) |
| Read the CWGsP register (P-driver conductance during no modulation) | |
| bool | writeCWGsP (const uint8_t value) |
| Write the CWGsP register. | |
| bool | readModGsP (uint8_t &value) |
| Read the ModGsP register (P-driver conductance during modulation) | |
| bool | writeModGsP (const uint8_t value) |
| Write the ModGsP register. | |
RxThreshold (receiver decision levels) | |
| bool | readRxThreshold (uint8_t &value) |
| Read the RxThreshold register. | |
| bool | writeRxThreshold (const uint8_t value) |
| Write the RxThreshold register. | |
TPrescaler | |
| bool | readTPrescaler (uint16_t &tprescale) |
| Read the TPrescaler. | |
| bool | writeTPrescaler (const uint16_t tprescale) |
| Write the TPrescaler. | |
CRC | |
| bool | calculateCRC (uint16_t &result, const uint8_t *buf, const uint8_t len) |
| Calculate CRC by hardware. | |
| bool | calculateSoftwareCRC (uint16_t &result, const uint8_t *buf, const uint8_t len) |
| Calculate CRC by software. | |
NFC-A | |
| bool | nfcaTransceive (uint8_t *rx, uint16_t &rx_len, const uint8_t *tx, const uint16_t tx_len, const uint32_t timeout_ms) |
| Transceive. | |
| bool | request (uint16_t &atqa) |
| Request for idle PICC. | |
| bool | wakeup (uint16_t &atqa) |
| Wakeup for idle/halt PICC. | |
| bool | selectWithAnticollision (bool &completed, m5::nfc::a::PICC &picc, const uint8_t lv) |
| Select PICC with anti-collision. | |
| bool | select (const m5::nfc::a::PICC &picc) |
| Select specific PICC. | |
| bool | readBlock (uint8_t rx[16], const uint8_t block) |
| Read the 1 block / 4 page (16 bytes) | |
| bool | writeBlock (const uint8_t block, const uint8_t tx[16]) |
| Write the 1 block. | |
| bool | hlt () |
| Hlt for PICC. | |
MIFARE classic | |
| bool | mifareClassicAuthenticateA (const m5::nfc::a::PICC &picc, const uint8_t block, const m5::nfc::a::mifare::classic::Key &key=m5::nfc::a::mifare::classic::DEFAULT_KEY) |
| Authentication using keyA of the specified block. | |
| bool | mifareClassicAuthenticateB (const m5::nfc::a::PICC &picc, const uint8_t block, const m5::nfc::a::mifare::classic::Key &key=m5::nfc::a::mifare::classic::DEFAULT_KEY) |
| Authentication using keyB of the specified block. | |
| bool | mifareClassicStopCrypto1 () |
| Exit from authenticated state for MIFARE classic. | |
| bool | mifareClassicValueBlock (const m5::nfc::a::Command cmd, const uint8_t block, const uint32_t arg=0) |
| Operation for the value block. | |
Protected Member Functions | |
| bool | modify_bit_register8 (const uint8_t reg, const uint8_t set_mask, const uint8_t clear_mask) |
| bool | set_bit_register8 (const uint8_t reg, const uint8_t bits) |
| bool | clear_bit_register8 (const uint8_t reg, const uint8_t bits) |
| bool | change_bit_register8 (const uint8_t reg, const uint8_t bits, const uint8_t mask) |
| bool | read_register_with_align (const uint8_t reg, uint8_t *buf, const uint8_t len, const uint8_t align) |
| bool | write_pcd_command (const mfrc522::Command cmd) |
| bool | reset_baud_rates () |
| bool | flush_fifo_buffer () |
| bool | wait_comm_irq (const uint8_t irq, const uint32_t duration) |
| bool | wait_div_irq (const uint8_t irq, const uint32_t duration) |
| bool | transmit_command (const mfrc522::Command cmd, const uint8_t *buf, const uint8_t len, const uint8_t txLast=0, const uint8_t rxAlign=0) |
| bool | transceive (uint8_t *rbuf, uint16_t &rlen, const uint8_t *buf, const uint16_t len, const uint32_t timeout_ms, uint8_t &validBits, const uint8_t rxAlign=0, const bool crc=false, uint8_t *err=nullptr) |
| bool | picc_haltA () |
| bool | read_block (uint8_t *rbuf, uint8_t &rlen, const uint8_t addr) |
| bool | write_block (const uint8_t block, const uint8_t *buf, const uint8_t len) |
| bool | write_page (const uint8_t page, const uint8_t *buf, const uint8_t len) |
| bool | request_wakeup (uint16_t &atqa, const bool request) |
| bool | anti_collision (const uint8_t cascadeLevel, uint8_t *buf) |
| bool | mifare_classic_authenticate (const m5::nfc::a::Command cmd, const m5::nfc::a::PICC &picc, const uint8_t block, const m5::nfc::a::mifare::classic::Key &key) |
| bool | mifare_classic_transceive (const m5::nfc::a::Command cmd, const uint8_t block, const uint32_t timeout_ms) |
| bool | mifare_classic_transceive (const uint8_t *buf, const uint8_t len, const uint32_t timeout_ms, const bool usingtimeout=false) |
| bool | calculate_crc (uint16_t &result, const uint8_t *buf, const uint8_t len) |
| virtual bool | self_test () |
Protected Attributes | |
| config_t | _cfg {} |
| uint16_t | _tprescaler {} |
Radio frequency identification unit.
Operating frequency: 13.56 MHz
Supported protocols: ISO14443A, MIFARE and NTAG
|
inlineexplicit |
Constructor.
| addr | I2C address |
|
overridevirtual |
Begin the unit.
writeRegister8(TRELOAD_REG_H, 0x00) || !writeRegister8(TRELOAD_REG_L, 40*5) || // 5ms
Reimplemented in m5::unit::UnitWS1850S.
| bool m5::unit::UnitMFRC522::calculateCRC | ( | uint16_t & | result, |
| const uint8_t * | buf, | ||
| const uint8_t | len ) |
Calculate CRC by hardware.
| [out] | result | CRC value |
| buf | Buffer | |
| len | The length of the buffer |
| bool m5::unit::UnitMFRC522::calculateSoftwareCRC | ( | uint16_t & | result, |
| const uint8_t * | buf, | ||
| const uint8_t | len ) |
Calculate CRC by software.
| [out] | result | CRC value |
| buf | Buffer | |
| len | The length of the buffer |
|
inlinevirtual |
Configure NFC mode.
| mode | NFC mode |
Reimplemented in m5::unit::UnitWS1850S.
| bool m5::unit::UnitMFRC522::hlt | ( | ) |
Hlt for PICC.
|
inline |
Authentication using keyA of the specified block.
| picc | PICC |
| block | Block address |
| key | MIFARE classic key |
|
inline |
Authentication using keyB of the specified block.
| picc | PICC |
| block | Block address |
| key | MIFARE classic key |
| bool m5::unit::UnitMFRC522::mifareClassicStopCrypto1 | ( | ) |
Exit from authenticated state for MIFARE classic.
| bool m5::unit::UnitMFRC522::mifareClassicValueBlock | ( | const m5::nfc::a::Command | cmd, |
| const uint8_t | block, | ||
| const uint32_t | arg = 0 ) |
Operation for the value block.
| cmd | Command |
| block | Block address |
| arg | Argument for command if needs |
| bool m5::unit::UnitMFRC522::nfcaTransceive | ( | uint8_t * | rx, |
| uint16_t & | rx_len, | ||
| const uint8_t * | tx, | ||
| const uint16_t | tx_len, | ||
| const uint32_t | timeout_ms ) |
Transceive.
| rx | Receive buffer | |
| [in,out] | rx_len | in:Size of receive buffer out:actual read size |
| tx | Send buffer | |
| tx_len | Size of send buffer | |
| timeout_ms | Timeout(ms) |
|
inline |
Gets the current operating mode.
| bool m5::unit::UnitMFRC522::readAntennaStatus | ( | bool & | status | ) |
Read the antenna status.
| [out] | status | ON if true |
| bool m5::unit::UnitMFRC522::readBlock | ( | uint8_t | rx[16], |
| const uint8_t | block ) |
Read the 1 block / 4 page (16 bytes)
| rx | Receiver buffer (at least 16 bytes) |
| block | Block address |
| bool m5::unit::UnitMFRC522::readCWGsP | ( | uint8_t & | value | ) |
Read the CWGsP register (P-driver conductance during no modulation)
| [out] | value | 6-bit value (0x00-0x3F) |
| bool m5::unit::UnitMFRC522::readGsN | ( | uint8_t & | value | ) |
Read the GsN register (N-driver conductance: CWGsN[7:4] / ModGsN[3:0])
| [out] | value | Raw 8-bit value (high nibble = CWGsN, low nibble = ModGsN) |
| bool m5::unit::UnitMFRC522::readModGsP | ( | uint8_t & | value | ) |
Read the ModGsP register (P-driver conductance during modulation)
| [out] | value | 6-bit value (0x00-0x3F) |
| bool m5::unit::UnitMFRC522::readReceiverGain | ( | mfrc522::ReceiverGain & | gain | ) |
Gets the receiver gain.
| [out] | gain | Gain |
| bool m5::unit::UnitMFRC522::readRxThreshold | ( | uint8_t & | value | ) |
Read the RxThreshold register.
| [out] | value | 8-bit raw value (MinLevel[7:4] / CollLevel[2:0]) |
| bool m5::unit::UnitMFRC522::readTPrescaler | ( | uint16_t & | tprescale | ) |
Read the TPrescaler.
| [out] | tprescale | TPrescaler value |
|
inline |
Request for idle PICC.
| [out] | atqa | ATQA |
| bool m5::unit::UnitMFRC522::select | ( | const m5::nfc::a::PICC & | picc | ) |
Select specific PICC.
| picc | PICC |
| bool m5::unit::UnitMFRC522::selectWithAnticollision | ( | bool & | completed, |
| m5::nfc::a::PICC & | picc, | ||
| const uint8_t | lv ) |
Select PICC with anti-collision.
| [out] | completed | Completed select? |
| [out] | picc | Selected PICC |
| lv | Cascade level (1-3) |
|
protectedvirtual |
Reimplemented in m5::unit::UnitWS1850S.
|
inline |
Self test.
| bool m5::unit::UnitMFRC522::softReset | ( | const bool | blocking = true | ) |
Software reset.
| blocking | Blocks until the reset finishes and starts up again if True |
| bool m5::unit::UnitMFRC522::turnOffAntenna | ( | ) |
Turn off the antenna.
| bool m5::unit::UnitMFRC522::turnOnAntenna | ( | ) |
Turn on the antenna.
|
overridevirtual |
Update internal state.
| force | Force update if true |
|
inline |
Wakeup for idle/halt PICC.
| [out] | atqa | ATQA |
| bool m5::unit::UnitMFRC522::writeBlock | ( | const uint8_t | block, |
| const uint8_t | tx[16] ) |
Write the 1 block.
| block | Block address |
| tx | Send buffer (at least 16 bytes) |
| bool m5::unit::UnitMFRC522::writeCWGsP | ( | const uint8_t | value | ) |
Write the CWGsP register.
| value | 6-bit value (0x00-0x3F). Upper 2 bits are reserved. |
| bool m5::unit::UnitMFRC522::writeGsN | ( | const uint8_t | value | ) |
Write the GsN register.
| value | Raw 8-bit value (high nibble = CWGsN, low nibble = ModGsN) |
| bool m5::unit::UnitMFRC522::writeModGsP | ( | const uint8_t | value | ) |
Write the ModGsP register.
| value | 6-bit value (0x00-0x3F). Smaller = deeper ASK modulation. |
| bool m5::unit::UnitMFRC522::writeReceiverGain | ( | const mfrc522::ReceiverGain | gain | ) |
Write the receiver gain.
| gain | Gain |
| bool m5::unit::UnitMFRC522::writeRxThreshold | ( | const uint8_t | value | ) |
Write the RxThreshold register.
| value | 8-bit raw value. bit[3] is reserved (must be 0). |
| bool m5::unit::UnitMFRC522::writeTPrescaler | ( | const uint16_t | tprescale | ) |
Write the TPrescaler.
| tprescale | TPrescaler value |