
	#include <system\soft\delayer\$chip$.txt>
	
	//ȡ
	public uint32 read()
	{
		#asm "cli"
		
		//18MS
		DS_OUT = 0;
		loop( 10 ) {
			delay_n_10us( 180 );
		}
		
		//20-40us
		DS_OUT = 1;
		delay_n_10us( 3 );
		
		DS_DIR = 0;
		
		//ȴ80us͵ƽӦ
		while( DS_IN == 1 ) {}
		while( DS_IN == 0 ) {}
		
		//80us׼
		while( DS_IN == 1 ) {}
		
		uint32 d;
		d.24(uint8) = get_byte();
		d.16(uint8) = get_byte();
		d.8(uint8) = get_byte();
		d.0(uint8) = get_byte();
		uint8 sum = get_byte();
		
		#asm "sei"
		
		DS_DIR = 1;
		
		return d;
		
		
	}
	//---------------------------------------------------
	//һֽ
	uint8 get_byte()
	{
		uint8 d;
		loop( 8 ) {
			while( DS_IN == 0 ) {}
			delay_n_10us( 5 );
			d << 1;
			d.0(bit) = DS_IN;
			while( DS_IN == 1 ) {}
		}
		return d;
	}
	
	
	