prog test rfid

Dependencies:   mbed MFRC522

Files at this revision

API Documentation at this revision

Comitter:
loucca
Date:
Fri Mar 01 10:36:21 2019 +0000
Commit message:
test_rfid_gr1

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 3a667e95c355 MFRC522.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MFRC522.lib	Fri Mar 01 10:36:21 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/AtomX/code/MFRC522/#63d729186747
diff -r 000000000000 -r 3a667e95c355 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 01 10:36:21 2019 +0000
@@ -0,0 +1,57 @@
+#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      p21
+ DigitalOut LedRed   (LED1);
+ DigitalOut LedGreen (LED2);
+  #define MF_RESET    p8
+ //#define UART_RX     p27
+//#define UART_TX     p28
+
+ //Serial     DebugUART(UART_TX, UART_RX);
+ MFRC522    RfChip   (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET);
+
+ int main(void) {
+   // Set debug UART speed
+   //DebugUART.baud(115200);
+
+   // Init. RC522 Chip
+   RfChip.PCD_Init();
+
+   while (true) {
+     LedRed   = 1;
+     LedGreen = 1;
+
+     // Look for new cards
+     if ( ! RfChip.PICC_IsNewCardPresent())
+     {
+       wait_ms(500);
+       continue;
+       
+     }
+     LedRed   = 0;
+
+     // Select one of the cards
+     if ( ! RfChip.PICC_ReadCardSerial())
+     {
+       wait_ms(500);
+       continue;
+      
+     }
+     LedRed   = 1;
+     LedGreen = 0;
+
+     // Print Card UID
+     printf("Card UID: ");
+     for (uint8_t i = 0; i < RfChip.uid.size; i++)
+     {
+       printf(" %X", RfChip.uid.uidByte[i]);
+     }
+     printf("\n\r");
+
+   }
+ }
\ No newline at end of file
diff -r 000000000000 -r 3a667e95c355 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 01 10:36:21 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file