Hello world code for PCT2075 and LM75B component class library. The PCT2075 is a temperature-to-digital converter featuring +/-1 degree-C accuracy over -25 degree-C to +100 degree-C range. It uses an on-chip band gap temperature sensor and Sigma-Delta A-to-D conversion technique with an overtemperature detection output that is a drop-in replacement for other LM75 series thermal sensors.
Diff: PCT2075/base_class/I2CTempSensor.cpp
- Revision:
- 2:edd678dcf504
- Parent:
- 1:5398b0799e20
--- a/PCT2075/base_class/I2CTempSensor.cpp Fri Feb 27 12:35:30 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#include "I2CTempSensor.h"
-
-I2CTempSensor::I2CTempSensor( PinName i2c_sda, PinName i2c_scl, char address )
- : i2c_p( new I2C( i2c_sda, i2c_scl ) ), i2c( *i2c_p ), adr( address )
-{
- init();
-}
-
-I2CTempSensor::I2CTempSensor( I2C &i2c_obj, char address )
- : i2c_p( NULL ), i2c( i2c_obj ), adr( address )
-{
- init();
-}
-
-I2CTempSensor::~I2CTempSensor()
-{
- if ( NULL != i2c_p )
- delete i2c_p;
-}
-
-void I2CTempSensor::init( void )
-{
- char command[ 2 ];
-
- command[ 0 ] = LM75B_Conf;
- command[ 1 ] = 0x00;
-
- i2c.write( adr, command, 2 );
-}
-
-short I2CTempSensor::read16( void )
-{
- char command[ 2 ];
-
- command[ 0 ] = LM75B_Temp;
-
- i2c.write( adr, command, 1 ); // Send command string
- i2c.read( adr, command, 2 ); // read two bytes data
-
- return ( (command[ 0 ] << 8)| command[1] );
-}