CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
obc_temperature_sensor.h File Reference
#include <stdint.h>
Include dependency graph for obc_temperature_sensor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Set_Precision_Data
 

Enumerations

enum  Temperature_Sensor_Data_Precision_Insignificant_Bytes_t { OBC_TEMP_SENSOR_TWELVE_BIT_PRECISION_INSIGNIFICANT_BYTES = 4 , OBC_TEMP_SENSOR_ELEVEN_BIT_PRECISION_INSIGNIFICANT_BYTES , OBC_TEMP_SENSOR_TEN_BIT_PRECISION_INSIGNIFICANT_BYTES , OBC_TEMP_SENSOR_NINE_BIT_PRECISION_INSIGNIFICANT_BYTES }
 

Functions

uint8_t OBC_TEMP_SENSOR_read_temperature (int32_t *result)
 Reads the temperature from the STDS75DS2F and stores it in the provided variable pointer result. Precision can be configured from 9 to 12 bits. Temperature range is -55 to 125 degrees celsius with +/- 3 degrees celsius over the whole range.
 
int32_t OBC_TEMP_SENSOR_convert_raw_to_deg_c (uint8_t raw_bytes[], uint8_t precision_coefficient, Temperature_Sensor_Data_Precision_Insignificant_Bytes_t precision_insignificant_bits, uint16_t precision_scaling_factor)
 Converts the raw bytes provided to a temperature in celsius and multiplied by a scaling factor based on the provided precision. Works on the four MSBs. Reference https://www.st.com/resource/en/datasheet/stds75.pdf page 15 and 18 for information on calculations and format of temperature data.
 
uint8_t OBC_TEMP_SENSOR_set_temp_precision (uint8_t arg_precision, uint32_t *temp_precision_conversion_delay, uint32_t *temp_scaling_factor)
 Set the temp temperature precision in the config register.
 
uint8_t OBC_TEMP_SENSOR_configure_precision_values (uint8_t arg_precision, struct Set_Precision_Data *precision_data)
 Configures the precision global variables in preparation for setting the precision.
 
int8_t OBC_TEMP_SENSOR_get_temp_precision (void)
 Reads the temperature precision from the config register. Refer to https://www.st.com/resource/en/datasheet/stds75.pdf page 17, table 6 and 7 for more information.
 
int32_t OBC_TEMP_SENSOR_get_temperature_cC ()
 The simplest and most foolproof way to get the OBC temperature in centi-celsius.
 

Variables

static const int32_t OBC_TEMP_SENSOR_ERROR_TEMPERATURE_CC = 99999
 A fake temperature, in cC, which indicates an error in reading the temperature.
 
static const float OBC_TEMP_SENSOR_nine_bit_precision_coefficient = 2
 
static const float OBC_TEMP_SENSOR_ten_bit_precision_coefficient = 4
 
static const float OBC_TEMP_SENSOR_eleven_bit_precision_coefficient = 8
 
static const float OBC_TEMP_SENSOR_twelve_bit_precision_coefficient = 16
 
static const uint16_t OBC_TEMP_SENSOR_nine_bit_scaling_factor = 10
 
static const uint16_t OBC_TEMP_SENSOR_ten_bit_scaling_factor = 100
 
static const uint16_t OBC_TEMP_SENSOR_eleven_bit_scaling_factor = 1000
 
static const uint16_t OBC_TEMP_SENSOR_twelve_bit_scaling_factor = 10000
 

Enumeration Type Documentation

◆ Temperature_Sensor_Data_Precision_Insignificant_Bytes_t

Enumerator
OBC_TEMP_SENSOR_TWELVE_BIT_PRECISION_INSIGNIFICANT_BYTES 
OBC_TEMP_SENSOR_ELEVEN_BIT_PRECISION_INSIGNIFICANT_BYTES 
OBC_TEMP_SENSOR_TEN_BIT_PRECISION_INSIGNIFICANT_BYTES 
OBC_TEMP_SENSOR_NINE_BIT_PRECISION_INSIGNIFICANT_BYTES 

Function Documentation

◆ OBC_TEMP_SENSOR_configure_precision_values()

uint8_t OBC_TEMP_SENSOR_configure_precision_values ( uint8_t arg_precision,
struct Set_Precision_Data * precision_data )

Configures the precision global variables in preparation for setting the precision.

Parameters
arg_precisionprecision to set the temperature to in decimal (9, 10, 11, 12).
precision_datastruct containing all the values needed in precision calculations.
Returns
0 on success, 1 if user passed in an invalid precision value.
Here is the caller graph for this function:

◆ OBC_TEMP_SENSOR_convert_raw_to_deg_c()

int32_t OBC_TEMP_SENSOR_convert_raw_to_deg_c ( uint8_t raw_bytes[],
uint8_t precision_coefficient,
Temperature_Sensor_Data_Precision_Insignificant_Bytes_t precision_insignificant_bits,
uint16_t precision_scaling_factor )

Converts the raw bytes provided to a temperature in celsius and multiplied by a scaling factor based on the provided precision. Works on the four MSBs. Reference https://www.st.com/resource/en/datasheet/stds75.pdf page 15 and 18 for information on calculations and format of temperature data.

Parameters
raw_bytesBytes to convert to celsius float value
TEMP_SENSOR_data_precision_coefficientCoefficient used to get the temperature in the correct precision.
TEMP_SENSOR_data_precision_insignificant_bitsValue used to remove always zero bits and bits not used the provided precision.
precision_scaling_factorValue used to convert the temperature into a representation with no fractional parts.
Returns
the temperature in celsius after conversion.
Here is the caller graph for this function:

◆ OBC_TEMP_SENSOR_get_temp_precision()

int8_t OBC_TEMP_SENSOR_get_temp_precision ( void )

Reads the temperature precision from the config register. Refer to https://www.st.com/resource/en/datasheet/stds75.pdf page 17, table 6 and 7 for more information.

Parameters
None
Returns
-1 if there is an error otherwise the temperature precision in the least significant two bits as 0x01, 0x02, 0x03, 0x04.

◆ OBC_TEMP_SENSOR_get_temperature_cC()

int32_t OBC_TEMP_SENSOR_get_temperature_cC ( )

The simplest and most foolproof way to get the OBC temperature in centi-celsius.

Returns
The temperature in cC, if successful. 99999 (OBC_TEMP_SENSOR_ERROR_TEMPERATURE_CC) if unsuccessful.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OBC_TEMP_SENSOR_read_temperature()

uint8_t OBC_TEMP_SENSOR_read_temperature ( int32_t * result)

Reads the temperature from the STDS75DS2F and stores it in the provided variable pointer result. Precision can be configured from 9 to 12 bits. Temperature range is -55 to 125 degrees celsius with +/- 3 degrees celsius over the whole range.

Parameters
resultMemory location to store the temperature result (units: degrees celsius).
Returns
0 if successful, 1 if config register error, 2 if temp register error.
Note
You may think this gets you the temperature in cC, but it doesn't!!
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OBC_TEMP_SENSOR_set_temp_precision()

uint8_t OBC_TEMP_SENSOR_set_temp_precision ( uint8_t arg_precision,
uint32_t * temp_precision_conversion_delay_ms,
uint32_t * temp_scaling_factor )

Set the temp temperature precision in the config register.

Parameters
arg_precisionPrecision to set the temperature to in decimal (9, 10, 11, 12).
temp_precision_conversion_delay_msPointer to store the conversion delay.
temp_scaling_factorPointer to store the scaling factor.
Returns
0 on success, 1 on write error, 2 when passed an invalid precision value.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OBC_TEMP_SENSOR_eleven_bit_precision_coefficient

const float OBC_TEMP_SENSOR_eleven_bit_precision_coefficient = 8
static

◆ OBC_TEMP_SENSOR_eleven_bit_scaling_factor

const uint16_t OBC_TEMP_SENSOR_eleven_bit_scaling_factor = 1000
static

◆ OBC_TEMP_SENSOR_ERROR_TEMPERATURE_CC

const int32_t OBC_TEMP_SENSOR_ERROR_TEMPERATURE_CC = 99999
static

A fake temperature, in cC, which indicates an error in reading the temperature.

◆ OBC_TEMP_SENSOR_nine_bit_precision_coefficient

const float OBC_TEMP_SENSOR_nine_bit_precision_coefficient = 2
static

◆ OBC_TEMP_SENSOR_nine_bit_scaling_factor

const uint16_t OBC_TEMP_SENSOR_nine_bit_scaling_factor = 10
static

◆ OBC_TEMP_SENSOR_ten_bit_precision_coefficient

const float OBC_TEMP_SENSOR_ten_bit_precision_coefficient = 4
static

◆ OBC_TEMP_SENSOR_ten_bit_scaling_factor

const uint16_t OBC_TEMP_SENSOR_ten_bit_scaling_factor = 100
static

◆ OBC_TEMP_SENSOR_twelve_bit_precision_coefficient

const float OBC_TEMP_SENSOR_twelve_bit_precision_coefficient = 16
static

◆ OBC_TEMP_SENSOR_twelve_bit_scaling_factor

const uint16_t OBC_TEMP_SENSOR_twelve_bit_scaling_factor = 10000
static