Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: RWDMifare/RWDMifare.h
- Revision:
- 0:340078fc5139
- Child:
- 1:c5be8c1c9e10
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RWDMifare/RWDMifare.h Wed Jun 26 19:09:58 2013 +0000
@@ -0,0 +1,129 @@
+/*
+Copyright (c) 2010 ARM Limited
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/*
+This is a specific and quick implementation for the Mifare MicroRWD modules.
+The class configures the reader for Mifare operation and can poll for UIDs.
+*/
+
+#ifndef RWD_MIFARE_H
+#define RWD_MIFARE_H
+
+#include "mbed.h"
+#include "RWDModule.h"
+
+class RWDMifare : public RWDModule
+{
+public:
+ RWDMifare(PinName tx, PinName rx, PinName cts);
+ virtual ~RWDMifare();
+
+ enum RWDMifareErr {
+ MIFARE_OK, //No error
+ MIFARE_HW, //Hardware-specific error
+ MIFARE_NOCARD, //No card in field
+ MIFARE_WRONGKEY //Key is not valid (for auth command)
+ };
+ // Command definitions
+#define CMD_Get_Status 0x53
+//#define CMD_Get_Message_Report 0x7A//not implemented
+#define CMD_Prog_EEPROM 0x50
+#define CMD_Read_Block 0x52
+#define CMD_Store_Key 0x4b
+ //Ackknowledge Codes
+#define Ack_Code_EEPROM_ERR 0x01
+#define Ack_Code_Card_OK 0x02
+#define Ack_Code_RX_OK 0x04
+#define Ack_Code_RS232_ERR 0x08
+#define Ack_Code_MF_Type 0x10
+#define Ack_Code_UL_Type 0x20
+#define Ack_Code_MRRFC_Err 0x40
+
+ //EEPROM Addresses
+#define EEP_Addr_POLL 0x00
+#define EEP_Addr_POLL_4ms 0x00
+#define EEP_Addr_POLL_8ms 0x10
+#define EEP_Addr_POLL_16ms 0x20
+#define EEP_Addr_POLL_32ms 0x30
+#define EEP_Addr_POLL_65ms 0x40
+#define EEP_Addr_POLL_132ms 0x50
+#define EEP_Addr_POLL_262ms_d 0x60
+#define EEP_Addr_POLL_524ms 0x70
+#define EEP_Addr_POLL_1s 0x80
+#define EEP_Addr_POLL_2s 0x90
+#define EEP_Addr_POLL_4s 0xA0
+#define EEP_Addr_POLL_8s 0xB0
+
+#define EEP_Addr_Aux_Data_OP 0x01
+#define EEP_Addr_Aux_Data_OP_OFF 0x00
+#define EEP_Addr_Aux_Data_OP_24bit_W 0x01
+#define EEP_Addr_Aux_Data_OP_32bit_W 0x02
+#define EEP_Addr_Aux_Data_OP_Serial_OP0 0x03
+
+#define EEP_Addr_Checksum 0x02
+
+#define EEP_Addr_Mifare_ICODE 0x03
+#define EEP_Addr_Mifare_ICODE_MIFARE 0x00
+#define EEP_Addr_Mifare_ICODE_ICODE 0x01
+
+#define EEP_Addr_Weigand_Parity 0x04
+#define EEP_Addr_Weigand_Parity_None 0x00
+#define EEP_Addr_Weigand_Parity_On 0x01
+
+#define EEP_Addr_Aux_Block_Addr 0x05
+
+#define EEP_Addr_Key_Number 0x06
+
+#define EEP_Addr_Beep_Delay 0x07
+#define EEP_Addr_Beep_Delay_OFF 0x00
+
+#define EEP_Addr_OP_Source_Data 0x08
+#define EEP_Addr_OP_Source_Data_UID 0x00
+#define EEP_Addr_OP_Source_Data_Block 0x01
+
+#define EEP_Addr_Aux_Out_ReDir 0x09
+#define EEP_Addr_Aux_Out_ReDir_OP0 0x00
+#define EEP_Addr_Aux_Out_ReDir_TX 0x01
+
+#define EEP_Addr_OP_Fmt 0x0A
+#define EEP_Addr_OP_Fmt_Hex 0x00
+#define EEP_Addr_OP_Fmt_ASCII 0x01
+
+#define EEP_Addr_Byte_Order 0x0B
+#define EEP_Addr_Byte_Order_Default 0x00
+#define EEP_Addr_Byte_Order_Reversed 0x01
+
+ //Initialize the reader to operate in Mifare mode
+ RWDMifareErr init();
+
+ //Checks if a card is present, and if so gets its UID
+ //Returns UID length as well (4, 7, or 10-bytes long)
+ RWDMifareErr getUID(uint8_t* pUID, size_t* pLen); //pUID must be at least 10-bytes long
+
+ //Gets Status
+ RWDMifareErr getStatus(uint8_t* Status);
+ RWDMifareErr Prog_EEPROM(uint8_t Address, uint8_t Value);
+ RWDMifareErr ReadBlock(uint8_t Addr, uint8_t KeyNumber, uint8_t Type, uint8_t* Data);
+ RWDMifareErr AuthAllCards();
+};
+
+#endif
\ No newline at end of file