SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | * DEKLARACE GLOBAL PROMENNYCH | |
3 | */ | |
4 | ||
5 | uint64_t ROM_NO = 0; | |
6 | - | volatile char temperature_char [15]; |
6 | + | |
7 | /* | |
8 | * FUNKCE | |
9 | */ | |
10 | ||
11 | void first (void) | |
12 | { | |
13 | uint8_t id_bit_number = 0; | |
14 | uint8_t id_bit = 0; | |
15 | uint8_t cmp_id_bit = 0; | |
16 | uint8_t LastDiscrepancy = 0; | |
17 | uint8_t LastDeviceFlag = 0; | |
18 | uint8_t last_zero = 0; | |
19 | ||
20 | uint8_t search_direction; | |
21 | ||
22 | - | char str; |
22 | + | |
23 | { | |
24 | id_bit_number = 1; | |
25 | LastDiscrepancy = 0; | |
26 | last_zero = 0; | |
27 | ||
28 | therm_write_byte(THERM_CMD_SEARCHROM); | |
29 | ||
30 | for(uint8_t i=0; i<64; i++ ) | |
31 | { | |
32 | id_bit = therm_read_bit(); | |
33 | - | lcdFunc(LCD_FUNC_CLEAR); |
33 | + | |
34 | if(therm_read_bit()) | |
35 | { | |
36 | if(id_bit) return; // Error no device on bus | |
37 | else search_direction = 0; // 01 | |
38 | ||
39 | } | |
40 | else | |
41 | { | |
42 | - | if(id_bit) return; // Error no device on bus |
42 | + | |
43 | - | else search_direction = 0; // 01 |
43 | + | else // Discrepancy |
44 | { | |
45 | if(id_bit_number > LastDiscrepancy) {last_zero = id_bit_number; search_direction = 0;} | |
46 | else if (id_bit_number == LastDiscrepancy) search_direction = 1; | |
47 | else search_direction = ROM_NO & ((uint64_t)1 << id_bit_number); | |
48 | } | |
49 | - | else // Discrepancy |
49 | + | |
50 | }//konec if(therm_read_bit()) | |
51 | ||
52 | if(search_direction) ROM_NO |= ((uint64_t)1 << i); | |
53 | else ROM_NO &= ~((uint64_t)1 << i); | |
54 | ||
55 | therm_write_bit(search_direction); | |
56 | id_bit_number++; | |
57 | ||
58 | }//konec foru | |
59 | LastDiscrepancy = last_zero; | |
60 | } |