rfid_reader.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. //#include "decoder_analyzer.h"
  3. #include "decoder_gpio_out.h"
  4. #include "decoder_emmarin.h"
  5. #include "decoder_hid26.h"
  6. #include "decoder_indala.h"
  7. #include "key_info.h"
  8. //#define RFID_GPIO_DEBUG 1
  9. class RfidReader {
  10. public:
  11. enum class Type : uint8_t {
  12. Normal,
  13. Indala,
  14. };
  15. RfidReader();
  16. void start();
  17. void start_forced(RfidReader::Type type);
  18. void stop();
  19. bool read(LfrfidKeyType* type, uint8_t* data, uint8_t data_size, bool switch_enable = true);
  20. bool detect();
  21. bool any_read();
  22. private:
  23. friend struct RfidReaderAccessor;
  24. //DecoderAnalyzer decoder_analyzer;
  25. #ifdef RFID_GPIO_DEBUG
  26. DecoderGpioOut decoder_gpio_out;
  27. #endif
  28. DecoderEMMarin decoder_em;
  29. DecoderHID26 decoder_hid26;
  30. DecoderIndala decoder_indala;
  31. uint32_t last_dwt_value;
  32. void start_comparator(void);
  33. void stop_comparator(void);
  34. void decode(bool polarity);
  35. uint32_t detect_ticks;
  36. uint32_t switch_os_tick_last;
  37. bool switch_timer_elapsed();
  38. void switch_timer_reset();
  39. void switch_mode();
  40. LfrfidKeyType last_read_type;
  41. uint8_t last_read_data[LFRFID_KEY_SIZE];
  42. uint8_t last_read_count;
  43. Type type = Type::Normal;
  44. };