uhf_module.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <stddef.h>
  5. #include "uhf_buffer.h"
  6. #include "uhf_tag.h"
  7. #include <furi_hal.h>
  8. #define FRAME_END 0x7E
  9. #define DEFAULT_BAUDRATE 115200
  10. typedef struct {
  11. char* hw_version;
  12. char* sw_version;
  13. char* manufacturer;
  14. } M100ModuleInfo;
  15. typedef enum {
  16. WA_CHINA_900 = 1, // Freq_CH-920.125M
  17. WA_US, // Freq_CH-902.25M
  18. WA_EU, // Freq_CH-865.1M
  19. WA_CHINA_800, // Freq_CH-840.125M
  20. WA_KOREA = 6 // Freq_CH-917.1M
  21. } WorkingArea;
  22. typedef enum {
  23. WC_CHINA_900 = 1, // CH_Index(CN,900MHz) = (Freq_CH-920.125M)/0.25M
  24. WC_US, // CH_Index(US) = (Freq_CH-902.25M)/0.5M
  25. WC_EU, // CH_Index(EU) = (Freq_CH-865.1M)/0.2M
  26. WC_CHINA_800, // CH_Index(CN,800MHz) = (Freq_CH-840.125M)/0.25M
  27. WC_KOREA = 6 // CH_Index(Korea) = (Freq_CH-917.1M)/0.2M
  28. } WorkingChannel;
  29. typedef enum {
  30. M100Success,
  31. M100ValidationFail,
  32. M100NoTagResponse,
  33. M100MemoryOverrun
  34. } M100ResponseType;
  35. typedef struct {
  36. M100ModuleInfo* info;
  37. uint16_t baudrate;
  38. WorkingArea area;
  39. WorkingChannel channel;
  40. uint16_t transmitting_power;
  41. bool freq_hopping;
  42. Buffer* buf;
  43. } M100Module;
  44. M100ModuleInfo* m100_module_info_alloc();
  45. void m100_module_info_free(M100ModuleInfo* module_info);
  46. M100Module* m100_module_alloc();
  47. void m100_module_free(M100Module* module);
  48. uint16_t crc16_genibus(const uint8_t* data, size_t length);
  49. uint8_t checksum(const uint8_t* data, size_t length);
  50. // Function prototypes
  51. char* m100_get_hardware_version(M100Module* module);
  52. char* m100_get_software_version(M100Module* module);
  53. char* m100_get_manufacturers(M100Module* module);
  54. void m100_set_baudrate(M100Module* module, uint16_t baudrate);
  55. bool m100_set_working_area(M100Module* module, WorkingArea area);
  56. bool m100_set_working_channel(M100Module* module, WorkingChannel channel);
  57. bool m100_set_transmitting_power(M100Module* module, uint16_t power);
  58. bool m100_set_freq_hopping(M100Module* module, bool hopping);
  59. // gen2 cmds
  60. M100ResponseType m100_send_single_poll(M100Module* module, UHFTag* uhf_tag);
  61. M100ResponseType m100_set_select(M100Module* module, UHFTag* uhf_tag);
  62. M100ResponseType m100_read_label_data_storage(
  63. M100Module* module,
  64. UHFTag* uhf_tag,
  65. BankType bank,
  66. uint32_t access_pwd,
  67. uint16_t word_count);
  68. M100ResponseType m100_write_label_data_storage(
  69. M100Module* module,
  70. UHFTag* saved_tag,
  71. UHFTag* selected_tag,
  72. BankType bank,
  73. uint16_t source_address,
  74. uint32_t access_pwd);