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
37void OWTargetSetup(
unsigned char family_code);
38void OWFamilySkipSetup();
40unsigned char docrc8(
unsigned char value);
43unsigned char ROM_NO[8];
45int LastFamilyDiscrepancy;
58 LastDeviceFlag = FALSE;
59 LastFamilyDiscrepancy = 0;
84 int last_zero, rom_byte_number, search_result;
85 int id_bit, cmp_id_bit;
86 unsigned char rom_byte_mask, search_direction;
104 LastDeviceFlag = FALSE;
105 LastFamilyDiscrepancy = 0;
120 if ((id_bit == 1) && (cmp_id_bit == 1))
125 if (id_bit != cmp_id_bit)
126 search_direction = id_bit;
131 if (id_bit_number < LastDiscrepancy)
132 search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
135 search_direction = (id_bit_number == LastDiscrepancy);
138 if (search_direction == 0)
140 last_zero = id_bit_number;
144 LastFamilyDiscrepancy = last_zero;
150 if (search_direction == 1)
151 ROM_NO[rom_byte_number] |= rom_byte_mask;
153 ROM_NO[rom_byte_number] &= ~rom_byte_mask;
164 if (rom_byte_mask == 0)
166 docrc8(ROM_NO[rom_byte_number]);
172 while(rom_byte_number < 8);
175 if (!((id_bit_number < 65) || (crc8 != 0)))
178 LastDiscrepancy = last_zero;
181 if (LastDiscrepancy == 0)
182 LastDeviceFlag = TRUE;
184 search_result = TRUE;
189 if (!search_result || !ROM_NO[0])
192 LastDeviceFlag = FALSE;
193 LastFamilyDiscrepancy = 0;
194 search_result = FALSE;
197 return search_result;
207 unsigned char rom_backup[8];
208 int i,rslt,ld_backup,ldf_backup,lfd_backup;
211 for (i = 0; i < 8; i++)
212 rom_backup[i] = ROM_NO[i];
213 ld_backup = LastDiscrepancy;
214 ldf_backup = LastDeviceFlag;
215 lfd_backup = LastFamilyDiscrepancy;
218 LastDiscrepancy = 64;
219 LastDeviceFlag = FALSE;
225 for (i = 0; i < 8; i++)
227 if (rom_backup[i] != ROM_NO[i])
238 for (i = 0; i < 8; i++)
239 ROM_NO[i] = rom_backup[i];
240 LastDiscrepancy = ld_backup;
241 LastDeviceFlag = ldf_backup;
242 LastFamilyDiscrepancy = lfd_backup;
252void OWTargetSetup(
unsigned char family_code)
257 ROM_NO[0] = family_code;
258 for (i = 1; i < 8; i++)
260 LastDiscrepancy = 64;
261 LastFamilyDiscrepancy = 0;
262 LastDeviceFlag = FALSE;
269void OWFamilySkipSetup()
272 LastDiscrepancy = LastFamilyDiscrepancy;
273 LastFamilyDiscrepancy = 0;
276 if (LastDiscrepancy == 0)
277 LastDeviceFlag = TRUE;
285unsigned char docrc8(
unsigned char value)
290 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:332
void neorv32_onewire_write_byte_blocking(uint8_t byte)
Definition neorv32_onewire.c:372
uint8_t neorv32_onewire_read_bit_blocking(void)
Definition neorv32_onewire.c:312
int neorv32_onewire_reset_blocking(void)
Definition neorv32_onewire.c:292