14static unsigned char dscrc_table[] = {
15 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65,
16 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220,
17 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98,
18 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255,
19 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7,
20 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154,
21 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36,
22 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185,
23 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205,
24 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80,
25 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238,
26 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115,
27 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139,
28 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22,
29 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168,
30 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53};
36void OWTargetSetup(
unsigned char family_code);
37void OWFamilySkipSetup();
39unsigned char docrc8(
unsigned char value);
42unsigned char ROM_NO[8];
44int LastFamilyDiscrepancy;
57 LastDeviceFlag = FALSE;
58 LastFamilyDiscrepancy = 0;
83 int last_zero, rom_byte_number, search_result;
84 int id_bit, cmp_id_bit;
85 unsigned char rom_byte_mask, search_direction;
103 LastDeviceFlag = FALSE;
104 LastFamilyDiscrepancy = 0;
119 if ((id_bit == 1) && (cmp_id_bit == 1))
124 if (id_bit != cmp_id_bit)
125 search_direction = id_bit;
130 if (id_bit_number < LastDiscrepancy)
131 search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
134 search_direction = (id_bit_number == LastDiscrepancy);
137 if (search_direction == 0)
139 last_zero = id_bit_number;
143 LastFamilyDiscrepancy = last_zero;
149 if (search_direction == 1)
150 ROM_NO[rom_byte_number] |= rom_byte_mask;
152 ROM_NO[rom_byte_number] &= ~rom_byte_mask;
163 if (rom_byte_mask == 0)
165 docrc8(ROM_NO[rom_byte_number]);
171 while(rom_byte_number < 8);
174 if (!((id_bit_number < 65) || (crc8 != 0)))
177 LastDiscrepancy = last_zero;
180 if (LastDiscrepancy == 0)
181 LastDeviceFlag = TRUE;
183 search_result = TRUE;
188 if (!search_result || !ROM_NO[0])
191 LastDeviceFlag = FALSE;
192 LastFamilyDiscrepancy = 0;
193 search_result = FALSE;
196 return search_result;
206 unsigned char rom_backup[8];
207 int i,rslt,ld_backup,ldf_backup,lfd_backup;
210 for (i = 0; i < 8; i++)
211 rom_backup[i] = ROM_NO[i];
212 ld_backup = LastDiscrepancy;
213 ldf_backup = LastDeviceFlag;
214 lfd_backup = LastFamilyDiscrepancy;
217 LastDiscrepancy = 64;
218 LastDeviceFlag = FALSE;
224 for (i = 0; i < 8; i++)
226 if (rom_backup[i] != ROM_NO[i])
237 for (i = 0; i < 8; i++)
238 ROM_NO[i] = rom_backup[i];
239 LastDiscrepancy = ld_backup;
240 LastDeviceFlag = ldf_backup;
241 LastFamilyDiscrepancy = lfd_backup;
251void OWTargetSetup(
unsigned char family_code)
256 ROM_NO[0] = family_code;
257 for (i = 1; i < 8; i++)
259 LastDiscrepancy = 64;
260 LastFamilyDiscrepancy = 0;
261 LastDeviceFlag = FALSE;
268void OWFamilySkipSetup()
271 LastDiscrepancy = LastFamilyDiscrepancy;
272 LastFamilyDiscrepancy = 0;
275 if (LastDiscrepancy == 0)
276 LastDeviceFlag = TRUE;
284unsigned char docrc8(
unsigned char value)
289 crc8 = dscrc_table[crc8 ^ value];
Main NEORV32 core library / driver / HAL include file.
void neorv32_onewire_write_bit_blocking(uint8_t bit)
Definition neorv32_onewire.c:327
void neorv32_onewire_write_byte_blocking(uint8_t byte)
Definition neorv32_onewire.c:364
uint8_t neorv32_onewire_read_bit_blocking(void)
Definition neorv32_onewire.c:307
int neorv32_onewire_reset_blocking(void)
Definition neorv32_onewire.c:287