Changeset - e26676bc539c
[Not reviewed]
default
0 1 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2012-11-28 11:58:22
kripperger@CL-SEC241-09.cedarville.edu
Optimization (temp sense)
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/sensors.c
Show inline comments
 
@@ -30,18 +30,17 @@ int16_t readSpiTemp()
 
	_delay_us(100);
 
	uint8_t three = send_spi(0xFF);
 
	_delay_us(100);
 
	uint8_t four = send_spi(0xFF);
 
	DESELECT_TEMP;
 
	
 
	uint8_t error = (two & 0x01);
 
	int16_t temperature = ((one<<4)|(two>>4));
 
	temperature = (temperature & (0x0800)) ? (temperature & 0xF000) : temperature;	// Sign extend
 
	
 
	temperature = error ? 0x00DE : temperature;	// Error Condition. If error is detected output is set to 222 degrees (0x00DE)
 
	temperature = (two & 0x01) ? 0x00DE : temperature;	// Error Condition. If error is detected output is set to 222 degrees (0x00DE)
 
	
 
	
 
			sprintf(buff, "Temperature: %d     Error: %u\r\n", temperature,error);		//DEBUG/////////////////////////////
 
			sprintf(buff, "Temperature: %d     Error: %u\r\n", temperature,(two & 0x01));		//DEBUG/////////////////////////////
 
			serial0_sendString(buff);													//DEBUG/////////////////////////////
 
	
 
	return temperature;
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)