PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

FixBrickedUID.ino 2.5KB

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * --------------------------------------------------------------------------------------------------------------------
  3. * Example sketch/program to fix a broken UID changeable MIFARE cards.
  4. * --------------------------------------------------------------------------------------------------------------------
  5. * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
  6. *
  7. * This sample shows how to fix a broken UID changeable MIFARE cards that have a corrupted sector 0.
  8. *
  9. * @author Tom Clement
  10. * @license Released into the public domain.
  11. *
  12. * Typical pin layout used:
  13. * -----------------------------------------------------------------------------------------
  14. * MFRC522 Arduino Arduino Arduino Arduino Arduino
  15. * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
  16. * Signal Pin Pin Pin Pin Pin Pin
  17. * -----------------------------------------------------------------------------------------
  18. * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  19. * SPI SS SDA(SS) 10 53 D10 10 10
  20. * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  21. * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  22. * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
  23. */
  24. #include <SPI.h>
  25. #include <MFRC522.h>
  26. #include <MFRC522Hack.h>
  27. constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
  28. constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
  29. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
  30. MFRC522Hack mfrc522Hack(&mfrc522); // Create MFRC522Hack instance.
  31. MFRC522::MIFARE_Key key;
  32. void setup() {
  33. Serial.begin(9600); // Initialize serial communications with the PC
  34. while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  35. SPI.begin(); // Init SPI bus
  36. mfrc522.PCD_Init(); // Init MFRC522 card
  37. Serial.println(F("Warning: this example clears your mifare UID, use with care!"));
  38. // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
  39. for (byte i = 0; i < 6; i++) {
  40. key.keyByte[i] = 0xFF;
  41. }
  42. }
  43. void loop() {
  44. if ( mfrc522Hack.MIFARE_UnbrickUidSector(false) ) {
  45. Serial.println(F("Cleared sector 0, set UID to 1234. Card should be responsive again now."));
  46. }
  47. delay(1000);
  48. }