rfid_reader.h 1.3 KB

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