コード例 #1
0
unsigned char ds_present(){

	//ds_pin_get();
   // give the device time to get back to the 'rest' state
   ds_pin_set( 1 );
   delay( 2000 );

   // test for stuck-at-0
   if( ! ds_pin_get() ){ 
   uart_put_string("\ntest stuck at 0");
	return 0; 
   }
   
   // request a presence pulse
   ds_pin_pulse( 1000 );   
   
   // test for the presence pulse 
   delay( 30 );
   if( ds_pin_get() ){ 
	uart_put_string("\npresent pulse");
	return 0; 
   }
   
   // test whether the presence pulse ends
   delay( 1000 );
   if( ! ds_pin_get() ){
	   uart_put_string("\npresence pulse doesn't end.");
	   return 0; 
		
	}
   
   // all tests succeeded
   return 1;   
}
コード例 #2
0
unsigned char ds_receive_bit( void ){
   unsigned char x;
   ds_pin_set(0);
    
    
   x = ds_pin_get();
   delay( 100 );
   return x;
}
コード例 #3
0
ファイル: main.c プロジェクト: Daan1992/bmptk
unsigned char ds_present(){

   // give the device time to get back to the 'rest' state
   ds_pin_set( 1 );
   delay( 2000 );
   
   // test for stuck-at-0
   if( ! ds_pin_get() ){ return 0; }
   
   // request a presence pulse
   ds_pin_pulse( 1000 );   
   
   // test for the presence pulse 
   delay( 30 );
   if( ds_pin_get() ){ return 0; }
   
   // test whether the presence pulse ends
   delay( 1000 );
   if( ! ds_pin_get() ){ return 0; }
   
   // all tests succeeded
   return 1;   
}
コード例 #4
0
void ds_pin_pulse( unsigned long long int t ){
   ds_pin_set( 0 );
   delay( t );
   ds_pin_set( 1 );
}