Esempio n. 1
0
void ow_parasite_disable(void)
{
	OW_DIR_IN();
#if (!OW_USE_INTERNAL_PULLUP)
	OW_OUT_LOW();
#endif
}
Esempio n. 2
0
uint8_t ow_reset(void)
{
	uint8_t err;

	OW_OUT_LOW();
	OW_DIR_OUT();            // pull OW-Pin low for 480us
	_delay_us(480);

	ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
		// set Pin as input - wait for clients to pull low
		OW_DIR_IN(); // input
#if OW_USE_INTERNAL_PULLUP
		OW_OUT_HIGH();
#endif

		_delay_us(64);       // was 66
		err = OW_GET_IN();   // no presence detect
		// if err!=0: nobody pulled to low, still high
	}

	// after a delay the clients should release the line
	// and input-pin gets back to high by pull-up-resistor
	_delay_us(480 - 64);       // was 480-66
	if ( OW_GET_IN() == 0 ) {
		err = 1;             // short circuit, expected low but got high
	}

	return err;
}
Esempio n. 3
0
uint8_t ow_reset(void)
{
	uint8_t err;
	uint8_t sreg;

	OW_OUT_LOW(); // disable internal pull-up (maybe on from parasite)
	OW_DIR_OUT(); // pull OW-Pin low for 480us

	_delay_us(480);

	sreg=SREG;
	cli();

	// set Pin as input - wait for clients to pull low
	OW_DIR_IN(); // input

	_delay_us(66);
	err = OW_GET_IN();		// no presence detect
	// nobody pulled to low, still high

	SREG=sreg; // sei()

	// after a delay the clients should release the line
	// and input-pin gets back to high due to pull-up-resistor
	_delay_us(480-66);
	if( OW_GET_IN() == 0 )		// short circuit
		err = 1;

	return err;
}
Esempio n. 4
0
/*********************************
*RESET
-*********************************/
uint8_t 
ow_reset(void)
{	uint8_t err;
	uint8_t sreg;

	OW_OUT_LOW(); // disable internal pull-up (maybe on from parasite)
	OW_DIR_OUT(); // pull OW-Pin low for 480us
	
	//   delay_us(480);
	usecsleep(2,240);
	//timer1_Delay(480);
	sreg=SREG;
	/*TRY it*///
	CLI();
	/* set Pin as input - wait for clients to pull low*/
	OW_DIR_IN(); /* input*/

	//   delay_us(66);
	usecsleep(2,33);
	//timer1_Delay(480);
	err = OW_GET_IN();		/* no presence detect*/
	/* nobody pulled to low, still high*/
	/*TRY it*///SREG=sreg; /* 
	SEI();

	/* after a delay the clients should release the line
	and input-pin gets back to high due to pull-up-resistor*/
  
	// delay_us(480-66);
	usecsleep(2,207); 
	//timer1_Delay(480-66);
	if( OW_GET_IN() == 0 )/* short circuit*/ err = 1;
	return err;
}
Esempio n. 5
0
/* Timing issue when using runtime-bus-selection (!OW_ONE_BUS):
   The master should sample at the end of the 15-slot after initiating
   the read-time-slot. The variable bus-settings need more
   cycles than the constant ones so the delays had to be shortened 
   to achive a 15uS overall delay 
   Setting/clearing a bit in I/O Register needs 1 cyle in OW_ONE_BUS
   but around 14 cyles in configureable bus (us-Delay is 4 cyles per uS) */
static uint8_t ow_bit_io_intern( uint8_t b, uint8_t with_parasite_enable )
{
	/*ATOMIC_BLOCK(ATOMIC_RESTORESTATE) */{
#if OW_USE_INTERNAL_PULLUP
		OW_OUT_LOW();
#endif
		OW_DIR_OUT();    // drive bus low
		_delay_us(2);    // T_INT > 1usec accoding to timing-diagramm
		if ( b ) {
			OW_DIR_IN(); // to write "1" release bus, resistor pulls high
#if OW_USE_INTERNAL_PULLUP
			OW_OUT_HIGH();
#endif
		}

		// "Output data from the DS18B20 is valid for 15usec after the falling
		// edge that initiated the read time slot. Therefore, the master must 
		// release the bus and then sample the bus state within 15ussec from 
		// the start of the slot."
		_delay_us(15-2-OW_CONF_DELAYOFFSET);
		
		if( OW_GET_IN() == 0 ) {
			b = 0;  // sample at end of read-timeslot
		}
	
		_delay_us(60-15-2+OW_CONF_DELAYOFFSET);
#if OW_USE_INTERNAL_PULLUP
		OW_OUT_HIGH();
#endif
		OW_DIR_IN();
	
		if ( with_parasite_enable ) {
			ow_parasite_enable();
		}
	
	} /* ATOMIC_BLOCK */

	_delay_us(OW_RECOVERY_TIME); // may be increased for longer wires

	return b;
}
Esempio n. 6
0
uint8_t
ow_reset(uint8_t pin)
{
  uint8_t err;
  err = 0;
  /* Pull bus low */
  OW_OUT_LOW(pin); /* disable internal pull-up (can be on from parasite) */
  OW_DIR_OUTPUT(pin); /* pull OW-Pin low for 480us */
  ow_delay_usec(RESET_DELAY); /* Wait for some time */
  /* Release bus */
  OW_DIR_INPUT(pin); /* Set pin as input - wait for clients to pull low. */
  ow_delay_usec(DIR_DELAY);
  /* Sample data */
  err = OW_GET_INPUT(pin); /* no presence detect */
  /* After a delay the clients should release the line
     and input-pin gets back to high due to pull-up-resistor. */
  ow_delay_usec(INPUT_DELAY);
  if (OW_GET_INPUT(pin) == 0) { /* short circuit */
    err = 1;
  }
  return err;
}
Esempio n. 7
0
void ow_parasite_disable(void)
{
    OW_OUT_LOW();
	OW_DIR_IN();
}