#ifndef MFRC522_H #define MFRC522_H #include "../../io/SoftSPI.h" /** * RFID reader based on MFRC522 * attached via SPI * * http://www.nxp.com/documents/data_sheet/MFRC522.pdf * */ class MFRC522 { struct OP { uint8_t addr : 7; // bits 0-6 uint8_t rw : 1; // bit 7 [MSB] 1 = read, 0 = write }; enum class Register { COMMAND_REG = 0x01, INTERRUPTS_REG = 0x02, ERROR_REG = 0x06, STATUS1_REG = 0x07, STATUS2_REG = 0x08, FIFI_DATA_REG = 0x09, // access fifo buffer FIFO_SIZE_REG = 0x0A, // number of available fifo data MOD_REG = 0x11, DEMOG_REG = 0x19, TEST_SEL_1_REG = 0x31, TEST_SEL_2_REG = 0x32, VERSION_REG = 0x37, // software version }; struct CommandReg { uint8_t command : 4; uint8_t power_down : 1; uint8_t receiver_off : 1; uint8_t reserved : 2; }; struct InterruptsReg { uint8_t timerInterruptEnable : 1; uint8_t errorInterruptEnable : 1; uint8_t loAlertInterruptEnable : 1; uint8_t hiAlertInterruptEnable : 1; uint8_t idleInterruptEnable : 1; uint8_t rxInterruptEnable : 1; uint8_t txInterruptEnable : 1; uint8_t inverted : 1; }; private: SoftSPI spi; public: MFRC522() { ; } /** init */ void init() { spi.init(); } }; #endif // MFRC522_H