uhf_module.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include <stddef.h>
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <furi_hal.h>
  6. #include "uhf_tag.h"
  7. #include "uhf_buffer.h"
  8. #include "uhf_module_settings.h"
  9. #define FRAME_END 0x7E
  10. #define DEFAULT_BAUDRATE 115200
  11. typedef struct {
  12. char* hw_version;
  13. char* sw_version;
  14. char* manufacturer;
  15. } M100ModuleInfo;
  16. typedef enum {
  17. M100Success,
  18. M100ValidationFail,
  19. M100NoTagResponse,
  20. M100MemoryOverrun
  21. } M100ResponseType;
  22. typedef struct {
  23. M100ModuleInfo* info;
  24. uint16_t baudrate;
  25. WorkingArea area;
  26. WorkingChannel channel;
  27. uint16_t transmitting_power;
  28. bool freq_hopping;
  29. Buffer* buf;
  30. } M100Module;
  31. M100ModuleInfo* m100_module_info_alloc();
  32. void m100_module_info_free(M100ModuleInfo* module_info);
  33. M100Module* m100_module_alloc();
  34. void m100_module_free(M100Module* module);
  35. uint16_t crc16_genibus(const uint8_t* data, size_t length);
  36. uint8_t checksum(const uint8_t* data, size_t length);
  37. uint8_t get_baudrate_count();
  38. // Function prototypes
  39. char* m100_get_hardware_version(M100Module* module);
  40. char* m100_get_software_version(M100Module* module);
  41. char* m100_get_manufacturers(M100Module* module);
  42. void m100_set_baudrate(M100Module* module, uint16_t baudrate);
  43. bool m100_set_working_area(M100Module* module, WorkingArea area);
  44. bool m100_set_working_channel(M100Module* module, WorkingChannel channel);
  45. bool m100_set_transmitting_power(M100Module* module, uint16_t power);
  46. bool m100_set_freq_hopping(M100Module* module, bool hopping);
  47. // gen2 cmds
  48. M100ResponseType m100_send_single_poll(M100Module* module, UHFTag* uhf_tag);
  49. M100ResponseType m100_set_select(M100Module* module, UHFTag* uhf_tag);
  50. M100ResponseType m100_read_label_data_storage(
  51. M100Module* module,
  52. UHFTag* uhf_tag,
  53. BankType bank,
  54. uint32_t access_pwd,
  55. uint16_t word_count);
  56. M100ResponseType m100_write_label_data_storage(
  57. M100Module* module,
  58. UHFTag* saved_tag,
  59. UHFTag* selected_tag,
  60. BankType bank,
  61. uint16_t source_address,
  62. uint32_t access_pwd);