PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.9KB

  1. /*
  2. * --------------------------------------------------------------------------------------------------------------------
  3. * Example sketch/program to test your firmware.
  4. * --------------------------------------------------------------------------------------------------------------------
  5. * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
  6. *
  7. * This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed
  8. * it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken.
  9. * NOTE: for more informations read the README.rst
  10. *
  11. * @author Rotzbua
  12. * @license Released into the public domain.
  13. *
  14. * Typical pin layout used:
  15. * -----------------------------------------------------------------------------------------
  16. * MFRC522 Arduino Arduino Arduino Arduino Arduino
  17. * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
  18. * Signal Pin Pin Pin Pin Pin Pin
  19. * -----------------------------------------------------------------------------------------
  20. * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  21. * SPI SS SDA(SS) 10 53 D10 10 10
  22. * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  23. * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  24. * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
  25. */
  26. #include <SPI.h>
  27. #include <MFRC522.h>
  28. constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
  29. constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
  30. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
  31. /**
  32. * Check firmware only once at startup
  33. */
  34. void setup() {
  35. Serial.begin(9600); // Initialize serial communications with the PC
  36. while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  37. SPI.begin(); // Init SPI bus
  38. mfrc522.PCD_Init(); // Init MFRC522 module
  39. Serial.println(F("*****************************"));
  40. Serial.println(F("MFRC522 Digital self test"));
  41. Serial.println(F("*****************************"));
  42. mfrc522.PCD_DumpVersionToSerial(); // Show version of PCD - MFRC522 Card Reader
  43. Serial.println(F("-----------------------------"));
  44. Serial.println(F("Only known versions supported"));
  45. Serial.println(F("-----------------------------"));
  46. Serial.println(F("Performing test..."));
  47. bool result = mfrc522.PCD_PerformSelfTest(); // perform the test
  48. Serial.println(F("-----------------------------"));
  49. Serial.print(F("Result: "));
  50. if (result)
  51. Serial.println(F("OK"));
  52. else
  53. Serial.println(F("DEFECT or UNKNOWN"));
  54. Serial.println();
  55. }
  56. void loop() {} // nothing to do