TA1 / RFID-RC522

Files at this revision

API Documentation at this revision

Comitter:
RizkyArdiMaulana
Date:
Tue Dec 22 22:16:36 2020 +0000
Parent:
3:ee5221e4c885
Commit message:
revising library

Changed in this revision

main.cpp Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Dec 05 07:54:57 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-//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
-
-//Connect as follows:
-//RFID pins        ->  Nucleo header CN5 (Arduino-compatible header)
-//----------------------------------------
-//RFID IRQ=pin5    ->   Not used. Leave open
-//RFID MISO=pin4   ->   Nucleo SPI_MISO=PA_6=D12
-//RFID MOSI=pin3   ->   Nucleo SPI_MOSI=PA_7=D11
-//RFID SCK=pin2    ->   Nucleo SPI_SCK =PA_5=D13
-//RFID SDA=pin1    ->   Nucleo SPI_CS  =PB_6=D10
-//RFID RST=pin7    ->   Nucleo         =PA_9=D8
-//3.3V and Gnd to the respective pins                              
-                              
-#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);
-
-MFRC522    RfChip   (D11, D12, D13, D10, D8);
-
-
-int main(void) {
-  pc.printf("starting...\n");
-  uint8_t data[10] ;
-  data[0] = 0x33;
-  data[1] = 0x59;
-  data[2] = 0xA8;
-  data[3] = 0x2;
-  uint8_t sum_cocok = 0;  
-
-  // Init. RC522 Chip
-  RfChip.PCD_Init();
-  while (true) {
-    LedGreen = 1;
-
-    // Look for new cards
-    if ( ! RfChip.PICC_IsNewCardPresent())
-    {
-      wait_ms(500);
-      continue;
-    }
-
-    // Select one of the cards
-    if ( ! RfChip.PICC_ReadCardSerial())
-    {
-      wait_ms(500);
-      continue;
-    }
-
-    LedGreen = 0;
-
-    // Print Card UID
-    pc.printf("Card UID: ");
-    for (uint8_t i = 0; i < RfChip.uid.size; i++)
-    {
-      pc.printf(" %X", RfChip.uid.uidByte[i]);
-      if (RfChip.uid.uidByte[i] == data[i]){
-          sum_cocok = sum_cocok + 1;
-        }
-    }
-    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));
-    pc.printf ("%d %d \n",sum_cocok,RfChip.uid.size);  
-    if (sum_cocok == RfChip.uid.size){
-        pc.printf("Acces Allowed \n ");
-        sum_cocok = 0;
-        }
-    else{
-        pc.printf("Acces Denied \n ");
-        sum_cocok = 0;
-        }
-    wait_ms(1000);
-  }
-}
\ No newline at end of file
--- a/mbed.bld	Sat Dec 05 07:54:57 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file