MAVRK Embedded Software 0.91
Software Libraries for the MAVRK motherboard and related components
Functions | Variables

TMP103_Temp_Sensor.c File Reference

Perform interactions with the TMP103 via the I2C bus. More...

#include "MAVRK_Arch.h"
#include "stdef.h"
#include "F5137_system.h"
#include "F5137_usci.h"
#include "PC_Interface.h"
#include "F5137_Modular_EVM_IO.h"
#include "F5438_system.h"
#include "F5438_usci_Defs.h"
#include "F5438_usci.h"
#include "F5438_ProMB_Modular_EVM_IO.h"
#include "TMP103_Temp_Sensor.h"
#include "I2C_Functions.h"
#include "MAVRK_Return_Error_Codes.h"

Functions

unsigned char mvk_Read_TMP103_register (unsigned char pointer, unsigned char *read_data, unsigned char device_slot, unsigned int I2C_device_address)
 Reads values out of the indicated hardware register on the TMP103 Temp Sensor at the given I2C slave address.
unsigned char mvk_Write_TMP103_register (unsigned char pointer, unsigned char *write_data, unsigned char device_slot, unsigned int I2C_device_address)
 Write a value to an I2C register in the TMP103 Keypad Scan Device.
unsigned char mvk_Init_TMP103 (unsigned char device_slot, unsigned int I2C_device_address)
 Intialize TMP103 Temp Sensor Device.
unsigned char mvk_Set_TMP103_Low_Level_Alert_Temperature (signed char low_level_alert_temp, unsigned char device_slot, unsigned int I2C_device_address)
 Set the TMP103 Temp Sensor Device Low Level Temperature Alert value.
unsigned char mvk_Get_TMP103_Low_Level_Alert_Temperature (signed char *low_level_alert_temp, unsigned char device_slot, unsigned int I2C_device_address)
 Gets the TMP103 Temp Sensor Device Low Level Alert Temperature value.
unsigned char mvk_Set_TMP103_High_Level_Alert_Temperature (signed char high_level_alert_temp, unsigned char device_slot, unsigned int I2C_device_address)
 Set the TMP103 Temp Sensor Device High Level Temperature Alert value.
unsigned char mvk_Get_TMP103_High_Level_Alert_Temperature (signed char *high_level_alert_temp, unsigned char device_slot, unsigned int I2C_device_address)
 Gets the TMP103 Temp Sensor Device High Level Alert Temperature value.
unsigned char mvk_Set_TMP103_Operational_Mode (unsigned char operational_mode, unsigned char device_slot, unsigned int I2C_device_address)
 Set the operational mode of the TMP103 Temp Sensor.
unsigned char mvk_Get_TMP103_Mode (unsigned char *operational_mode, unsigned char device_slot, unsigned int I2C_device_address)
 Get the TMP103 Temp Sensor operational mode.
unsigned char mvk_Trigger_TMP103_One_Shot_Temperature_Measurement (unsigned char device_slot, unsigned int I2C_device_address)
 Initiates a single(one-shot) TMP103 temperature measurement.
unsigned char mvk_Set_TMP103_Conversion_Rate (unsigned char conversion_rate, unsigned char device_slot, unsigned int I2C_device_address)
 Set the TMP103 temp sensor conversion rate.
unsigned char mvk_Get_TMP103_Conversion_Rate (unsigned char *conversion_rate, unsigned char device_slot, unsigned int I2C_device_address)
 Get the TMP103 Temp Sensor conversion rate.
unsigned char mvk_Set_TMP103_Sleep_Enable (unsigned char mode, unsigned char device_slot, unsigned int I2C_device_address)
 Sets the TMP103 Sleep Function.
unsigned char mvk_Read_TMP103_Temperature (unsigned char *temperature, unsigned char device_slot, unsigned int I2C_device_address)
 Read the TMP103 Temp Sensor temperature register.
signed char mvk_Convert_To_Celsius (signed int data)
 Convert an TMP103 register temperature value into degrees Celsius.
unsigned int mvk_Convert_Celsius_To_Fahrenheit (unsigned int data)
 Convert an integer Celsius vlaue into an interger Farenheit value.
signed char mvk_Convert_TMP103_Celsius_Temperature_To_Threshold (signed char temp_data)
 Convert a celsius temperature into a threshold value used in the TMP103 Temp Sensor.
void mvk_Format_TMP103_Temperature_To_PrintF (signed int temp_data, signed char *temp_result_pointer)
 Convert a celsius temperature from the TMP103 Temp Sensor register into ASCII string.
signed char mvk_Convert_TMP103_ASCII_Number (unsigned char *ASCII_number)
 Converts a string of ASCII values into a signed char.

Variables

volatile unsigned char TMP103_Configuration = 0000
volatile
TMP103_Configuration_register_type
TMP103_Configuration_register = (TMP103_Configuration_register_type*) &TMP103_Configuration
I2C_Device_Parameter_type TMP103_I2C_Device_Default_Settings = {I2C_100_KHZ, I2C_7_BIT_ADDRESS, NULL}
volatile unsigned char TMP103_Last_Operational_Mode

Detailed Description

Perform interactions with the TMP103 via the I2C bus.

Author:
Ron Crea
Date:
September 2011

The TMP103_Temp_Sensor functions initialize and configure the various settings in the TMP112 Temp Sensor devices.

Note:
Prototypes for functions in this file are located in the TMP103_Temp_Sensor.h header file located in the mavrk_embedded\Modular_EVM_Libraries\Components\TMP_Sensor_Template directory
See also:
For Support: http://ti.com/mavrkquestions

Function Documentation

unsigned int mvk_Convert_Celsius_To_Fahrenheit ( unsigned int  data)

Convert an integer Celsius vlaue into an interger Farenheit value.

Parameters:
[in]dataTemperature value in celsius (in degrees)
Returns:
Value in Farenheit (in degrees)
Note:
This only works on positive Celsius temperatures
signed char mvk_Convert_TMP103_ASCII_Number ( unsigned char *  ASCII_number)

Converts a string of ASCII values into a signed char.

This function converts a three character string of ASCII value into a signed char without requiring the string functions.

Parameters:
[in]ASCII_numberASCII string to convert. (-99 to 999)
Returns:
signed char containg the value that was in the input ASCII string
Warning:
This function REQUIRES a 3 byte string containing the input temperature, so 78 degrees must be present in teh ASCII form 078 in the input string
signed char mvk_Convert_TMP103_Celsius_Temperature_To_Threshold ( signed char  temp_data)

Convert a celsius temperature into a threshold value used in the TMP103 Temp Sensor.

This function takes a celsius input and converts the value into a configuration used by the TMP103 Temperateure Sensors register setting.

Parameters:
[in]temp_dataTemperature setting for the threshold in celsius (1 degree LSB)
Returns:
Setting for the hardware register
signed char mvk_Convert_To_Celsius ( signed int  data)

Convert an TMP103 register temperature value into degrees Celsius.

Parameters:
[in]dataTemperature value from a TMP103 register with temperature present
Returns:
Value in Celsius
void mvk_Format_TMP103_Temperature_To_PrintF ( signed int  temp_data,
signed char *  temp_result_pointer 
)

Convert a celsius temperature from the TMP103 Temp Sensor register into ASCII string.

This function takes a TMP103 Temp Sensor register setting and converts it into a celsius value (LSB 1 degree) with a + or - sign in the first character position as appropriate. The reusltant value (3 bytes) is written to the output pointer position.

Parameters:
[in]temp_dataTemperature setting for the threshold in celsius (1 degree LSB)
[out]temp_result_pointerPointer to a 3 byte string to place the sign and 2 ASCII numbers for degrees celsius
Returns:
None
unsigned char mvk_Get_TMP103_Conversion_Rate ( unsigned char *  conversion_rate,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Get the TMP103 Temp Sensor conversion rate.

This function reads the TMP103 Temperateure Sensor continuous conversion rate register value.

Parameters:
[out]conversion_rateTMP103 rate of temperature conversions ( _POINT_25_HZ_RATE, _1_HZ_RATE, _4_HZ_RATE, _8_HZ_RATE)
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Get_TMP103_High_Level_Alert_Temperature ( signed char *  high_level_alert_temp,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Gets the TMP103 Temp Sensor Device High Level Alert Temperature value.

This function reads the register containing the high level alert temperature value. When the TMP103 senses a temperateure lower than the high level alert value, the high level alert flag is set in the TMP103 configuration/status register

Parameters:
[out]high_level_alert_tempTemperature value(celsius) below which triggers a TMP103 high temp alert flag
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Get_TMP103_Low_Level_Alert_Temperature ( signed char *  low_level_alert_temp,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Gets the TMP103 Temp Sensor Device Low Level Alert Temperature value.

This function reads the register containing the low level alert temperature value. When the TMP103 senses a temperateure lower than the low level alert value, the low level alert flag is set in the TMP103 configuration/status register

Parameters:
[out]low_level_alert_tempTemperature value(celsius) below which triggers a TMP103 low temp alert flag
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Get_TMP103_Mode ( unsigned char *  operational_mode,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Get the TMP103 Temp Sensor operational mode.

This function reads the TMP103 Temperature Sensor operational mode register value.

Parameters:
[out]operational_modeOperational mode of TMP103 device (TMP103_SHUTDOWN, TMP103_CONTINUOUS_CONVERSION)
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Init_TMP103 ( unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Intialize TMP103 Temp Sensor Device.

This function writes all required TMP103 registers with configuration data to enable operation of the TMP103 Temperateure Sensors.

Parameters:
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Read_TMP103_register ( unsigned char  pointer,
unsigned char *  read_data,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Reads values out of the indicated hardware register on the TMP103 Temp Sensor at the given I2C slave address.

The function will handle the I2C Communications to read a register out of the TMP103 devices

Parameters:
[in]pointerTMP103 register address to be read
[out]read_dataPointer to variable where data read from TMP103 register is stored
[in]device_slotDefines slot where TMP103 device is located on the MB-PRO-MVK motherboard
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Read_TMP103_Temperature ( unsigned char *  temperature,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Read the TMP103 Temp Sensor temperature register.

This function reads the TMP103 temperature register

Parameters:
[out]temperaturePointer to the location to place the temperature value from the TMP103
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Set_TMP103_Conversion_Rate ( unsigned char  conversion_rate,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Set the TMP103 temp sensor conversion rate.

This function writes the register used to set the temperature conversion rate.

Parameters:
[in]conversion_rateRate of TMP103 temperature conversions ( _POINT_25_HZ_RATE, _1_HZ_RATE, _4_HZ_RATE, _8_HZ_RATE)
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Set_TMP103_High_Level_Alert_Temperature ( signed char  high_level_alert_temp,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Set the TMP103 Temp Sensor Device High Level Temperature Alert value.

This function writes the register containing the high level alert temperature value. When the TMP103 senses a temperateure greater than the high level alert value, the high level alert flag is set in the TMP103 configuration/status register

Parameters:
[in]high_level_alert_tempTemperature value(celsius) above which triggers a TMP103 high temp alert flag
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Set_TMP103_Low_Level_Alert_Temperature ( signed char  low_level_alert_temp,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Set the TMP103 Temp Sensor Device Low Level Temperature Alert value.

This function writes the register containing the low level alert temperature value. When the TMP103 senses a temperateure lower than the low level alert value, the low level alert flag is set in the TMP103 configuration/status register

Parameters:
[in]low_level_alert_tempTemperature value(celsius) below which triggers a TMP103 low temp alert flag
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Set_TMP103_Operational_Mode ( unsigned char  operational_mode,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Set the operational mode of the TMP103 Temp Sensor.

This function writes the TMP103 Temperature operational mode register. TMP103_SHUTDOWN mode conserves power by shutting down all device functionality except the serial interface. TMP103_CONTINUOUS_CONVERSION mode continuously measures temperature at the rate defined by the Configuration Register Conversion Rate value.

Parameters:
[in]operational_modeOperational Mode of TMP103 (TMP103_SHUTDOWN, TMP103_CONTINUOUS_CONVERSION)
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Set_TMP103_Sleep_Enable ( unsigned char  mode,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Sets the TMP103 Sleep Function.

This function enables or disables the TMP103 sleep mode setting

Parameters:
[in]modeSleep Mode setting (ENABLE or DISABLE)
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
unsigned char mvk_Trigger_TMP103_One_Shot_Temperature_Measurement ( unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Initiates a single(one-shot) TMP103 temperature measurement.

This command initiates a single TMP103 temperature mesurement only when the current TMP103 operation mode is TMP_SHUTDOWN. This feature is useful for reducing power consumption in the TMP103 when continuous temperature monitoring is not required. A single conversion typically takes 26ms and a read can take place in less than 20ìs. When using One-Shot mode, 30 or more conversions per second are possible.

Parameters:
[in]device_slotDefines slot where TMP103 device is located
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C
INVALID_COMMAND One Shot measurement cannot be activated unless TMP103 is in TMP103_SHUTDOWN mode.
unsigned char mvk_Write_TMP103_register ( unsigned char  pointer,
unsigned char *  write_data,
unsigned char  device_slot,
unsigned int  I2C_device_address 
)

Write a value to an I2C register in the TMP103 Keypad Scan Device.

The function will write a value to an I2C register in the TMP103 Temp Sensor Device.

Parameters:
[in]pointerTMP103 register address to be written
[in]write_dataPointer to value to be written to the specified TMP103 register
[in]device_slotDefines slot where TMP103 device is located on the MB-PRO-MVK motherboard
[in]I2C_device_addressTMP103 I2C slave address
Returns:
I2C_OPERATION_SUCCESSFUL Success
I2C_WRITE_FAILED_NACK Failure as TMP103 NAK a transmission on I2C

Variable Documentation

volatile unsigned char TMP103_Configuration = 0000
I2C_Device_Parameter_type TMP103_I2C_Device_Default_Settings = {I2C_100_KHZ, I2C_7_BIT_ADDRESS, NULL}
volatile unsigned char TMP103_Last_Operational_Mode
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines