hey gang-
I have this RFID reader/writer, that I still dont understand enough to WRITE or edit any data on it..
Its an SPI RFID reader/writer..
and I have read up about the SPI protocol a bit here:
and understand the master/slave architecture/set-up
(I read the comments & understood (by default) enough on how to read a card that is swiped.. get the S/N of the card.. and use that as a 'hard coded' check to see if its the white card or the blue key fob I'm swiping)
not really a true understanding by any stretch.. all done so far by searching the net for others who have the same 'product'.. and compiling comments from all edited sketches and putting them into this one. (attached: RFID_commented_code.txt)
I have attached datasheet and some other .pdfs that came along with it.. (and the default sketches in case I messed something up in mine) (attached: RFID_SOURCE_FILES.zip)
I know I have it hooked up correctly (physically, as I am getting reads..etc)..
I guess Im looking for a kind soul to take pity on a noob and help me make some sense of the datasheet.. where I should be focused..(what area)
I think section 9.1 is (what I thought) the place to be focused on.. as that is the REGISTERS section?
But Im not really understanding how to "USE" this data in the read/write functions I see available to us?
I see in the sketch there are a bunch of 'registers' DEFINED# at the top.. (but again not really sure how Im suppose to correctly use them.. and handle the returned (if any) data..)
once the most recurring questions I saw on every post & forums around was HOW are we supposed to:
1.) read the password? (in something legible)
2.) how are we supposed to write/change the password to another one? (in a legible manner again)
but in the grander scheme.. I want to be able to use the datasheet.. and unfortunately, need some direction/help.
My own personal questions (in no particular order, and I know are a bit vague/broad)
1.) without code.. a general explanation of how the the read/write functions with this RFID card work..
basically you take one of the functions..
give it an 'address' it needs to either read or write to?.. and the second params is the 'data/value' to be written? (if its a write function for example)
I have things commented out next to each function.. but I think Im missing an understanding of the registers 'stuff' to make it all click/work?
2.) I dont understand the difference between the TWO read functions and the TWO write functions?? (the names seems to be in different order:
example:
MFRC522_Read()
&
MFRC522_Write()
vs.
Read_MFRC522()
&
Write_MFRC5200()
(seems they return different value..one is a status and one a value?)
//Read_MFRC522
//----------------------------------------------------------//
/*
* Function: Read_MFRC522()
* Description: read a byte data in one register of MR RC522
* Input parameter: (addr--register address)
* Return: returns the read value
*/
uchar Read_MFRC522(uchar addr){
uchar val;
digitalWrite(chipSelectPin, LOW);
SPI.transfer(((addr<<1)&0x7E) | 0x80);
val =SPI.transfer(0x00);
digitalWrite(chipSelectPin, HIGH);
return val;
}
//MFRC522_Read
//----------------------------------------------------------//
/*
* Function: MFRC522_Read()
* Description: Read data
* Input parameters: (blockAddr--block address, recvData--the block data which are read)
* return: returns MI_OK (if success)
*/
uchar MFRC522_Read(uchar blockAddr, uchar *recvData){
uchar status;
uint unLen;
recvData[0] = PICC_READ;
recvData[1] = blockAddr;
CalulateCRC(recvData, 2, &recvData[2]);
status = MFRC522_ToCard(PCD_TRANSCEIVE, recvData, 4, recvData, &unLen);
if ((status != MI_OK) || (unLen != 0x90)){
status = MI_ERR;
}
return status;
}
I guess I'll stop there..
this is doing my head in!.. I skim the info a few times every known and then.. hoping it will 'click/sink' in... or I could see some 'noob' examples to make it more understandable....
but I think I need a push in the right direction here, to fully utilize the card for write abilities.. (like keeping track of money on the card like the example sorta indicates..changing passwords on the card....etc..etc.)
thanks.
RFID_commented_code.txt (25.4 KB)
RFID_SOURCE_FILES.zip (1.71 MB)