#include <stdint.h>
Go to the source code of this file.
◆ 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 | |
◆ 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_precision | precision to set the temperature to in decimal (9, 10, 11, 12). |
precision_data | struct containing all the values needed in precision calculations. |
- Returns
- 0 on success, 1 if user passed in an invalid precision value.
◆ OBC_TEMP_SENSOR_convert_raw_to_deg_c()
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_bytes | Bytes to convert to celsius float value |
TEMP_SENSOR_data_precision_coefficient | Coefficient used to get the temperature in the correct precision. |
TEMP_SENSOR_data_precision_insignificant_bits | Value used to remove always zero bits and bits not used the provided precision. |
precision_scaling_factor | Value used to convert the temperature into a representation with no fractional parts. |
- Returns
- the temperature in celsius after conversion.
◆ 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
-
- 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.
◆ 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
-
result | Memory 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!!
◆ 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_precision | Precision to set the temperature to in decimal (9, 10, 11, 12). |
temp_precision_conversion_delay_ms | Pointer to store the conversion delay. |
temp_scaling_factor | Pointer to store the scaling factor. |
- Returns
- 0 on success, 1 on write error, 2 when passed an invalid precision value.
◆ 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 |