Jump to content

Component: RFID (MFRC522) (Wireless): Difference between revisions

From Flowcode Help
No edit summary
No edit summary
Line 1: Line 1:
 
{| style="width:50%"
 
{| width="50%"
|-
|-
| width="20%" style="color: gray;" | Author
| width="20%" style="color:gray;" | Author
| Ben Rowland and STibor
| Ben Rowland and STibor
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 3.0 (Release)
| 3.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Wireless
| Wireless
|}
|}




==RFID (MFRC522) component==
Functions designed to work with the MFRC522 contactless reader IC. The MFRC522 supports all variants of the MIFARE Mini, MIFARE 1K, MIFARE 4K, MIFARE Ultralight,  MIFARE DESFire EV1 and MIFARE Plus RF identification protocols.


==[[File:Component Icon 3f8d29a6_40a6_4d5e_a254_190c86d9ebb7.png|Image]] RFID (MFRC522) component==
==Detailed description==
Functions designed to work with the MFRC522 contactless reader IC.
 
The MFRC522 supports all variants of the MIFARE Mini, MIFARE 1K, MIFARE 4K, MIFARE Ultralight,
''No detailed description exists yet for this component''
MIFARE DESFire EV1 and MIFARE Plus RF identification protocols.


==Examples==
==Examples==
Here is a basic example program that reads the UID from a Mifare RFID tag and displays on an LCD. If the UID matches the UID stored in memory then a solenoid will fire allowing a door to be unlocked etc.
Here is a basic example program that reads the UID from a Mifare RFID tag and displays on an LCD. If the UID matches the UID stored in memory then a solenoid will fire allowing a door to be unlocked etc.


Line 32: Line 33:
==Downloadable macro reference==
==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>CompareUID</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Compares the UID from the ReadCardSerial macro with 4 byte UID.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CompareUID'''
|-
| colspan="2" | Compares the UID from the ReadCardSerial macro with 4 byte UID. Returns 0 if the addresses match.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Add0
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Add1
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Add2
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Add3
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


Returns 0 if the addresses match.


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''IsNewCardPresent'''
|-
| colspan="2" | Is there a card present for us to communicate with.  Returns 0 for no card and 1 for valid card present.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Add0''


:[[Variable Types|BYTE]] ''Add1''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetType'''
|-
| colspan="2" | Translates the SAK (Select Acknowledge) to a PICC type&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | sak
|-
| colspan="2" | The SAK byte returned from PICC_Select&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Add2''


:[[Variable Types|BYTE]] ''Add3''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AntennaOff'''
|-
| colspan="2" | Switches off the RFID antenna to save power. The antenna must be switched on again before communicating with an RFID tag.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCardSerial'''
|-
| colspan="2" | Simple wrapper around PICC_Select. Returns true if a UID could be read. Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first. The read UID is available in the class variable uid.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]]


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MifareWrite'''
|-
| colspan="2" | Writes to a block of data on a MIFARE type tag&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | BlockAddress
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Buffer
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | BufferSize
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>IsNewCardPresent</tt></u></span>===
Is there a card present for us to communicate with.


Returns 0 for no card and 1 for valid card present.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Select'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | ValidBits
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Parameters'''


:''This macro has no parameters''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopCrypto'''
|-
| colspan="2" | Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MifareRead'''
|-
| colspan="2" | Reads from a block of data on a MIFARE type tag&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | BlockAddress
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Buffer
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | BufferSize
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]]


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Authenticate'''
|-
| colspan="2" | This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card. All keys are set to FFFFFFFFFFFFh at chip delivery. The authentication is described in the MFRC522 datasheet section 10.3.1.9.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Command
|-
| colspan="2" | PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | BlockAddress
|-
| colspan="2" | The block number&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Key
|-
| colspan="2" | Crypteo key to use&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>GetType</tt></u></span>===
Translates the SAK (Select Acknowledge) to a PICC type


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''HaltA'''
|-
| colspan="2" | Instructs a PICC in state ACTIVE(*) to go to state HALT&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''sak''
::The SAK byte returned from PICC_Select


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadUIDByte'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Index
|-
| colspan="2" | 0-9 = UID Data Bytes, 10 = UID Length, 11 = UID SAK&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Return value'''


:[[Variable Types|BYTE]]
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AntennaOn'''
|-
| colspan="2" | Switches on the RFID antenna. Called as part of the Initialise macro.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===<span style="font-weight: normal;"><u><tt>AntennaOff</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Switches off the RFID antenna to save power.
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
The antenna must be switched on again before communicating with an RFID tag.
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
|-
'''Parameters'''
| colspan="2" | Initialises the RFID module ready for interaction with RFID tags.&nbsp;
 
|-
:''This macro has no parameters''
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
'''Return value'''
|}
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>ReadCardSerial</tt></u></span>===
Simple wrapper around PICC_Select.
 
Returns true if a UID could be read.
 
Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first.
 
The read UID is available in the class variable uid.
 
'''Parameters'''
 
:''This macro has no parameters''
 
 
'''Return value'''
 
:[[Variable Types|BYTE]]
 
 
===<span style="font-weight: normal;"><u><tt>MifareWrite</tt></u></span>===
Writes to a block of data on a MIFARE type tag
 
'''Parameters'''
 
:[[Variable Types|BYTE]] ''BlockAddress''
 
:[[Variable Types|BYTE]] ''Buffer''
 
:[[Variable Types|BYTE]] ''BufferSize''
 
 
'''Return value'''
 
:[[Variable Types|BYTE]]
 
 
===<span style="font-weight: normal;"><u><tt>Select</tt></u></span>===
''<span style="color:red;">No additional information</span>''
 
 
 
'''Parameters'''
 
:[[Variable Types|BYTE]] ''ValidBits''
 
 
'''Return value'''
 
:[[Variable Types|BYTE]]
 
 
===<span style="font-weight: normal;"><u><tt>StopCrypto</tt></u></span>===
Used to exit the PCD from its authenticated state.
 
Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start.
 
'''Parameters'''
 
:''This macro has no parameters''
 
 
'''Return value'''
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>MifareRead</tt></u></span>===
Reads from a block of data on a MIFARE type tag


'''Parameters'''


:[[Variable Types|BYTE]] ''BlockAddress''
:[[Variable Types|BYTE]] ''Buffer''
:[[Variable Types|BYTE]] ''BufferSize''
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>Authenticate</tt></u></span>===
This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card.
All keys are set to FFFFFFFFFFFFh at chip delivery.
The authentication is described in the MFRC522 datasheet section 10.3.1.9.
'''Parameters'''
:[[Variable Types|BYTE]] ''Command''
::PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B
:[[Variable Types|BYTE]] ''BlockAddress''
::The block number
:[[Variable Types|BYTE]] ''Key''
::Crypteo key to use
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>HaltA</tt></u></span>===
Instructs a PICC in state ACTIVE(*) to go to state HALT
'''Parameters'''
:''This macro has no parameters''
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>ReadUIDByte</tt></u></span>===
''<span style="color:red;">No additional information</span>''
'''Parameters'''
:[[Variable Types|BYTE]] ''Index''
::0-9 = UID Data Bytes, 10 = UID Length, 11 = UID SAK
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>AntennaOn</tt></u></span>===
Switches on the RFID antenna.
Called as part of the Initialise macro.
'''Parameters'''
:''This macro has no parameters''
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Initialises the RFID module ready for interaction with RFID tags.
'''Parameters'''
:''This macro has no parameters''
'''Return value'''
:''This call does not return a value''
==Simulation macro reference==
''This component does not contain any simulation macros''




==Property reference==
==Property reference==
<span style="font-weight: normal;"><u>Channel</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CHANNEL''.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
SPI Channel selector
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Prescale</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::PR_SCALE''.
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
Prescale option selector
|-
 
|-
<span style="font-weight: normal;"><u>MOSI</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MOSI''.
|-
 
| colspan="2" | SPI Channel selector&nbsp;
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>MISO</u></span>
| width="90%" | Prescale
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MISO''.
| colspan="2" | Prescale option selector&nbsp;
 
|-
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | MOSI
<span style="font-weight: normal;"><u>CLK</u></span>
|-
 
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::CLK''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
| width="90%" | MISO
 
|-
<span style="font-weight: normal;"><u>CS / SS</u></span>
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::SS''.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | CLK
Chip Select / Slave Select Pin  
|-
 
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.&nbsp;
Master Mode: General purpose output pin used to select the remote SPI device.
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
Slave Mode: Hardware chip select pin input used to select the SPI device.
| width="90%" | CS / SS
 
|-
<span style="font-weight: normal;"><u>Reset</u></span>
| colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device. &nbsp;
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''reset''.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | Reset
MFRC522 Reset Pin
|-
 
| colspan="2" | MFRC522 Reset Pin &nbsp;
<span style="font-weight: normal;"><u>Label</u></span>
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
 
|-
''<span style="color:red;">No additional information</span>''
|-
 
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 
| width="90%" | Label
 
|-
<span style="font-weight: normal;"><u>Scope Traces</u></span>
| colspan="2" | &nbsp;
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ScopeTraces''.
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Scope Traces
Selects if the scope traces are automatically generated or not
|-
 
| colspan="2" | Selects if the scope traces are automatically generated or not&nbsp;
<span style="font-weight: normal;"><u>Console Data</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ConsoleData''.
| width="90%" | Console Data
 
|-
Selects if the console data is automatically generated or not
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
 
|-
<span style="font-weight: normal;"><u>Injector</u></span>
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | API
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::Injector''.
|-
 
| colspan="2" | &nbsp;
''<span style="color:red;">No additional information</span>''
|}

Revision as of 20:34, 16 November 2021

Author Ben Rowland and STibor
Version 3.0
Category Wireless


RFID (MFRC522) component

Functions designed to work with the MFRC522 contactless reader IC. The MFRC522 supports all variants of the MIFARE Mini, MIFARE 1K, MIFARE 4K, MIFARE Ultralight, MIFARE DESFire EV1 and MIFARE Plus RF identification protocols.

Detailed description

No detailed description exists yet for this component

Examples

Here is a basic example program that reads the UID from a Mifare RFID tag and displays on an LCD. If the UID matches the UID stored in memory then a solenoid will fire allowing a door to be unlocked etc.

Display UID


Here is a basic example program to read and modify data stored on a Mifare RFID tag.

Read Write Test

Downloadable macro reference

CompareUID
Compares the UID from the ReadCardSerial macro with 4 byte UID. Returns 0 if the addresses match. 
- BYTE Add0
 
- BYTE Add1
 
- BYTE Add2
 
- BYTE Add3
 
- BYTE Return


IsNewCardPresent
Is there a card present for us to communicate with. Returns 0 for no card and 1 for valid card present. 
- BYTE Return


GetType
Translates the SAK (Select Acknowledge) to a PICC type 
- BYTE sak
The SAK byte returned from PICC_Select 
- BYTE Return


AntennaOff
Switches off the RFID antenna to save power. The antenna must be switched on again before communicating with an RFID tag. 
- VOID Return


ReadCardSerial
Simple wrapper around PICC_Select. Returns true if a UID could be read. Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first. The read UID is available in the class variable uid. 
- BYTE Return


MifareWrite
Writes to a block of data on a MIFARE type tag 
- BYTE BlockAddress
 
- BYTE Buffer
 
- BYTE BufferSize
 
- BYTE Return


Select
 
- BYTE ValidBits
 
- BYTE Return


StopCrypto
Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start. 
- VOID Return


MifareRead
Reads from a block of data on a MIFARE type tag 
- BYTE BlockAddress
 
- BYTE Buffer
 
- BYTE BufferSize
 
- BYTE Return


Authenticate
This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card. All keys are set to FFFFFFFFFFFFh at chip delivery. The authentication is described in the MFRC522 datasheet section 10.3.1.9. 
- BYTE Command
PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B 
- BYTE BlockAddress
The block number 
- BYTE Key
Crypteo key to use 
- BYTE Return


HaltA
Instructs a PICC in state ACTIVE(*) to go to state HALT 
- BYTE Return


ReadUIDByte
 
- BYTE Index
0-9 = UID Data Bytes, 10 = UID Length, 11 = UID SAK 
- BYTE Return


AntennaOn
Switches on the RFID antenna. Called as part of the Initialise macro. 
- VOID Return


Initialise
Initialises the RFID module ready for interaction with RFID tags. 
- VOID Return



Property reference

Properties
Connections
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Reset
MFRC522 Reset Pin  
Simulations
Label
 
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API