📄 thermometer.lss
字号:
770: 40 e0 ldi r20, 0x00 ; 0
772: 50 e0 ldi r21, 0x00 ; 0
while ((i++ < 64) && (x < 3)) /* 8 bytes */
{
if (!((i-1) % 8))
{
mask = 0x01; /* mask within a byte */
ptr++; /* skip to next byte if 8 bits passed */
774: b1 e0 ldi r27, 0x01 ; 1
776: a5 e0 ldi r26, 0x05 ; 5
}
else
#if 0 /* did not worked (against spec ?) */
tm_rombit = (x & 0x02); /* or (x & 1) ^ 1 (inverted LSb) */
#else
tm_rombit = (x & 1) ^ 1; /* inverted LSb */
778: 04 e1 ldi r16, 0x14 ; 20
77a: c1 e0 ldi r28, 0x01 ; 1
77c: d0 e0 ldi r29, 0x00 ; 0
77e: 8f e0 ldi r24, 0x0F ; 15
780: f8 2e mov r15, r24
782: 03 c0 rjmp .+6 ; 0x78a <TM_Search_next+0x5c>
TM_Enter_Critical(); /* disable interrupts */
if (!TM_Reset())
TM_Write_byte(0xF0);
else
{ TM_Exit_Critical(); /* reenable interrupts */
784: 0f 90 pop r0
786: 0f be out 0x3f, r0 ; 63
788: 6a c0 rjmp .+212 ; 0x85e <TM_Search_next+0x130>
return 0;
}
ptr--; /* adjust pointer to satisfy algorithm within loop below */
while ((i++ < 64) && (x < 3)) /* 8 bytes */
78a: 7f 5f subi r23, 0xFF ; 255
{
if (!((i-1) % 8))
78c: ca 01 movw r24, r20
78e: 87 70 andi r24, 0x07 ; 7
790: 90 70 andi r25, 0x00 ; 0
792: 89 2b or r24, r25
794: 19 f4 brne .+6 ; 0x79c <TM_Search_next+0x6e>
{
mask = 0x01; /* mask within a byte */
ptr++; /* skip to next byte if 8 bits passed */
796: 31 96 adiw r30, 0x01 ; 1
798: 61 e0 ldi r22, 0x01 ; 1
79a: 01 c0 rjmp .+2 ; 0x79e <TM_Search_next+0x70>
}
else
mask <<= 1; /* next bit */
79c: 66 0f add r22, r22
*/
static u_char TM_Read_bit(void)
{
u_char val;
sbi(DS_DDR, DQ); /* set DQ pin direction - output */
79e: d1 9a sbi 0x1a, 1 ; 26
cbi(DS_PORT, DQ); /* pull DQ low to start timeslot */
7a0: d9 98 cbi 0x1b, 1 ; 27
7a2: 8b 2f mov r24, r27
7a4: 8a 95 dec r24
7a6: f1 f7 brne .-4 ; 0x7a4 <TM_Search_next+0x76>
// _NOP(); /* wait 68 ns */
//COMPRESS_REENABLE;
_delay_us(0.2); //delay 200ns
sbi(DS_PORT, DQ); /* then return high DQ = 1 */
7a8: d9 9a sbi 0x1b, 1 ; 27
7aa: 8a 2f mov r24, r26
7ac: 8a 95 dec r24
7ae: f1 f7 brne .-4 ; 0x7ac <TM_Search_next+0x7e>
//TM_Delay(1); /* wait 15 us */
_delay_us(15); //delay 15us
cbi(DS_DDR, DQ); /* set DQ pin direction - input */
7b0: d1 98 cbi 0x1a, 1 ; 26
sbi(DS_PORT, DQ); /* enable AVR internal pull-up resistor */
7b2: d9 9a sbi 0x1b, 1 ; 27
bit_is_set(DS_PIN, DQ) ? (val = 1) : (val = 0); /* read DQ status */
7b4: 89 b3 in r24, 0x19 ; 25
7b6: 90 2f mov r25, r16
7b8: 9a 95 dec r25
7ba: f1 f7 brne .-4 ; 0x7b8 <TM_Search_next+0x8a>
ptr++; /* skip to next byte if 8 bits passed */
}
else
mask <<= 1; /* next bit */
x = ((u_char)TM_Read_bit()) << 1;
7bc: 90 e0 ldi r25, 0x00 ; 0
7be: 96 95 lsr r25
7c0: 87 95 ror r24
7c2: 38 2f mov r19, r24
7c4: 31 70 andi r19, 0x01 ; 1
7c6: 33 0f add r19, r19
*/
static u_char TM_Read_bit(void)
{
u_char val;
sbi(DS_DDR, DQ); /* set DQ pin direction - output */
7c8: d1 9a sbi 0x1a, 1 ; 26
cbi(DS_PORT, DQ); /* pull DQ low to start timeslot */
7ca: d9 98 cbi 0x1b, 1 ; 27
7cc: 8b 2f mov r24, r27
7ce: 8a 95 dec r24
7d0: f1 f7 brne .-4 ; 0x7ce <TM_Search_next+0xa0>
// _NOP(); /* wait 68 ns */
//COMPRESS_REENABLE;
_delay_us(0.2); //delay 200ns
sbi(DS_PORT, DQ); /* then return high DQ = 1 */
7d2: d9 9a sbi 0x1b, 1 ; 27
7d4: 8a 2f mov r24, r26
7d6: 8a 95 dec r24
7d8: f1 f7 brne .-4 ; 0x7d6 <TM_Search_next+0xa8>
//TM_Delay(1); /* wait 15 us */
_delay_us(15); //delay 15us
cbi(DS_DDR, DQ); /* set DQ pin direction - input */
7da: d1 98 cbi 0x1a, 1 ; 26
sbi(DS_PORT, DQ); /* enable AVR internal pull-up resistor */
7dc: d9 9a sbi 0x1b, 1 ; 27
bit_is_set(DS_PIN, DQ) ? (val = 1) : (val = 0); /* read DQ status */
7de: 89 b3 in r24, 0x19 ; 25
7e0: 90 2f mov r25, r16
7e2: 9a 95 dec r25
7e4: f1 f7 brne .-4 ; 0x7e2 <TM_Search_next+0xb4>
}
else
mask <<= 1; /* next bit */
x = ((u_char)TM_Read_bit()) << 1;
x |= TM_Read_bit();
7e6: 90 e0 ldi r25, 0x00 ; 0
7e8: 96 95 lsr r25
7ea: 87 95 ror r24
7ec: 81 70 andi r24, 0x01 ; 1
7ee: 38 2b or r19, r24
if (!x)
7f0: 69 f4 brne .+26 ; 0x80c <TM_Search_next+0xde>
{
if (i > lst_dif)
7f2: 17 17 cp r17, r23
7f4: 10 f4 brcc .+4 ; 0x7fa <TM_Search_next+0xcc>
7f6: 20 e0 ldi r18, 0x00 ; 0
7f8: 06 c0 rjmp .+12 ; 0x806 <TM_Search_next+0xd8>
tm_rombit = 0;
else
if (i == lst_dif) /* to device where conflict was last time use 1 now (it was 0 for previous device) */
7fa: 71 17 cp r23, r17
7fc: 09 f4 brne .+2 ; 0x800 <TM_Search_next+0xd2>
7fe: 3e c0 rjmp .+124 ; 0x87c <__stack+0x1d>
tm_rombit = 1;
else
tm_rombit = *ptr & mask;
800: 20 81 ld r18, Z
802: 26 23 and r18, r22
/* seed with bit value of previously found device */
if (!tm_rombit) /* last bit not set position */
804: 41 f4 brne .+16 ; 0x816 <TM_Search_next+0xe8>
tm_lst0 = i;
806: 70 93 aa 01 sts 0x01AA, r23
80a: 03 c0 rjmp .+6 ; 0x812 <TM_Search_next+0xe4>
}
else
#if 0 /* did not worked (against spec ?) */
tm_rombit = (x & 0x02); /* or (x & 1) ^ 1 (inverted LSb) */
#else
tm_rombit = (x & 1) ^ 1; /* inverted LSb */
80c: 23 2f mov r18, r19
80e: 2c 27 eor r18, r28
810: 21 70 andi r18, 0x01 ; 1
#endif
if (tm_rombit)
812: 22 23 and r18, r18
814: 19 f0 breq .+6 ; 0x81c <TM_Search_next+0xee>
*ptr |= mask;
816: 80 81 ld r24, Z
818: 86 2b or r24, r22
81a: 04 c0 rjmp .+8 ; 0x824 <TM_Search_next+0xf6>
else
*ptr &= ~mask;
81c: 96 2f mov r25, r22
81e: 90 95 com r25
820: 80 81 ld r24, Z
822: 89 23 and r24, r25
824: 80 83 st Z, r24
/*
* TM_WRITE_BIT - writes a byte to the one-wire bus, passed in u_charval.
*/
static void TM_Write_bit(u_char bitval)
{
sbi(DS_DDR, DQ); /* set DQ pin direction - output */
826: d1 9a sbi 0x1a, 1 ; 26
cbi(DS_PORT, DQ); /* pull DQ low to start timeslot */
828: d9 98 cbi 0x1b, 1 ; 27
82a: 8b 2f mov r24, r27
82c: 8a 95 dec r24
82e: f1 f7 brne .-4 ; 0x82c <TM_Search_next+0xfe>
// _NOP(); /* wait 68 ns */
//COMPRESS_REENABLE;
_delay_us(0.2); //delay 200ns
if( bitval ) sbi(DS_PORT, DQ); /* set DQ */
830: 22 23 and r18, r18
832: 11 f0 breq .+4 ; 0x838 <TM_Search_next+0x10a>
834: d9 9a sbi 0x1b, 1 ; 27
836: 01 c0 rjmp .+2 ; 0x83a <TM_Search_next+0x10c>
else cbi(DS_PORT, DQ);
838: d9 98 cbi 0x1b, 1 ; 27
83a: 8f 2d mov r24, r15
83c: 8a 95 dec r24
83e: f1 f7 brne .-4 ; 0x83c <TM_Search_next+0x10e>
//TM_Delay(3); /* hold value for remainder of timeslot */
_delay_us(45); //delay 3*15us
sbi(DS_PORT, DQ); /* DQ = 1 */
840: d9 9a sbi 0x1b, 1 ; 27
842: 8a 2f mov r24, r26
844: 8a 95 dec r24
846: f1 f7 brne .-4 ; 0x844 <TM_Search_next+0x116>
848: 4f 5f subi r20, 0xFF ; 255
84a: 5f 4f sbci r21, 0xFF ; 255
return 0;
}
ptr--; /* adjust pointer to satisfy algorithm within loop below */
while ((i++ < 64) && (x < 3)) /* 8 bytes */
84c: 70 34 cpi r23, 0x40 ; 64
84e: 19 f0 breq .+6 ; 0x856 <TM_Search_next+0x128>
850: 33 30 cpi r19, 0x03 ; 3
852: 08 f4 brcc .+2 ; 0x856 <TM_Search_next+0x128>
854: 9a cf rjmp .-204 ; 0x78a <TM_Search_next+0x5c>
*ptr &= ~mask;
TM_Write_bit(tm_rombit);
}
TM_Exit_Critical(); /* reenable interrupts */
856: 0f 90 pop r0
858: 0f be out 0x3f, r0 ; 63
#if DS_DEBUG
hex_dump((char *)&tm_romdta, sizeof(tm_romdta));
#endif
return (x == 3) ? 0 : 1 + (lst_dif == tm_lst0);
85a: 33 30 cpi r19, 0x03 ; 3
85c: 11 f4 brne .+4 ; 0x862 <__stack+0x3>
85e: 80 e0 ldi r24, 0x00 ; 0
860: 07 c0 rjmp .+14 ; 0x870 <__stack+0x11>
862: 80 91 aa 01 lds r24, 0x01AA
866: 18 17 cp r17, r24
868: 11 f0 breq .+4 ; 0x86e <__stack+0xf>
86a: 81 e0 ldi r24, 0x01 ; 1
86c: 01 c0 rjmp .+2 ; 0x870 <__stack+0x11>
86e: 82 e0 ldi r24, 0x02 ; 2
}
870: df 91 pop r29
872: cf 91 pop r28
874: 1f 91 pop r17
876: 0f 91 pop r16
878: ff 90 pop r15
87a: 08 95 ret
#if DS_DEBUG
hex_dump((char *)&tm_romdta, sizeof(tm_romdta));
#endif
return (x == 3) ? 0 : 1 + (lst_dif == tm_lst0);
87c: 21 e0 ldi r18, 0x01 ; 1
87e: cb cf rjmp .-106 ; 0x816 <TM_Search_next+0xe8>
00000880 <TM_Sample_temperature>:
*
* Arguments:
* idx == 0xFF skip ROM and initiate conversion on all devices
*/
void TM_Sample_temperature(u_char idx)
{
880: 1f 93 push r17
882: cf 93 push r28
884: df 93 push r29
u_char *ptr_tmp = &tm_romdta[8*idx];
u_char cnt;
/* Issue command to sample temperature to be prepared for next read */
TM_Enter_Critical(); /* disable interrupts */
886: 0f b6 in r0, 0x3f ; 63
888: f8 94 cli
88a: 0f 92 push r0
*/
static u_char TM_Reset(void)
{
u_char presence;
sbi(DS_DDR, DQ); /* set DQ pin direction - output */
88c: d1 9a sbi 0x1a, 1 ; 26
cbi(DS_PORT, DQ); /* pull DQ line low */
88e: d9 98 cbi 0x1b, 1 ; 27
890: 90 ea ldi r25, 0xA0 ; 160
892: 9a 95 dec r25
894: f1 f7 brne .-4 ; 0x892 <TM_Sample_temperature+0x12>
//TM_Delay(32); /* leave it low for 480us */
_delay_us(480); //delay 480us
/* allow DQ line to return high */
cbi(DS_DDR, DQ); /* set DQ pin direction - input */
896: d1 98 cbi 0x1a, 1 ; 26
898: 94 e1 ldi r25, 0x14 ; 20
89a: 9a 95 dec r25
89c: f1 f7 brne .-4 ; 0x89a <TM_Sample_temperature+0x1a>
// TM_Delay(4); /* wait for presence */
_delay_us(60); //delay 4*15us
/* get presence signal */
if(bit_is_set(DS_PIN, DQ))
89e: 99 b3 in r25, 0x19 ; 25
8a0: 94 e6 ldi r25, 0x64 ; 100
8a2: 9a 95 dec r25
8a4: f1 f7 brne .-4 ; 0x8a2 <TM_Sample_temperature+0x22>
TM_Enter_Critical(); /* disable interrupts */
TM_Reset();
if (idx == 0xFF)
8a6: 8f 3f cpi r24, 0xFF ; 255
8a8: 21 f4 brne .+8 ; 0x8b2 <TM_Sample_temperature+0x32>
TM_Write_byte(0xCC); /* skip ROM */
8aa: 8c ec ldi r24, 0xCC ; 204
8ac: 0e 94 7d 03 call 0x6fa ; 0x6fa <TM_Write_byte>
8b0: 12 c0 rjmp .+36 ; 0x8d6 <TM_Sample_temperature+0x56>
* Arguments:
* idx == 0xFF skip ROM and initiate conversion on all devices
*/
void TM_Sample_temperature(u_char idx)
{
u_char *ptr_tmp = &tm_romdta[8*idx];
8b2: c8 2f mov r28, r24
8b4: d0 e0 ldi r29, 0x00 ; 0
8b6: 93 e0 ldi r25, 0x03 ; 3
8b8: cc 0f add r28, r28
8ba: dd 1f adc r29, r29
8bc: 9a 95 dec r25
8be: e1 f7 brne .-8 ; 0x8b8 <TM_Sample_temperature+0x38>
8c0: ce 57 subi r28, 0x7E ; 126
8c2: de 4f sbci r29, 0xFE ; 254
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -