示例#1
0
uint8_t DS18X20_copy_scratchpad( uint8_t with_power_extern,
	uint8_t id[] )
{
	ow_reset(); //**
	if( ow_input_pin_state() ) { // only send if bus is "idle" = high
		ow_command( DS18X20_COPY_SCRATCHPAD, id );
		if (with_power_extern != DS18X20_POWER_EXTERN)
			ow_parasite_enable();
		_delay_ms(10); // wait for 10 ms
		if (with_power_extern != DS18X20_POWER_EXTERN)
			ow_parasite_disable();
		return DS18X20_OK;
	}
	else {

		return DS18X20_START_FAIL;
	}
}
示例#2
0
uint8_t DS18X20_copy_scratchpad(uint8_t with_power_extern,
                                uint8_t id[])
{
	ow_reset(); //**
	if (ow_input_pin_state()) {  // only send if bus is "idle" = high
		ow_command(DS18X20_COPY_SCRATCHPAD, id);
		if (with_power_extern != DS18X20_POWER_EXTERN)
			ow_parasite_enable();
		_delay_ms(DS18X20_COPYSP_DELAY); // wait for 10 ms
		if (with_power_extern != DS18X20_POWER_EXTERN)
			ow_parasite_disable();
		return DS18X20_OK;
	} else {
#ifdef DS18X20_VERBOSE
		printf_P(PSTR("DS18X20_copy_scratchpad: Short Circuit !\r"));
#endif
		return DS18X20_START_FAIL;
	}
}