Loading...
Searching...
No Matches
dallas_common.h
1#pragma once
2
5
7
8#define DALLAS_COMMON_MANUFACTURER_NAME "Dallas"
9
10#define DALLAS_COMMON_CMD_READ_ROM 0x33U
11#define DALLAS_COMMON_CMD_MATCH_ROM 0x55U
12#define DALLAS_COMMON_CMD_SKIP_ROM 0xCCU
13#define DALLAS_COMMON_CMD_COND_SEARCH 0xECU
14#define DALLAS_COMMON_CMD_SEARCH_ROM 0xF0U
15
16#define DALLAS_COMMON_CMD_READ_SCRATCH 0xAAU
17#define DALLAS_COMMON_CMD_WRITE_SCRATCH 0x0FU
18#define DALLAS_COMMON_CMD_COPY_SCRATCH 0x55U
19
20#define DALLAS_COMMON_CMD_READ_MEM 0xF0U
21
22#define DALLAS_COMMON_CMD_OVERDRIVE_SKIP_ROM 0x3CU
23#define DALLAS_COMMON_CMD_OVERDRIVE_MATCH_ROM 0x69U
24
25typedef enum {
26 DallasCommonCommandStateIdle,
27 DallasCommonCommandStateRomCmd,
28 DallasCommonCommandStateMemCmd,
29} DallasCommonCommandState;
30
31typedef union {
32 struct {
33 uint8_t family_code;
34 uint8_t serial_number[6];
35 uint8_t checksum;
36 } fields;
37 uint8_t bytes[8];
39
40typedef union {
41 struct {
42 uint8_t address_lo;
43 uint8_t address_hi;
44 uint8_t status;
45 } fields;
46 uint8_t bytes[3];
48
49/* Standard(ish) iButton commands */
50bool dallas_common_skip_rom(OneWireHost* host);
51
52bool dallas_common_read_rom(OneWireHost* host, DallasCommonRomData* rom_data);
53
54bool dallas_common_write_scratchpad(
55 OneWireHost* host,
56 uint16_t address,
57 const uint8_t* data,
58 size_t data_size);
59
60bool dallas_common_read_scratchpad(
61 OneWireHost* host,
63 uint8_t* data,
64 size_t data_size);
65
66bool dallas_common_copy_scratchpad(
67 OneWireHost* host,
68 const DallasCommonAddressRegs* regs,
69 uint32_t timeout_us);
70
71bool dallas_common_read_mem(OneWireHost* host, uint16_t address, uint8_t* data, size_t data_size);
72
73/* Combined operations */
74bool dallas_common_write_mem(
75 OneWireHost* host,
76 uint32_t timeout_us,
77 size_t page_size,
78 const uint8_t* data,
79 size_t data_size);
80
81/* Emulation */
82bool dallas_common_emulate_search_rom(OneWireSlave* bus, const DallasCommonRomData* rom_data);
83
84bool dallas_common_emulate_read_rom(OneWireSlave* bus, const DallasCommonRomData* rom_data);
85
86bool dallas_common_emulate_read_mem(OneWireSlave* bus, const uint8_t* data, size_t data_size);
87
88/* Save & Load */
89bool dallas_common_save_rom_data(FlipperFormat* ff, const DallasCommonRomData* rom_data);
90
91bool dallas_common_load_rom_data(
92 FlipperFormat* ff,
93 uint32_t format_version,
94 DallasCommonRomData* rom_data);
95
96/* Miscellaneous */
97bool dallas_common_is_valid_crc(const DallasCommonRomData* rom_data);
98
99void dallas_common_render_uid(FuriString* result, const DallasCommonRomData* rom_data);
100
101void dallas_common_render_brief_data(
102 FuriString* result,
103 const DallasCommonRomData* rom_data,
104 const uint8_t* mem_data,
105 size_t mem_size,
106 const char* mem_name);
107
108void dallas_common_render_crc_error(FuriString* result, const DallasCommonRomData* rom_data);
109
110void dallas_common_apply_edits(DallasCommonRomData* rom_data, uint8_t family_code);
Flipper File Format helper library.
1-Wire host (master) library
1-Wire slave library.
Definition flipper_format.c:12
Definition string.c:4
Definition one_wire_host.c:49
Definition one_wire_slave.c:31
Definition dallas_common.h:40
Definition dallas_common.h:31