gen4.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include <lib/nfc/protocols/mifare_classic.h>
  3. #define MAGIC_GEN4_DEFAULT_PWD 0x00000000
  4. #define MAGIC_GEN4_CONFIG_LEN 30
  5. #define NFCID1_SINGLE_SIZE 4
  6. #define NFCID1_DOUBLE_SIZE 7
  7. #define NFCID1_TRIPLE_SIZE 10
  8. typedef enum {
  9. MagicGen4UIDLengthSingle = 0x00,
  10. MagicGen4UIDLengthDouble = 0x01,
  11. MagicGen4UIDLengthTriple = 0x02
  12. } MagicGen4UIDLength;
  13. typedef enum {
  14. MagicGen4UltralightModeUL_EV1 = 0x00,
  15. MagicGen4UltralightModeNTAG = 0x01,
  16. MagicGen4UltralightModeUL_C = 0x02,
  17. MagicGen4UltralightModeUL = 0x03
  18. } MagicGen4UltralightMode;
  19. typedef enum {
  20. // for writing original (shadow) data
  21. MagicGen4ShadowModePreWrite = 0x00,
  22. // written data can be read once before restored to original
  23. MagicGen4ShadowModeRestore = 0x01,
  24. // written data is discarded
  25. MagicGen4ShadowModeIgnore = 0x02,
  26. // apparently for UL?
  27. MagicGen4ShadowModeHighSpeedIgnore = 0x03
  28. } MagicGen4ShadowMode;
  29. extern const uint8_t MAGIC_DEFAULT_CONFIG[];
  30. bool magic_gen4_get_cfg(uint32_t pwd, uint8_t* config);
  31. bool magic_gen4_set_cfg(uint32_t pwd, const uint8_t* config, uint8_t config_length, bool fuse);
  32. bool magic_gen4_set_pwd(uint32_t old_pwd, uint32_t new_pwd);
  33. bool magic_gen4_read_blk(uint32_t pwd, uint8_t block_num, uint8_t* data);
  34. bool magic_gen4_write_blk(uint32_t pwd, uint8_t block_num, const uint8_t* data);
  35. bool magic_gen4_wipe(uint32_t pwd);
  36. void magic_gen4_deactivate();