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.
Dependencies: mbed
Fork of RFID-RC522 by
Revision 3:99dc0ceb4f3e, committed 2018-01-28
- Comitter:
- Izzy00
- Date:
- Sun Jan 28 14:26:40 2018 +0000
- Parent:
- 2:a0c7513fb634
- Commit message:
- ?p
Changed in this revision
| MFRC522.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a0c7513fb634 -r 99dc0ceb4f3e MFRC522.cpp --- a/MFRC522.cpp Fri Jun 06 03:04:48 2014 +0000 +++ b/MFRC522.cpp Sun Jan 28 14:26:40 2018 +0000 @@ -996,7 +996,8 @@ // Support functions ///////////////////////////////////////////////////////////////////////////////////// -/* +/* pod[0]=rfid.write(PCD_TRANSCEIVE); + * Wrapper for MIFARE protocol communication. * Adds CRC_A, executes the Transceive command and checks that the response is MF_ACK or a timeout. */
diff -r a0c7513fb634 -r 99dc0ceb4f3e main.cpp
--- a/main.cpp Fri Jun 06 03:04:48 2014 +0000
+++ b/main.cpp Sun Jan 28 14:26:40 2018 +0000
@@ -1,6 +1,5 @@
-//Test of cheap 13.56 Mhz RFID-RC522 module from eBay
-//This code is based on Martin Olejar's MFRC522 library. Minimal changes
-//Adapted for Nucleo STM32 F401RE. Should work on other Nucleos too
+//RFID-RC522
+//Bazirano na Martin Olejar's MFRC522 library.
//Connect as follows:
//RFID pins -> Nucleo header CN5 (Arduino-compatible header)
@@ -16,17 +15,17 @@
#include "mbed.h"
#include "MFRC522.h"
-// Nucleo Pin for MFRC522 reset (pick another D pin if you need D8)
-#define MF_RESET D8
+
DigitalOut LedGreen(LED1);
//Serial connection to PC for output
-Serial pc(SERIAL_TX, SERIAL_RX);
+Serial pc(USBTX, USBRX);
-MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET);
+MFRC522 RfChip (p5,p6,p7,p8,p9);
int main(void) {
+ uint8_t test [4];
pc.printf("starting...\n");
// Init. RC522 Chip
@@ -41,7 +40,7 @@
wait_ms(500);
continue;
}
-
+
// Select one of the cards
if ( ! RfChip.PICC_ReadCardSerial())
{
@@ -55,13 +54,18 @@
pc.printf("Card UID: ");
for (uint8_t i = 0; i < RfChip.uid.size; i++)
{
- pc.printf(" %X02", RfChip.uid.uidByte[i]);
+ pc.printf(" %0X02", RfChip.uid.uidByte[i]);
+
}
pc.printf("\n\r");
-
- // Print Card type
- uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
- pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
+ if(RfChip.uid.uidByte[0]==23)
+ {
+ pc.printf("dobra\n");
+ }
+ else if(RfChip.uid.uidByte[0]!=23)
+ {
+ pc.printf("kriva\n");
+ }
wait_ms(1000);
}
-}
\ No newline at end of file
+}
