
	#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;
	}
	
	
	