⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thermometer.lss

📁 ds18b20 thermometer with lcd, ds18b20 thermometer with lcd, ds18b20 thermometer with lcd
💻 LSS
📖 第 1 页 / 共 5 页
字号:
     5e8:	90 e0       	ldi	r25, 0x00	; 0
     5ea:	0e 94 54 02 	call	0x4a8	; 0x4a8 <lcd_str>
}
     5ee:	08 95       	ret

000005f0 <InitSystem>:
#include "ds182x.h"
#include "lcd.h"
#include "1-wire.h"

void InitSystem(void)
{
     5f0:	0e 94 b4 02 	call	0x568	; 0x568 <lcd_init>
	lcd_init();
	lcd_contrast(0x4F); //F - the highest constras
     5f4:	8f e4       	ldi	r24, 0x4F	; 79
     5f6:	0e 94 a3 02 	call	0x546	; 0x546 <lcd_contrast>
}
     5fa:	08 95       	ret

000005fc <TM_Convert_temperature>:
 *			0x10 - DS18S20 - software compatible with the DS1820.
 *	        0x22 - DS1822
 *	        0x28 - DS18B20 - software compatible with the DS1822.
 */
void TM_Convert_temperature(u_char idx, u_int *temp, u_int *frac)
{
     5fc:	cf 93       	push	r28
     5fe:	df 93       	push	r29
     600:	db 01       	movw	r26, r22
     602:	ea 01       	movw	r28, r20
	switch(tm_romdta[8*idx])
     604:	e8 2f       	mov	r30, r24
     606:	f0 e0       	ldi	r31, 0x00	; 0
     608:	43 e0       	ldi	r20, 0x03	; 3
     60a:	ee 0f       	add	r30, r30
     60c:	ff 1f       	adc	r31, r31
     60e:	4a 95       	dec	r20
     610:	e1 f7       	brne	.-8      	; 0x60a <TM_Convert_temperature+0xe>
     612:	ee 57       	subi	r30, 0x7E	; 126
     614:	fe 4f       	sbci	r31, 0xFE	; 254
     616:	e0 81       	ld	r30, Z
     618:	e2 32       	cpi	r30, 0x22	; 34
     61a:	a9 f0       	breq	.+42     	; 0x646 <TM_Convert_temperature+0x4a>
     61c:	e8 32       	cpi	r30, 0x28	; 40
     61e:	99 f0       	breq	.+38     	; 0x646 <TM_Convert_temperature+0x4a>
     620:	e0 31       	cpi	r30, 0x10	; 16
     622:	09 f0       	breq	.+2      	; 0x626 <TM_Convert_temperature+0x2a>
     624:	41 c0       	rjmp	.+130    	; 0x6a8 <TM_Convert_temperature+0xac>
	{ case 0x10: if(*temp & 0x01) *frac = 5000; /* 4 decimal char. precision */
     626:	8c 91       	ld	r24, X
     628:	80 ff       	sbrs	r24, 0
     62a:	05 c0       	rjmp	.+10     	; 0x636 <TM_Convert_temperature+0x3a>
     62c:	88 e8       	ldi	r24, 0x88	; 136
     62e:	93 e1       	ldi	r25, 0x13	; 19
     630:	99 83       	std	Y+1, r25	; 0x01
     632:	88 83       	st	Y, r24
     634:	02 c0       	rjmp	.+4      	; 0x63a <TM_Convert_temperature+0x3e>
	             else *frac = 0;
     636:	19 82       	std	Y+1, r1	; 0x01
     638:	18 82       	st	Y, r1

				 *temp >>= 1;
     63a:	8d 91       	ld	r24, X+
     63c:	9c 91       	ld	r25, X
     63e:	11 97       	sbiw	r26, 0x01	; 1
     640:	96 95       	lsr	r25
     642:	87 95       	ror	r24
     644:	2d c0       	rjmp	.+90     	; 0x6a0 <TM_Convert_temperature+0xa4>
                 break;

	  case 0x22:
	  case 0x28: *frac = ((*temp & (1 << 3)) ? 10000/(1 << 1) : 0) +
     646:	2c 91       	ld	r18, X
     648:	23 fd       	sbrc	r18, 3
     64a:	03 c0       	rjmp	.+6      	; 0x652 <TM_Convert_temperature+0x56>
     64c:	60 e0       	ldi	r22, 0x00	; 0
     64e:	70 e0       	ldi	r23, 0x00	; 0
     650:	02 c0       	rjmp	.+4      	; 0x656 <TM_Convert_temperature+0x5a>
     652:	68 e8       	ldi	r22, 0x88	; 136
     654:	73 e1       	ldi	r23, 0x13	; 19
     656:	22 fd       	sbrc	r18, 2
     658:	03 c0       	rjmp	.+6      	; 0x660 <TM_Convert_temperature+0x64>
     65a:	80 e0       	ldi	r24, 0x00	; 0
     65c:	90 e0       	ldi	r25, 0x00	; 0
     65e:	02 c0       	rjmp	.+4      	; 0x664 <TM_Convert_temperature+0x68>
     660:	84 ec       	ldi	r24, 0xC4	; 196
     662:	99 e0       	ldi	r25, 0x09	; 9
     664:	21 fd       	sbrc	r18, 1
     666:	03 c0       	rjmp	.+6      	; 0x66e <TM_Convert_temperature+0x72>
     668:	40 e0       	ldi	r20, 0x00	; 0
     66a:	50 e0       	ldi	r21, 0x00	; 0
     66c:	02 c0       	rjmp	.+4      	; 0x672 <TM_Convert_temperature+0x76>
     66e:	42 ee       	ldi	r20, 0xE2	; 226
     670:	54 e0       	ldi	r21, 0x04	; 4
     672:	20 fd       	sbrc	r18, 0
     674:	03 c0       	rjmp	.+6      	; 0x67c <TM_Convert_temperature+0x80>
     676:	20 e0       	ldi	r18, 0x00	; 0
     678:	30 e0       	ldi	r19, 0x00	; 0
     67a:	02 c0       	rjmp	.+4      	; 0x680 <TM_Convert_temperature+0x84>
     67c:	21 e7       	ldi	r18, 0x71	; 113
     67e:	32 e0       	ldi	r19, 0x02	; 2
     680:	86 0f       	add	r24, r22
     682:	97 1f       	adc	r25, r23
     684:	84 0f       	add	r24, r20
     686:	95 1f       	adc	r25, r21
     688:	82 0f       	add	r24, r18
     68a:	93 1f       	adc	r25, r19
     68c:	99 83       	std	Y+1, r25	; 0x01
     68e:	88 83       	st	Y, r24
                         ((*temp & (1 << 2)) ? 10000/(1 << 2) : 0) +
                         ((*temp & (1 << 1)) ? 10000/(1 << 3) : 0) +
                         ((*temp & (1 << 0)) ? 10000/(1 << 4) : 0);

                 *temp >>= 4;
     690:	8d 91       	ld	r24, X+
     692:	9c 91       	ld	r25, X
     694:	11 97       	sbiw	r26, 0x01	; 1
     696:	24 e0       	ldi	r18, 0x04	; 4
     698:	96 95       	lsr	r25
     69a:	87 95       	ror	r24
     69c:	2a 95       	dec	r18
     69e:	e1 f7       	brne	.-8      	; 0x698 <TM_Convert_temperature+0x9c>
     6a0:	11 96       	adiw	r26, 0x01	; 1
     6a2:	9c 93       	st	X, r25
     6a4:	8e 93       	st	-X, r24
     6a6:	07 c0       	rjmp	.+14     	; 0x6b6 <TM_Convert_temperature+0xba>
				 break;
      default:
#if DS_DEBUG
                 printf_P(PSTR("\n\rUnknown family code - %02X.\n\r"), tm_romdta[8*idx]);
#endif
				 *temp = 85;
     6a8:	85 e5       	ldi	r24, 0x55	; 85
     6aa:	90 e0       	ldi	r25, 0x00	; 0
     6ac:	11 96       	adiw	r26, 0x01	; 1
     6ae:	9c 93       	st	X, r25
     6b0:	8e 93       	st	-X, r24
				 *frac = 0;
     6b2:	19 82       	std	Y+1, r1	; 0x01
     6b4:	18 82       	st	Y, r1
				 break;
	}

    if(*temp & 0x80)		/* check the sign bit */
     6b6:	8d 91       	ld	r24, X+
     6b8:	9c 91       	ld	r25, X
     6ba:	11 97       	sbiw	r26, 0x01	; 1
     6bc:	87 ff       	sbrs	r24, 7
     6be:	05 c0       	rjmp	.+10     	; 0x6ca <TM_Convert_temperature+0xce>
    { *temp &= 0x007F;		/* clear sign bits */
      *temp |= 0x8000;		/* set sign bit */
     6c0:	8f 77       	andi	r24, 0x7F	; 127
     6c2:	90 70       	andi	r25, 0x00	; 0
     6c4:	90 68       	ori	r25, 0x80	; 128
     6c6:	8d 93       	st	X+, r24
     6c8:	9c 93       	st	X, r25
    }
}
     6ca:	df 91       	pop	r29
     6cc:	cf 91       	pop	r28
     6ce:	08 95       	ret

000006d0 <TM_Crc>:
/*
 *  TM_Crc - calculate CRC (Cyclic Redundancy Check) for
 *           Dallas Semiconductor Touch Memory.
 */
u_char TM_Crc(u_char crc, u_char inp)
{
     6d0:	98 2f       	mov	r25, r24
     6d2:	26 2f       	mov	r18, r22
     6d4:	38 e0       	ldi	r19, 0x08	; 8
        inp ^= crc;
        crc >>= 1;

        if (inp & 1)
        {
            crc ^= (0x18 >> 1);
     6d6:	4c e0       	ldi	r20, 0x0C	; 12
           i = 8,
           carry;

    do
    {
        inp ^= crc;
     6d8:	86 2f       	mov	r24, r22
     6da:	89 27       	eor	r24, r25
        crc >>= 1;
     6dc:	96 95       	lsr	r25

        if (inp & 1)
     6de:	80 ff       	sbrs	r24, 0
     6e0:	02 c0       	rjmp	.+4      	; 0x6e6 <TM_Crc+0x16>
        {
            crc ^= (0x18 >> 1);
     6e2:	94 27       	eor	r25, r20
            crc |= 0x80;
     6e4:	90 68       	ori	r25, 0x80	; 128
        }

        carry = inp_z & 1;
     6e6:	82 2f       	mov	r24, r18
     6e8:	81 70       	andi	r24, 0x01	; 1
        inp_z >>= 1;
     6ea:	26 95       	lsr	r18

        if (carry)
     6ec:	81 11       	cpse	r24, r1
            inp_z |= 0x80;
     6ee:	20 68       	ori	r18, 0x80	; 128
        inp = inp_z;

    } while (--i);
     6f0:	31 50       	subi	r19, 0x01	; 1
     6f2:	62 2f       	mov	r22, r18
     6f4:	89 f7       	brne	.-30     	; 0x6d8 <TM_Crc+0x8>

    return crc;
}
     6f6:	89 2f       	mov	r24, r25
     6f8:	08 95       	ret

000006fa <TM_Write_byte>:

/*
 *  TM_WRITE_BYTE - writes a byte to the one-wire bus.
 */
static void TM_Write_byte(u_char val)
{
     6fa:	28 e0       	ldi	r18, 0x08	; 8
    can be achieved.
*/
void
_delay_loop_1(uint8_t __count)
{
	__asm__ volatile (
     6fc:	51 e0       	ldi	r21, 0x01	; 1
/*
 *  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 */
     6fe:	4f e0       	ldi	r20, 0x0F	; 15
     700:	35 e0       	ldi	r19, 0x05	; 5
     702:	d1 9a       	sbi	0x1a, 1	; 26
    cbi(DS_PORT, DQ);       /* pull DQ low to start timeslot */
     704:	d9 98       	cbi	0x1b, 1	; 27
     706:	95 2f       	mov	r25, r21
     708:	9a 95       	dec	r25
     70a:	f1 f7       	brne	.-4      	; 0x708 <TM_Write_byte+0xe>
//     _NOP();                /* wait 68 ns */
//COMPRESS_REENABLE;

	_delay_us(0.2); //delay 200ns
	 
    if( bitval ) sbi(DS_PORT, DQ); /* set DQ */
     70c:	80 ff       	sbrs	r24, 0
     70e:	02 c0       	rjmp	.+4      	; 0x714 <TM_Write_byte+0x1a>
     710:	d9 9a       	sbi	0x1b, 1	; 27
     712:	01 c0       	rjmp	.+2      	; 0x716 <TM_Write_byte+0x1c>
    else cbi(DS_PORT, DQ);
     714:	d9 98       	cbi	0x1b, 1	; 27
     716:	94 2f       	mov	r25, r20
     718:	9a 95       	dec	r25
     71a:	f1 f7       	brne	.-4      	; 0x718 <TM_Write_byte+0x1e>

    //TM_Delay(3);            /* hold value for remainder of timeslot */
	_delay_us(45); //delay 3*15us

    sbi(DS_PORT, DQ);       /* DQ = 1 */
     71c:	d9 9a       	sbi	0x1b, 1	; 27
     71e:	93 2f       	mov	r25, r19
     720:	9a 95       	dec	r25
     722:	f1 f7       	brne	.-4      	; 0x720 <TM_Write_byte+0x26>

    do
    {
      TM_Write_bit ((val & 1));
      val >>= 1;
    } while (--cnt);
     724:	21 50       	subi	r18, 0x01	; 1
     726:	11 f0       	breq	.+4      	; 0x72c <TM_Write_byte+0x32>
    u_char cnt = 8;

    do
    {
      TM_Write_bit ((val & 1));
      val >>= 1;
     728:	86 95       	lsr	r24
     72a:	eb cf       	rjmp	.-42     	; 0x702 <TM_Write_byte+0x8>
     72c:	08 95       	ret

0000072e <TM_Search_next>:
 *  TM_Search_next()
 *
 *    Search for a single device.
 */
u_char TM_Search_next(u_char *ptr)
{
     72e:	ff 92       	push	r15
     730:	0f 93       	push	r16
     732:	1f 93       	push	r17
     734:	cf 93       	push	r28
     736:	df 93       	push	r29
     738:	ec 01       	movw	r28, r24
    u_char  i = 0, x = 0, lst_dif = tm_lst0;
     73a:	10 91 aa 01 	lds	r17, 0x01AA
    u_char  mask = 0x01;
    u_char  tm_rombit;

    TM_Enter_Critical();    /* disable interrupts */
     73e:	0f b6       	in	r0, 0x3f	; 63
     740:	f8 94       	cli
     742:	0f 92       	push	r0
 */
static u_char TM_Reset(void)
{
    u_char presence;

    sbi(DS_DDR, DQ);        /* set DQ pin direction - output */
     744:	d1 9a       	sbi	0x1a, 1	; 26

    cbi(DS_PORT, DQ);       /* pull DQ line low */
     746:	d9 98       	cbi	0x1b, 1	; 27
     748:	80 ea       	ldi	r24, 0xA0	; 160
     74a:	8a 95       	dec	r24
     74c:	f1 f7       	brne	.-4      	; 0x74a <TM_Search_next+0x1c>

    //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 */
     74e:	d1 98       	cbi	0x1a, 1	; 26
     750:	84 e1       	ldi	r24, 0x14	; 20
     752:	8a 95       	dec	r24
     754:	f1 f7       	brne	.-4      	; 0x752 <TM_Search_next+0x24>
   // TM_Delay(4);            /* wait for presence */
   _delay_us(60); //delay 4*15us

                            /* get presence signal */

   if(bit_is_set(DS_PIN, DQ))
     756:	89 b3       	in	r24, 0x19	; 25
     758:	94 e6       	ldi	r25, 0x64	; 100
     75a:	9a 95       	dec	r25
     75c:	f1 f7       	brne	.-4      	; 0x75a <TM_Search_next+0x2c>
    u_char  mask = 0x01;
    u_char  tm_rombit;

    TM_Enter_Critical();    /* disable interrupts */

    if (!TM_Reset())
     75e:	81 fd       	sbrc	r24, 1
     760:	11 c0       	rjmp	.+34     	; 0x784 <TM_Search_next+0x56>
        TM_Write_byte(0xF0);
     762:	80 ef       	ldi	r24, 0xF0	; 240
     764:	0e 94 7d 03 	call	0x6fa	; 0x6fa <TM_Write_byte>
    else
     {  TM_Exit_Critical(); /* reenable interrupts */
        return 0;
     }

    ptr--;                          /* adjust pointer to satisfy algorithm within loop below */
     768:	fe 01       	movw	r30, r28
     76a:	31 97       	sbiw	r30, 0x01	; 1
     76c:	61 e0       	ldi	r22, 0x01	; 1
     76e:	70 e0       	ldi	r23, 0x00	; 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -