ER

Dependencies:   mbed MFRC522

Files at this revision

API Documentation at this revision

Comitter:
dorian06
Date:
Wed Jun 09 12:26:11 2021 +0000
Commit message:
ER2

Changed in this revision

MFRC522.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 91f18ae471f0 MFRC522.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MFRC522.lib	Wed Jun 09 12:26:11 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/AtomX/code/MFRC522/#63d729186747
diff -r 000000000000 -r 91f18ae471f0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 09 12:26:11 2021 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include "MFRC522.h"
+
+//KL25Z Pins for MFRC522 SPI interface
+#define SPI_MOSI    p5
+#define SPI_MISO    p6
+#define SPI_SCLK    p7
+#define SPI_CS      p16
+// KL25Z Pin for MFRC522 reset
+#define MF_RESET    p8
+void fct(void);
+Ticker T1;
+DigitalOut LedRed (LED1);
+DigitalOut LedGreen (LED2);
+MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCLK,SPI_CS,MF_RESET);
+int main()
+{
+    RfChip.PCD_Init();
+    T1.attach(&fct,0.2);
+    while(1) {
+        wait_ms(200);
+    }
+}
+void fct(void){
+    if (  RfChip.PICC_IsNewCardPresent()) {
+        if(RfChip.PICC_ReadCardSerial()) {
+            LedRed   = 1;
+            LedGreen = 0;
+            printf("Card UID: ");
+            // Print Card UID
+            for (uint8_t i = 0; i < RfChip.uid.size; i++) {
+                printf(" %02X", RfChip.uid.uidByte[i]);
+            }
+            printf("\n\r");
+
+            // Print Card type
+            uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
+            printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
+            wait_ms(500);
+
+        }
+    }
+}
+    
\ No newline at end of file
diff -r 000000000000 -r 91f18ae471f0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 09 12:26:11 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file