| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- 1 ; C Compiler for STM8 (COSMIC Software)
- 2 ; Parser V4.8.32 - 23 Mar 2010
- 3 ; Generator V4.3.4 - 23 Mar 2010
- 2483 ; 49 void DS18B20_Init(void)
- 2483 ; 50 {
- 2485 switch .text
- 2486 0000 _DS18B20_Init:
- 2490 ; 51 DS18B20_DQ_OUT;
- 2492 0000 721c5011 bset _B20_OUT_DDR
- 2493 ; 52 DS18B20_DQ_PUSH_PULL;
- 2495 0004 721c5012 bset _B20_OUT_CR1
- 2496 ; 53 DS18B20_DQ_HIGH;
- 2498 0008 721c500f bset _B20_OUT_ODR
- 2499 ; 54 _delay_us(10);
- 2501 000c ae000a ldw x,#10
- 2502 000f cd0000 call __delay_us
- 2504 ; 55 DS18B20_DQ_LOW;
- 2506 0012 721d500f bres _B20_OUT_ODR
- 2507 ; 56 _delay_us(600); //¸´Î»Âö³å
- 2509 0016 ae0258 ldw x,#600
- 2510 0019 cd0000 call __delay_us
- 2512 ; 58 DS18B20_DQ_IN;
- 2514 001c 721d5011 bres _B20_OUT_DDR
- 2515 ; 59 DS18B20_DQ_PULL_UP;
- 2517 0020 721c5012 bset _B20_OUT_CR1
- 2518 ; 60 _delay_us(100);
- 2520 0024 ae0064 ldw x,#100
- 2521 0027 cd0000 call __delay_us
- 2523 ; 63 _delay_us(400);
- 2525 002a ae0190 ldw x,#400
- 2526 002d cd0000 call __delay_us
- 2528 ; 64 }
- 2531 0030 81 ret
- 2577 ; 66 void DS18B20_WriteByte(unsigned char _data)
- 2577 ; 67 {
- 2578 switch .text
- 2579 0031 _DS18B20_WriteByte:
- 2581 0031 88 push a
- 2582 0032 88 push a
- 2583 00000001 OFST: set 1
- 2586 ; 68 unsigned char i = 0;
- 2588 ; 70 DS18B20_DQ_OUT;
- 2590 0033 721c5011 bset _B20_OUT_DDR
- 2591 ; 71 for (i = 0; i < 8; i++)
- 2593 0037 0f01 clr (OFST+0,sp)
- 2594 0039 L3261:
- 2595 ; 73 DS18B20_DQ_LOW;
- 2597 0039 721d500f bres _B20_OUT_ODR
- 2598 ; 74 _delay_us(2);
- 2600 003d ae0002 ldw x,#2
- 2601 0040 cd0000 call __delay_us
- 2603 ; 75 if (_data & 0x01)
- 2605 0043 7b02 ld a,(OFST+1,sp)
- 2606 0045 a501 bcp a,#1
- 2607 0047 2704 jreq L1361
- 2608 ; 77 DS18B20_DQ_HIGH;
- 2610 0049 721c500f bset _B20_OUT_ODR
- 2611 004d L1361:
- 2612 ; 79 _data >>= 1;
- 2614 004d 0402 srl (OFST+1,sp)
- 2615 ; 80 _delay_us(60);
- 2617 004f ae003c ldw x,#60
- 2618 0052 cd0000 call __delay_us
- 2620 ; 81 DS18B20_DQ_HIGH;
- 2622 0055 721c500f bset _B20_OUT_ODR
- 2623 ; 71 for (i = 0; i < 8; i++)
- 2625 0059 0c01 inc (OFST+0,sp)
- 2628 005b 7b01 ld a,(OFST+0,sp)
- 2629 005d a108 cp a,#8
- 2630 005f 25d8 jrult L3261
- 2631 ; 83 }
- 2634 0061 85 popw x
- 2635 0062 81 ret
- 2682 ; 85 unsigned char DS18B20_ReadByte(void)
- 2682 ; 86 {
- 2683 switch .text
- 2684 0063 _DS18B20_ReadByte:
- 2686 0063 89 pushw x
- 2687 00000002 OFST: set 2
- 2690 ; 87 unsigned char i = 0, _data = 0;
- 2694 0064 0f02 clr (OFST+0,sp)
- 2695 ; 89 for (i = 0; i < 8; i++)
- 2697 0066 0f01 clr (OFST-1,sp)
- 2698 0068 L5561:
- 2699 ; 91 DS18B20_DQ_OUT;
- 2701 0068 721c5011 bset _B20_OUT_DDR
- 2702 ; 92 DS18B20_DQ_LOW;
- 2704 006c 721d500f bres _B20_OUT_ODR
- 2705 ; 93 _delay_us(5);
- 2707 0070 ae0005 ldw x,#5
- 2708 0073 cd0000 call __delay_us
- 2710 ; 94 _data >>= 1;
- 2712 0076 0402 srl (OFST+0,sp)
- 2713 ; 95 DS18B20_DQ_HIGH;
- 2715 0078 721c500f bset _B20_OUT_ODR
- 2716 ; 96 DS18B20_DQ_IN;
- 2718 007c 721d5011 bres _B20_OUT_DDR
- 2719 ; 97 if (DS18B20_DQ_VALUE)
- 2721 btst _B20_IN_IDR
- 2722 0085 2406 jruge L3661
- 2723 ; 99 _data |= 0x80;
- 2725 0087 7b02 ld a,(OFST+0,sp)
- 2726 0089 aa80 or a,#128
- 2727 008b 6b02 ld (OFST+0,sp),a
- 2728 008d L3661:
- 2729 ; 101 DS18B20_DQ_OUT;
- 2731 008d 721c5011 bset _B20_OUT_DDR
- 2732 ; 102 DS18B20_DQ_HIGH;
- 2734 0091 721c500f bset _B20_OUT_ODR
- 2735 ; 103 _delay_us(60);
- 2737 0095 ae003c ldw x,#60
- 2738 0098 cd0000 call __delay_us
- 2740 ; 89 for (i = 0; i < 8; i++)
- 2742 009b 0c01 inc (OFST-1,sp)
- 2745 009d 7b01 ld a,(OFST-1,sp)
- 2746 009f a108 cp a,#8
- 2747 00a1 25c5 jrult L5561
- 2748 ; 106 return _data;
- 2750 00a3 7b02 ld a,(OFST+0,sp)
- 2753 00a5 85 popw x
- 2754 00a6 81 ret
- 2801 ; 109 float DS18B20_ReadTemperature(void)
- 2801 ; 110 {
- 2802 switch .text
- 2803 00a7 _DS18B20_ReadTemperature:
- 2805 00a7 5209 subw sp,#9
- 2806 00000009 OFST: set 9
- 2809 ; 111 unsigned char temp = 0;
- 2811 ; 112 float t = 0;
- 2813 ; 114 DS18B20_Init();
- 2815 00a9 cd0000 call _DS18B20_Init
- 2817 ; 115 DS18B20_WriteByte(0xcc);
- 2819 00ac a6cc ld a,#204
- 2820 00ae ad81 call _DS18B20_WriteByte
- 2822 ; 116 DS18B20_WriteByte(0x44);
- 2824 00b0 a644 ld a,#68
- 2825 00b2 cd0031 call _DS18B20_WriteByte
- 2827 ; 118 DS18B20_Init();
- 2829 00b5 cd0000 call _DS18B20_Init
- 2831 ; 119 DS18B20_WriteByte(0xcc);
- 2833 00b8 a6cc ld a,#204
- 2834 00ba cd0031 call _DS18B20_WriteByte
- 2836 ; 120 DS18B20_WriteByte(0xbe);
- 2838 00bd a6be ld a,#190
- 2839 00bf cd0031 call _DS18B20_WriteByte
- 2841 ; 122 temp = DS18B20_ReadByte();
- 2843 00c2 ad9f call _DS18B20_ReadByte
- 2845 00c4 6b09 ld (OFST+0,sp),a
- 2846 ; 123 t = (((temp & 0xf0) >> 4) + (temp & 0x07) * 0.125);
- 2848 00c6 7b09 ld a,(OFST+0,sp)
- 2849 00c8 a407 and a,#7
- 2850 00ca 5f clrw x
- 2851 00cb 97 ld xl,a
- 2852 00cc cd0000 call c_itof
- 2854 00cf ae0000 ldw x,#L3171
- 2855 00d2 cd0000 call c_fmul
- 2857 00d5 96 ldw x,sp
- 2858 00d6 1c0001 addw x,#OFST-8
- 2859 00d9 cd0000 call c_rtol
- 2861 00dc 7b09 ld a,(OFST+0,sp)
- 2862 00de a4f0 and a,#240
- 2863 00e0 4e swap a
- 2864 00e1 a40f and a,#15
- 2865 00e3 5f clrw x
- 2866 00e4 02 rlwa x,a
- 2867 00e5 cd0000 call c_itof
- 2869 00e8 96 ldw x,sp
- 2870 00e9 1c0001 addw x,#OFST-8
- 2871 00ec cd0000 call c_fadd
- 2873 00ef 96 ldw x,sp
- 2874 00f0 1c0005 addw x,#OFST-4
- 2875 00f3 cd0000 call c_rtol
- 2877 ; 124 temp = DS18B20_ReadByte();
- 2879 00f6 cd0063 call _DS18B20_ReadByte
- 2881 00f9 6b09 ld (OFST+0,sp),a
- 2882 ; 125 t += ((temp & 0x0f) << 4);
- 2884 00fb 7b09 ld a,(OFST+0,sp)
- 2885 00fd a40f and a,#15
- 2886 00ff 97 ld xl,a
- 2887 0100 a610 ld a,#16
- 2888 0102 42 mul x,a
- 2889 0103 cd0000 call c_itof
- 2891 0106 96 ldw x,sp
- 2892 0107 1c0005 addw x,#OFST-4
- 2893 010a cd0000 call c_fgadd
- 2895 ; 127 return t;
- 2897 010d 96 ldw x,sp
- 2898 010e 1c0005 addw x,#OFST-4
- 2899 0111 cd0000 call c_ltor
- 2903 0114 5b09 addw sp,#9
- 2904 0116 81 ret
- 2969 xdef _DS18B20_ReadByte
- 2970 xdef _DS18B20_WriteByte
- 2971 xdef _DS18B20_Init
- 2972 xdef _DS18B20_ReadTemperature
- 2973 xref __delay_us
- 2974 .const: section .text
- 2975 0000 L3171:
- 2976 0000 3e000000 dc.w 15872,0
- 2977 xref.b c_x
- 2997 xref c_ltor
- 2998 xref c_fgadd
- 2999 xref c_fadd
- 3000 xref c_rtol
- 3001 xref c_fmul
- 3002 xref c_itof
- 3003 end
|