TI-OpenThread API Documentation  1.03.02.00
Data Structures | Macros | Typedefs | Enumerations | Functions
tmp007.h File Reference

Detailed Description

TMP007 driver.

============================================================================

The TMP007 header file should be included in an application as follows:

#include <tmp007.h>

Operation

The TMP007 driver simplifies using a TMP007 sensor to perform temperature readings. The board's I2C peripheral and pins must be configured and then initialized by using Board_initI2C(). Similarly, any GPIO pins must be configured and then initialized by using Board_initGPIO(). A TMP007_config array should be defined by the application. The TMP007_config array should contain pointers to a defined TMP007_HWAttrs and allocated array for the TMP007_Object structures. TMP007_init() must be called prior to using TMP007_open().

The APIs in this driver serve as an interface to a DPL(Driver Porting Layer) The specific implementations are responsible for creating all the RTOS specific primitives to allow for thread-safe operation.

For accurate operation, calibration may be necessary. Refer to SBOU142.pdf for calibration instructions.

This driver has no dynamic memory allocation.

Defining TMP007_Config, TMP007_Object and TMP007_HWAttrs

Each structure must be defined by the application. The following example is for a MSP432 in which two TMP007 sensors are setup. The following declarations are placed in "MSP_EXP432P401R.h" and "MSP_EXP432P401R.c" respectively. How the gpioIndices are defined are detailed in the next example.

"MSP_EXP432P401R.h"

typedef enum MSP_EXP432P491RLP_TMP007Name {
TMP007_ROOMTEMP = 0, // Sensor measuring room temperature
TMP007_OUTDOORTEMP, // Sensor measuring outside temperature
MSP_EXP432P491RLP_TMP007COUNT
} MSP_EXP432P491RLP_TMP007Name;

"MSP_EXP432P401R.c"

#include <tmp007.h>
TMP007_Object TMP007_object[MSP_EXP432P491RLP_TMP007COUNT];
const TMP007_HWAttrs TMP007_hwAttrs[MSP_EXP432P491RLP_TMP007COUNT] = {
{
.gpioIndex = MSP_EXP432P401R_TMP007_0,
},
{
.slaveAddress = TMP007_SA2, // 0x41
.gpioIndex = MSP_EXP432P401R_TMP007_1,
},
};
{
.hwAttrs = (void *)&TMP007_hwAttrs[0],
.objects = (void *)&TMP007_object[0],
},
{
.hwAttrs = (void *)&TMP007_hwAttrs[1],
.objects = (void *)&TMP007_object[1],
},
{NULL, NULL},
};

Setting up GPIO configurations

The following example is for a MSP432 in which two TMP007 sensors each need a GPIO pin for alarming. The following definitions are in "MSP_EXP432P401R.h" and "MSP_EXP432P401R.c" respectively. This example uses GPIO pins 1.5 and 4.3. The GPIO_CallbackFxn table must contain as many indices as GPIO_CallbackFxns that will be specified by the application. For each ALERT pin used, an index should be allocated as NULL.

"MSP_EXP432P401R.h"

typedef enum MSP_EXP432P401R_GPIOName {
MSP_EXP432P401R_TMP007_0, // ALERT pin for the room temperature
MSP_EXP432P401R_TMP007_1, // ALERT pin for the outdoor temperature
MSP_EXP432P401R_GPIOCOUNT
} MSP_EXP432P401R_GPIOName;

"MSP_EXP432P401R.c"

#include <gpio.h>
GPIO_PinConfig gpioPinConfigs[] = {
GPIOMSP432_P1_5 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_FALLING,
GPIOMSP432_P4_3 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_FALLING
};
GPIO_CallbackFxn gpioCallbackFunctions[] = {
NULL,
NULL
};

Opening a I2C Handle

The I2C controller must be in blocking mode. This will seamlessly allow for multiple I2C endpoints without conflicting callback functions. The I2C_open() call requires a configured index. This index must be defined by the application in accordance to the I2C driver. The default transfer mode for an I2C_Params structure is I2C_MODE_BLOCKING. In the example below, the transfer mode is set explicitly for clarity. Additionally, the TMP007 hardware is capable of communicating at 400kHz. The default bit rate for an I2C_Params structure is I2C_100kHz.

#include <ti/drivers/I2C.h>
I2C_Handle i2cHandle;
I2C_Params i2cParams;
I2C_Params_init(&i2cParams);
i2cParams.transferMode = I2C_MODE_BLOCKING;
i2cParams.bitRate = I2C_400kHz;
i2cHandle = I2C_open(someI2C_configIndexValue, &i2cParams);

Opening a TMP007 sensor with default parameters

The TMP007_open() call must be made in a task context.

#include <tmp007.h>
tmp007Handle = TMP007_open(TMP007_ROOMTEMP, i2cHandle, NULL);

Opening a TMP007 sensor to ALERT

In the following example, a callback function is specified in the tmp007Params structure. This indicates to the module that the ALERT pin will be used. Additionally, a user specific argument is passed in. The sensor will assert the ALERT pin whenever the temperature exceeds 35 (C). The low limit is ignored. No ALERT will be generated until TMP007_enableAlert() is called.

#include <tmp007.h>
TMP007_Params tmp007Params;
tmp007Params.callback = gpioCallbackFxn;
tmp007Handle = TMP007_open(TMP007_ROOMTEMP, i2cHandle, &tmp007Params);
TMP007_enableAlert(tmp007Handle);

Go to the source code of this file.

Data Structures

struct  TMP007_Config
 TMP007 configuration. More...
 
struct  TMP007_HWAttrs
 Hardware specific settings for a TMP007 sensor. More...
 
struct  TMP007_Object
 Members should not be accessed by the application. More...
 
struct  TMP007_Params
 TMP007 Parameters. More...
 

Macros

#define TMP007_A0   0x000B /*! A0 coefficient register */
 
#define TMP007_A1   0x000C /*! A1 coefficient register */
 
#define TMP007_B0   0x000D /*! B0 coefficient register */
 
#define TMP007_B1   0x000E /*! B1 coefficient register */
 
#define TMP007_B2   0x000F /*! B2 coefficient register */
 
#define TMP007_C   0x0010 /*! C coefficient register */
 
#define TMP007_CONFIG   0x0002 /*! Configuration register */
 
#define TMP007_DEVICEID   0x001F /*! Manufacturer ID register */
 
#define TMP007_DIE_HI_LIM   0x0008 /*! DIE Temp High limit register */
 
#define TMP007_DIE_LO_LIM   0x0009 /*! DIE Temp Low limit register */
 
#define TMP007_DIE_TEMP   0x0001 /*! DIE Temp result register */
 
#define TMP007_IGNORE   0xFFFF
 Ignore temperature limit define. More...
 
#define TMP007_MASK_ENABLE   0x0005 /*! Status Mask and Enable Register */
 
#define TMP007_MEMORY   0x002A /*! Memory access register */
 
#define TMP007_OBJ_HI_LIM   0x0006 /*! Object Temp High limit register */
 
#define TMP007_OBJ_LO_LIM   0x0007 /*! Object Temp Low limit register */
 
#define TMP007_OBJ_TEMP   0x0003 /*! Object Temp Result Register */
 
#define TMP007_S0   0x000A /*! S0 coefficient register */
 
#define TMP007_SMER_ALRTEN   0x8000 /*! Alert Flag Enable Bit */
 
#define TMP007_SMER_CRTEN   0x4000 /*! Tem Conversion Ready Enable */
 
#define TMP007_SMER_DVEN   0x0200 /*! Data Invalid Flag Enable Bit */
 
#define TMP007_SMER_LHEN   0x0800 /*! DIE Temp High Limit Enable */
 
#define TMP007_SMER_LLEN   0x0400 /*! DIE Temp Low Limit Enable */
 
#define TMP007_SMER_MEMC_EN   0x0100 /*! Memory Corrupt Enable Bit */
 
#define TMP007_SMER_OHEN   0x2000 /*! Object Temp High Limit Enable */
 
#define TMP007_SMER_OLEN   0x1000 /*! Object Temp Low Limit Enable */
 
#define TMP007_STAT_ALRTF   0x8000 /*! Cumulative Alert Flag */
 
#define TMP007_STAT_CRTF   0x4000 /*! Conversion Ready Flag */
 
#define TMP007_STAT_DOF   0x0080 /*! Data Overflow */
 
#define TMP007_STAT_LHF   0x0800 /*! Local Temp High Limit Flag */
 
#define TMP007_STAT_LLF   0x0400 /*! Local Temp Low Limit Flag */
 
#define TMP007_STAT_MCRPT   0x0100 /*! Memory Corrupt Flag */
 
#define TMP007_STAT_nDVF   0x0200 /*! Data Invalid Flag */
 
#define TMP007_STAT_OHF   0x2000 /*! Object Temp High Limit Flag */
 
#define TMP007_STAT_OLF   0x1000 /*! Object Temp Low Limit Flag */
 
#define TMP007_STATUS   0x0004 /*! Status register */
 
#define TMP007_TC0   0x0011 /*! TC0 coefficient register */
 
#define TMP007_TC1   0x0012 /*! TC1 coefficient register */
 
#define TMP007_VOBJ   0x0000 /*! Sensor voltage result register */
 

Typedefs

typedef struct TMP007_Config TMP007_Config
 TMP007 configuration. More...
 
typedef enum TMP007_Conversions TMP007_Conversions
 TMP007 ADC conversion settings. More...
 
typedef struct TMP007_ConfigTMP007_Handle
 A handle that is returned from a TMP007_open() call. More...
 
typedef struct TMP007_HWAttrs TMP007_HWAttrs
 Hardware specific settings for a TMP007 sensor. More...
 
typedef enum TMP007_IntComp TMP007_IntComp
 TMP007 interrupt/comparator settings. More...
 
typedef struct TMP007_Object TMP007_Object
 Members should not be accessed by the application. More...
 
typedef struct TMP007_Params TMP007_Params
 TMP007 Parameters. More...
 
typedef enum TMP007_SlaveAddress TMP007_SlaveAddress
 TMP007 I2C slave addresses. More...
 
typedef enum TMP007_TempScale TMP007_TempScale
 TMP007 temperature settings. More...
 
typedef enum TMP007_TransientCorrect TMP007_TransientCorrect
 TMP007 Transient Correct settings. More...
 

Enumerations

enum  TMP007_Conversions {
  TMP007_1CONV = 0x0000, TMP007_2CONV = 0x0200, TMP007_4CONV = 0x0400, TMP007_8CONV = 0x0600,
  TMP007_16CONV = 0x0800, TMP007_1CONVLP = 0x0A00, TMP007_2CONVLP = 0x0C00, TMP007_4CONVLP = 0x0E00
}
 TMP007 ADC conversion settings. More...
 
enum  TMP007_IntComp { TMP007_IntMode = 0, TMP007_CompMode = 0x0020 }
 TMP007 interrupt/comparator settings. More...
 
enum  TMP007_SlaveAddress {
  TMP007_SA1 = 0x40, TMP007_SA2 = 0x41, TMP007_SA3 = 0x42, TMP007_SA4 = 0x43,
  TMP007_SA5 = 0x44, TMP007_SA6 = 0x45, TMP007_SA7 = 0x46, TMP007_SA8 = 0x47
}
 TMP007 I2C slave addresses. More...
 
enum  TMP007_TempScale { TMP007_CELSIUS = 0, TMP007_KELVIN = 1, TMP007_FAHREN = 2 }
 TMP007 temperature settings. More...
 
enum  TMP007_TransientCorrect { TMP007_TCDisable = 0, TMP007_TCEnable = 0x0040 }
 TMP007 Transient Correct settings. More...
 

Functions

bool TMP007_close (TMP007_Handle handle)
 Function to close a TMP007 sensor specified by the TMP007 handle. More...
 
bool TMP007_disableAlert (TMP007_Handle handle)
 Function to disable the ALERT pin and GPIO interrupt. More...
 
bool TMP007_disableConversions (TMP007_Handle handle)
 Function to put TMP007 sensor is low power state. More...
 
bool TMP007_enableAlert (TMP007_Handle handle)
 Function to enable the ALERT pin and GPIO interrupt. More...
 
bool TMP007_enableConversions (TMP007_Handle handle)
 Function to restore TMP007 to normal power operation. More...
 
static bool TMP007_getDieTemp (TMP007_Handle handle, TMP007_TempScale scale, float *temp)
 Function to read die temperature. More...
 
static bool TMP007_getDieTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float *high, float *low)
 This function will read the die temperature limits. More...
 
static bool TMP007_getObjTemp (TMP007_Handle handle, TMP007_TempScale scale, float *temp)
 Function to read object temperature. More...
 
static bool TMP007_getObjTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float *high, float *low)
 This function will read the object temperature limits. More...
 
bool TMP007_getTemp (TMP007_Handle, TMP007_TempScale unit, float *data, uint16_t registerAddress)
 
bool TMP007_getTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float *data, uint16_t registerAddress)
 
void TMP007_init ()
 Function to initialize TMP007 driver. More...
 
TMP007_Handle TMP007_open (unsigned int tmp007Index, I2C_Handle i2cHandle, TMP007_Params *params)
 Function to open a given TMP007 sensor. More...
 
void TMP007_Params_init (TMP007_Params *params)
 Function to initialize a TMP007_Params struct to its defaults. More...
 
bool TMP007_readRegister (TMP007_Handle handle, uint16_t *data, uint8_t registerAddress)
 Read function for advanced users. More...
 
static bool TMP007_readStatus (TMP007_Handle handle, uint16_t *data)
 Function to read a TMP007 sensor's status register. More...
 
static bool TMP007_readVoltage (TMP007_Handle handle, int16_t *data)
 Function to read a TMP007 sensor's voltage register. More...
 
static bool TMP007_setDieTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float high, float low)
 This function will set the die temperature limits. More...
 
static bool TMP007_setObjTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float high, float low)
 This function will set the object temperature limits. More...
 
bool TMP007_setTempLimit (TMP007_Handle handle, TMP007_TempScale scale, float data, uint16_t bitMask, uint8_t registerAddress)
 
bool TMP007_writeRegister (TMP007_Handle handle, uint16_t data, uint8_t registerAddress)
 Write function for advanced users. This is not thread safe. More...
 

Macro Definition Documentation

§ TMP007_A0

#define TMP007_A0   0x000B /*! A0 coefficient register */

§ TMP007_A1

#define TMP007_A1   0x000C /*! A1 coefficient register */

§ TMP007_B0

#define TMP007_B0   0x000D /*! B0 coefficient register */

§ TMP007_B1

#define TMP007_B1   0x000E /*! B1 coefficient register */

§ TMP007_B2

#define TMP007_B2   0x000F /*! B2 coefficient register */

§ TMP007_C

#define TMP007_C   0x0010 /*! C coefficient register */

§ TMP007_CONFIG

#define TMP007_CONFIG   0x0002 /*! Configuration register */

§ TMP007_DEVICEID

#define TMP007_DEVICEID   0x001F /*! Manufacturer ID register */

§ TMP007_DIE_HI_LIM

#define TMP007_DIE_HI_LIM   0x0008 /*! DIE Temp High limit register */

§ TMP007_DIE_LO_LIM

#define TMP007_DIE_LO_LIM   0x0009 /*! DIE Temp Low limit register */

§ TMP007_DIE_TEMP

#define TMP007_DIE_TEMP   0x0001 /*! DIE Temp result register */

Referenced by TMP007_getDieTemp().

§ TMP007_IGNORE

#define TMP007_IGNORE   0xFFFF

Ignore temperature limit define.

TMP007_IGNORE should be used to ignore or unset a temperature limit.

In the following example, the object temperature limits are set and reset:

Referenced by TMP007_setTempLimit().

§ TMP007_MASK_ENABLE

#define TMP007_MASK_ENABLE   0x0005 /*! Status Mask and Enable Register */

Referenced by TMP007_setTempLimit().

§ TMP007_MEMORY

#define TMP007_MEMORY   0x002A /*! Memory access register */

§ TMP007_OBJ_HI_LIM

#define TMP007_OBJ_HI_LIM   0x0006 /*! Object Temp High limit register */

§ TMP007_OBJ_LO_LIM

#define TMP007_OBJ_LO_LIM   0x0007 /*! Object Temp Low limit register */

§ TMP007_OBJ_TEMP

#define TMP007_OBJ_TEMP   0x0003 /*! Object Temp Result Register */

Referenced by TMP007_getObjTemp().

§ TMP007_S0

#define TMP007_S0   0x000A /*! S0 coefficient register */

§ TMP007_SMER_ALRTEN

#define TMP007_SMER_ALRTEN   0x8000 /*! Alert Flag Enable Bit */

§ TMP007_SMER_CRTEN

#define TMP007_SMER_CRTEN   0x4000 /*! Tem Conversion Ready Enable */

§ TMP007_SMER_DVEN

#define TMP007_SMER_DVEN   0x0200 /*! Data Invalid Flag Enable Bit */

§ TMP007_SMER_LHEN

#define TMP007_SMER_LHEN   0x0800 /*! DIE Temp High Limit Enable */

Referenced by TMP007_setDieTempLimit().

§ TMP007_SMER_LLEN

#define TMP007_SMER_LLEN   0x0400 /*! DIE Temp Low Limit Enable */

Referenced by TMP007_setDieTempLimit().

§ TMP007_SMER_MEMC_EN

#define TMP007_SMER_MEMC_EN   0x0100 /*! Memory Corrupt Enable Bit */

§ TMP007_SMER_OHEN

#define TMP007_SMER_OHEN   0x2000 /*! Object Temp High Limit Enable */

Referenced by TMP007_setObjTempLimit().

§ TMP007_SMER_OLEN

#define TMP007_SMER_OLEN   0x1000 /*! Object Temp Low Limit Enable */

Referenced by TMP007_setObjTempLimit().

§ TMP007_STAT_ALRTF

#define TMP007_STAT_ALRTF   0x8000 /*! Cumulative Alert Flag */

§ TMP007_STAT_CRTF

#define TMP007_STAT_CRTF   0x4000 /*! Conversion Ready Flag */

§ TMP007_STAT_DOF

#define TMP007_STAT_DOF   0x0080 /*! Data Overflow */

§ TMP007_STAT_LHF

#define TMP007_STAT_LHF   0x0800 /*! Local Temp High Limit Flag */

§ TMP007_STAT_LLF

#define TMP007_STAT_LLF   0x0400 /*! Local Temp Low Limit Flag */

§ TMP007_STAT_MCRPT

#define TMP007_STAT_MCRPT   0x0100 /*! Memory Corrupt Flag */

§ TMP007_STAT_nDVF

#define TMP007_STAT_nDVF   0x0200 /*! Data Invalid Flag */

§ TMP007_STAT_OHF

#define TMP007_STAT_OHF   0x2000 /*! Object Temp High Limit Flag */

§ TMP007_STAT_OLF

#define TMP007_STAT_OLF   0x1000 /*! Object Temp Low Limit Flag */

§ TMP007_STATUS

#define TMP007_STATUS   0x0004 /*! Status register */

Referenced by TMP007_readStatus().

§ TMP007_TC0

#define TMP007_TC0   0x0011 /*! TC0 coefficient register */

§ TMP007_TC1

#define TMP007_TC1   0x0012 /*! TC1 coefficient register */

§ TMP007_VOBJ

#define TMP007_VOBJ   0x0000 /*! Sensor voltage result register */

Referenced by TMP007_readVoltage().

Typedef Documentation

§ TMP007_Config

typedef struct TMP007_Config TMP007_Config

TMP007 configuration.

The TMP007_Config structure contains a set of pointers used to characterize the TMP007 driver implementation.

This structure needs to be defined and provided by the application.

§ TMP007_Conversions

TMP007 ADC conversion settings.

This enumeration defines the number of ADC conversions performed before an average is computed and stored in the hardware registers. More ADC conversions results in a longer overall conversion time and more accurate object temperature reading.

§ TMP007_Handle

typedef struct TMP007_Config* TMP007_Handle

A handle that is returned from a TMP007_open() call.

§ TMP007_HWAttrs

Hardware specific settings for a TMP007 sensor.

This structure should be defined and provided by the application. The gpioIndex should be defined in accordance of the GPIO driver. The pin must be configured as GPIO_CFG_INPUT and GPIO_CFG_IN_INT_FALLING.

§ TMP007_IntComp

TMP007 interrupt/comparator settings.

The INT/COMP bit controls whether the limit flags are in INTERRUPT (INT) mode (0) or COMPARATOR (COMP) Mode (1). It controls the behavior of the limit flags (LH, LL, OH, OL) and the data invalid flag (nDVF) from the status register. In INT mode, the ALERT condition is maintained until the status register has been read. In COMP mode, the ALERT pin is asserted whenever the alert condition occurs, and deasserts without any external intervention when the alert condition is no longer present.

§ TMP007_Object

typedef struct TMP007_Object TMP007_Object

Members should not be accessed by the application.

§ TMP007_Params

typedef struct TMP007_Params TMP007_Params

TMP007 Parameters.

TMP007 parameters are used with the TMP007_open() call. Default values for these parameters are set using TMP007_Params_init(). The GPIO_CallbackFxn should be defined by the application only if the ALERT functionality is desired. A gpioIndex must be defined in the TMP007_HWAttrs for the corresponding tmp007Index. The GPIO_CallbackFxn is in the context of an interrupt handler.

See also
TMP007_Params_init()

§ TMP007_SlaveAddress

TMP007 I2C slave addresses.

The TMP007 Slave Address is determined by the input to the ADR0 and ADR1 input pins of the TMP007 hardware. A '1' indicates a supply voltage of up to 7.5 V while '0' indicates ground. In some cases, the ADR0 pin may be coupled with the SDA or SCL bus to achieve a particular slave address. TMP007 sensors on the same I2C bus cannot share the same slave address.

§ TMP007_TempScale

TMP007 temperature settings.

This enumeration defines the scaling for reading and writing temperature values with a TMP007 sensor.

§ TMP007_TransientCorrect

TMP007 Transient Correct settings.

Setting this bit turns on the transient correction–enabling sensor voltage and object temperature output filtering. This helps reduce error due to changes in the die temperature. As a general guideline, turn on transient correction when the die temperature is changing at a rate greater than 1.5 degrees (C) per minute. Transient correction corrects transients up to approximately 20 degrees (C) per minute.

Enumeration Type Documentation

§ TMP007_Conversions

TMP007 ADC conversion settings.

This enumeration defines the number of ADC conversions performed before an average is computed and stored in the hardware registers. More ADC conversions results in a longer overall conversion time and more accurate object temperature reading.

Enumerator
TMP007_1CONV 

1 average per conversion (0.26 secs)

TMP007_2CONV 

2 averages per conversion (0.51 secs)

TMP007_4CONV 

4 averages per conversion (1.01 secs)

TMP007_8CONV 

8 averages per conversion (2.01 secs)

TMP007_16CONV 

16 averages per conversion (4.01 secs)

TMP007_1CONVLP 

1 low power conversion (1.00 secs)

TMP007_2CONVLP 

2 low power conversions (4.00 secs)

TMP007_4CONVLP 

4 low power conversions (4.00 secs)

§ TMP007_IntComp

TMP007 interrupt/comparator settings.

The INT/COMP bit controls whether the limit flags are in INTERRUPT (INT) mode (0) or COMPARATOR (COMP) Mode (1). It controls the behavior of the limit flags (LH, LL, OH, OL) and the data invalid flag (nDVF) from the status register. In INT mode, the ALERT condition is maintained until the status register has been read. In COMP mode, the ALERT pin is asserted whenever the alert condition occurs, and deasserts without any external intervention when the alert condition is no longer present.

Enumerator
TMP007_IntMode 
TMP007_CompMode 

§ TMP007_SlaveAddress

TMP007 I2C slave addresses.

The TMP007 Slave Address is determined by the input to the ADR0 and ADR1 input pins of the TMP007 hardware. A '1' indicates a supply voltage of up to 7.5 V while '0' indicates ground. In some cases, the ADR0 pin may be coupled with the SDA or SCL bus to achieve a particular slave address. TMP007 sensors on the same I2C bus cannot share the same slave address.

Enumerator
TMP007_SA1 

ADR1 = 0, ADR0 = 0

TMP007_SA2 

ADR1 = 0, ADR0 = 1

TMP007_SA3 

ADR1 = 0, ADR0 = SDA

TMP007_SA4 

ADR1 = 0, ADR0 = SCL

TMP007_SA5 

ADR1 = 1, ADR0 = 0

TMP007_SA6 

ADR1 = 1, ADR0 = 1

TMP007_SA7 

ADR1 = 1, ADR0 = SDA

TMP007_SA8 

ADR1 = 1, ADR0 = SCL

§ TMP007_TempScale

TMP007 temperature settings.

This enumeration defines the scaling for reading and writing temperature values with a TMP007 sensor.

Enumerator
TMP007_CELSIUS 
TMP007_KELVIN 
TMP007_FAHREN 

§ TMP007_TransientCorrect

TMP007 Transient Correct settings.

Setting this bit turns on the transient correction–enabling sensor voltage and object temperature output filtering. This helps reduce error due to changes in the die temperature. As a general guideline, turn on transient correction when the die temperature is changing at a rate greater than 1.5 degrees (C) per minute. Transient correction corrects transients up to approximately 20 degrees (C) per minute.

Enumerator
TMP007_TCDisable 
TMP007_TCEnable 

Function Documentation

§ TMP007_close()

bool TMP007_close ( TMP007_Handle  handle)

Function to close a TMP007 sensor specified by the TMP007 handle.

The TMP007 hardware will be placed in a low power state in which ADC conversions are disabled. If the pin is configured to alarm, the ALERT pin and GPIO pin interrupts will be disabled. The I2C handle is not affected.

Precondition
TMP007_open() had to be called first.
Parameters
handleA TMP007_Handle returned from TMP007_open()
Returns
true on success or false upon failure.

References TMP007_Object::callback, TMP007_Object::i2cHandle, TMP007_Config::object, TMP007_disableAlert(), and TMP007_disableConversions().

§ TMP007_disableAlert()

bool TMP007_disableAlert ( TMP007_Handle  handle)

Function to disable the ALERT pin and GPIO interrupt.

This function will disable the ALERT pin on the specified TMP007 sensor. Interrupts on the TMP007 specific GPIO index will be disabled. Any temperature limits set are not affected. This function is not thread safe when used in conjunction with TMP007_enableAlert() (ie. A task is executing TMP007_disableAlert() but preempted by a higher priority task that calls TMP007_enableAlert() on the same handle).

See also
TMP007_enableAlert()
Precondition
TMP007_enableAlert() had to be called first in order for this function to have an effect.
Parameters
handleA TMP007_Handle
Returns
true on success or false upon failure.

References CFG_ALRT, TMP007_Config::hwAttrs, TMP007_Config::object, TMP007_CONFIG, TMP007_readRegister(), and TMP007_writeRegister().

Referenced by TMP007_close().

§ TMP007_disableConversions()

bool TMP007_disableConversions ( TMP007_Handle  handle)

Function to put TMP007 sensor is low power state.

This function will place the specified TMP007 sensor in a low power state. All settings are retained. Temperature and voltage readings are invalid in this state. This function is not thread safe when used in conjunction with TMP007_enableConversions().

See also
TMP007_enableConversions()
Precondition
TMP007_open() had to be called first.
Parameters
handleA TMP007_Handle
Returns
true on success or false upon failure.

References CFG_CONV_ON, TMP007_CONFIG, TMP007_readRegister(), and TMP007_writeRegister().

Referenced by TMP007_close().

§ TMP007_enableAlert()

bool TMP007_enableAlert ( TMP007_Handle  handle)

Function to enable the ALERT pin and GPIO interrupt.

This function will enable the ALERT pin on the specified TMP007 sensor. Interrupts on the TMP007 specific GPIO index will be disabled. This function is not thread safe when used in conjunction with TMP007_disableAlert() (ie. A task is executing TMP007_enableAlert() but preempted by a higher priority task that calls TMP007_disableAlert() on the same handle).

See also
TMP007_disableAlert()
TMP007_setObjTempLimit()
TMP007_setDieTempLimit()
Precondition
TMP007_setObjTempLimit() or TMP007_setDieTempLimit() had to be called first. If not called first, the TMP007 sensor will never generate an interrupt.
Parameters
handleA TMP007_Handle
Returns
true on success or false upon failure.

References CFG_ALRT, TMP007_Config::hwAttrs, TMP007_Config::object, TMP007_CONFIG, TMP007_readRegister(), and TMP007_writeRegister().

§ TMP007_enableConversions()

bool TMP007_enableConversions ( TMP007_Handle  handle)

Function to restore TMP007 to normal power operation.

This function will restore ADC conversions on the specified TMP007 sensor. Temperature and voltage readings may be invalid up to 4 seconds following this function call. This function is not thread safe when used in conjunction with TMP007_disableConversions().

See also
TMP007_disableConversions
Precondition
TMP007_disableConversions() had to be called first.
Parameters
handleA TMP007_Handle
Returns
true on success or false upon failure.

References CFG_CONV_ON, TMP007_CONFIG, TMP007_readRegister(), and TMP007_writeRegister().

§ TMP007_getDieTemp()

static bool TMP007_getDieTemp ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float *  temp 
)
inlinestatic

Function to read die temperature.

This function will return the temperature of the die. Full scale allows a result of up to (+/-)256 (C).

Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature format.
tempA pointer to a float in which temperature data will be stored in.
Returns
true on success or false upon failure.

References TMP007_DIE_TEMP, and TMP007_getTemp().

§ TMP007_getDieTempLimit()

static bool TMP007_getDieTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float *  high,
float *  low 
)
inlinestatic

This function will read the die temperature limits.

Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature return format.
highA pointer to a float to store the value of the high temperature limit.
lowA pointer to a float to store the value of the low temperature limit.
Returns
true on success or false upon failure.
See also
TMP007_setDieTempLimit()

References TMP007_DIE_HI_LIM, TMP007_DIE_LO_LIM, and TMP007_getTempLimit().

§ TMP007_getObjTemp()

static bool TMP007_getObjTemp ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float *  temp 
)
inlinestatic

Function to read object temperature.

This function will return the temperature of the object in the field of view of the specified TMP007 sensor. Full scale allows a result of up to (+/-)256 (C).

Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature format.
tempA pointer to a float in which temperature data will be stored in.
Returns
true on success or false upon failure.

References TMP007_getTemp(), and TMP007_OBJ_TEMP.

Referenced by coapHandleIrTemp().

§ TMP007_getObjTempLimit()

static bool TMP007_getObjTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float *  high,
float *  low 
)
inlinestatic

This function will read the object temperature limits.

Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature return format.
highA pointer to a float to store the value of the high temperature limit.
lowA pointer to a float to store the value of the low temperature limit.
Returns
true on success or false upon failure.
See also
TMP007_setObjTempLimit()

References i2cHandle, TMP007_getTempLimit(), TMP007_init(), TMP007_OBJ_HI_LIM, TMP007_OBJ_LO_LIM, TMP007_open(), TMP007_Params_init(), and TMP007_readRegister().

§ TMP007_getTemp()

bool TMP007_getTemp ( TMP007_Handle  ,
TMP007_TempScale  unit,
float *  data,
uint16_t  registerAddress 
)

§ TMP007_getTempLimit()

bool TMP007_getTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float *  data,
uint16_t  registerAddress 
)

§ TMP007_init()

void TMP007_init ( )

Function to initialize TMP007 driver.

This function will initialize the TMP007 driver. This should be called before BIOS_start().

References i2cHandle, and TMP007_Config::object.

Referenced by initTMP(), and TMP007_getObjTempLimit().

§ TMP007_open()

TMP007_Handle TMP007_open ( unsigned int  tmp007Index,
I2C_Handle  i2cHandle,
TMP007_Params params 
)

Function to open a given TMP007 sensor.

Function to initialize a given TMP007 sensor specified by the particular index value. This function must be called from a task context. If one intends to use the ALERT pin, a callBack function must be specified in the TMP007_Params structure. Additionally, a gpioIndex must be setup and specified in the TMP007_HWAttrs structure.

The I2C controller must be operating in BLOCKING mode. Failure to ensure the I2C_Handle is in BLOCKING mode will result in undefined behavior.

The user should ensure that each sensor has its own slaveAddress, gpioIndex (if alarming) and tmp007Index.

Precondition
TMP007_init() has to be called first
Parameters
tmp007IndexLogical sensor number for the TMP007 indexed into the TMP007_config table
i2cHandleAn I2C_Handle opened in BLOCKING mode
*paramsA pointer to TMP007_Params structure. If NULL, it will use default values.
Returns
A TMP007_Handle on success, or a NULL on failure.
See also
TMP007_init()
TMP007_Params_init()
TMP007_close()

References TMP007_Object::callback, TMP007_Params::callback, CFG_CONV_ON, CFG_SW_RST, TMP007_Params::conversions, TMP007_HWAttrs::gpioIndex, i2cHandle, TMP007_Object::i2cHandle, TMP007_Params::intComp, TMP007_CONFIG, TMP007_writeRegister(), TMP007_Params::transientCorrect, and WAIT_POST_RESET.

Referenced by initTMP(), and TMP007_getObjTempLimit().

§ TMP007_Params_init()

void TMP007_Params_init ( TMP007_Params params)

Function to initialize a TMP007_Params struct to its defaults.

Parameters
paramsA pointer to TMP007_Params structure for initialization.

Default values are: conversions = TMP007_4CONV intComp = TMP007_IntMode transientCorrect = TMP007_TCEnable callback = NULL

References TMP007_defaultParams.

Referenced by initTMP(), and TMP007_getObjTempLimit().

§ TMP007_readRegister()

bool TMP007_readRegister ( TMP007_Handle  handle,
uint16_t *  data,
uint8_t  registerAddress 
)

Read function for advanced users.

Parameters
handleA TMP007_Handle
registerAddressRegister address
dataA pointer to a data register in which received data will be written to. Must be 16 bits.
Returns
true on success or false upon failure.

References TMP007_Config::hwAttrs, i2cTransferFxn(), TMP007_Config::object, and READ_BUF_SIZE.

Referenced by TMP007_disableAlert(), TMP007_disableConversions(), TMP007_enableAlert(), TMP007_enableConversions(), TMP007_getObjTempLimit(), TMP007_getTemp(), TMP007_getTempLimit(), TMP007_readStatus(), TMP007_readVoltage(), and TMP007_setTempLimit().

§ TMP007_readStatus()

static bool TMP007_readStatus ( TMP007_Handle  handle,
uint16_t *  data 
)
inlinestatic

Function to read a TMP007 sensor's status register.

Parameters
handleA TMP007_Handle
dataA pointer to an uint16_t data buffer in which received data will be written.
Returns
true on success or false upon failure.

References TMP007_readRegister(), and TMP007_STATUS.

§ TMP007_readVoltage()

static bool TMP007_readVoltage ( TMP007_Handle  handle,
int16_t *  data 
)
inlinestatic

Function to read a TMP007 sensor's voltage register.

This function will read the sensor voltage register. This value is the digitized infrared sensor voltage output. The recieved data has a resolution of 156.25 nV/LSB and should be scaled appropriately.

Parameters
handleA TMP007_Handle
dataA uint16_t pointer to a storage address. This value may range from (+/-) 5.21 mV.
Returns
true on success or false upon failure.

References TMP007_readRegister(), TMP007_setTempLimit(), and TMP007_VOBJ.

§ TMP007_setDieTempLimit()

static bool TMP007_setDieTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float  high,
float  low 
)
inlinestatic

This function will set the die temperature limits.

This function will write the specified high and low die limits to the specified TMP007 sensor. The low limit will only flag when INT mode is enabled. In COMP mode, the low limit flag will always read 0 and therefore there will never be an ALERT generated on a low temperature limit. This function may be called multiple times to adjust or disable the limits.

See also
TMP007_enableAlert()
Precondition
TMP007_open() had to be called first.
Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature return format.
highA float that specifies the high limit. This value is limited to (+/-) 256 (C) with 0.5 (C) precision. Use TMP007_IGNORE as an argument if a high limit is not desired.
lowA float that specifies the low limit. This value is limited to (+/-) 256 (C) with 0.5 (C) precision. Use TMP007_IGNORE as an argument if a low limit is not desired.
Returns
true on success or false upon failure.

References TMP007_DIE_HI_LIM, TMP007_DIE_LO_LIM, TMP007_setTempLimit(), TMP007_SMER_LHEN, and TMP007_SMER_LLEN.

§ TMP007_setObjTempLimit()

static bool TMP007_setObjTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float  high,
float  low 
)
inlinestatic

This function will set the object temperature limits.

This function will write the specified high and low object limits to the specified TMP007 sensor. The low limit will only flag when INT mode is enabled. In COMP mode, the low limit will always read 0. This function may be called multiple times to adjust or disable the limits.

See also
enableAlert()
Precondition
TMP007_open() had to be called first.
Parameters
handleA TMP007_Handle
scaleA TMP007_TempScale field specifying the temperature return format.
highA float that specifies the high limit. This value is limited to (+/-) 256 (C) with 0.5 (C) precision. Use TMP007_IGNORE as an argument if a high limit is not desired.
lowA float that specifies the low limit. This value is limited to (+/-) 256 (C) with 0.5 (C) precision. Use TMP007_IGNORE as an argument if a low limit is not desired.
Returns
true on success or false upon failure.

References TMP007_OBJ_HI_LIM, TMP007_OBJ_LO_LIM, TMP007_setTempLimit(), TMP007_SMER_OHEN, TMP007_SMER_OLEN, and TMP007_writeRegister().

§ TMP007_setTempLimit()

bool TMP007_setTempLimit ( TMP007_Handle  handle,
TMP007_TempScale  scale,
float  data,
uint16_t  bitMask,
uint8_t  registerAddress 
)

§ TMP007_writeRegister()

bool TMP007_writeRegister ( TMP007_Handle  handle,
uint16_t  data,
uint8_t  registerAddress 
)

Write function for advanced users. This is not thread safe.

When writing to a handle, it is possible to overwrite data written by another task.

For example: Task A and B are writing to the configuration register. Task A has a higher priority than Task B. Task B is running and reads the configuration register. Task A then preempts Task B and reads the configuration register, performs a logical OR and writes to the configuration register. Task B then resumes execution and performs its logical OR and writes to the configuration register–overwriting the data written by Task A.

Such instances can be prevented through the use of Semaphores. Below is an example which utilizes an initialized Semaphore_handle, tmp007Lock.

if (Semaphore_pend(tmp007Lock, BIOS_NO_WAIT)) {
//Perform read/write operations
}
else {
Task_sleep(1000);
}
Semaphore_post(tmp007Lock);
Parameters
handleA TMP007_Handle
dataA uint16_t containing the 2 bytes to be written to the TMP007 sensor.
registerAddressRegister address.
Returns
true on success or false upon failure.

References TMP007_Config::hwAttrs, i2cTransferFxn(), TMP007_Config::object, and WRITE_BUF_SIZE.

Referenced by TMP007_disableAlert(), TMP007_disableConversions(), TMP007_enableAlert(), TMP007_enableConversions(), TMP007_open(), TMP007_setObjTempLimit(), and TMP007_setTempLimit().

© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale