CTS-SAT-1-OBC-Firmware
|
#include "main.h"
#include "stdio.h"
#include <stdint.h>
#include "obc_systems/obc_temperature_sensor.h"
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. | |
int8_t | OBC_TEMP_SENSOR_get_temp_precision () |
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. | |
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. | |
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. | |
int32_t | OBC_TEMP_SENSOR_get_temperature_cC () |
The simplest and most foolproof way to get the OBC temperature in centi-celsius. | |
Variables | |
const uint16_t | OBC_TEMP_SENSOR_device_addr = 0x48 |
const uint16_t | OBC_TEMP_SENSOR_temp_register_addr = 0x00 |
const uint32_t | OBC_TEMP_SENSOR_timeout_ms = 50 |
const uint16_t | OBC_TEMP_SENSOR_config_register_addr = 0x01 |
const uint8_t | OBC_TEMP_SENSOR_precision = 0x01 << 5 |
uint16_t | OBC_TEMP_SENSOR_precision_scaling_factor = 100 |
float | OBC_TEMP_SENSOR_precision_coefficient = OBC_TEMP_SENSOR_ten_bit_precision_coefficient |
Temperature_Sensor_Data_Precision_Insignificant_Bytes_t | OBC_TEMP_SENSOR_precision_insignificant_bits = OBC_TEMP_SENSOR_TEN_BIT_PRECISION_INSIGNIFICANT_BYTES |
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.
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. |
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.
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. |
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.
None |
int32_t OBC_TEMP_SENSOR_get_temperature_cC | ( | ) |
The simplest and most foolproof way to get the OBC temperature in centi-celsius.
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.
result | Memory location to store the temperature result (units: degrees celsius). |
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.
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. |
const uint16_t OBC_TEMP_SENSOR_config_register_addr = 0x01 |
const uint16_t OBC_TEMP_SENSOR_device_addr = 0x48 |
const uint8_t OBC_TEMP_SENSOR_precision = 0x01 << 5 |
float OBC_TEMP_SENSOR_precision_coefficient = OBC_TEMP_SENSOR_ten_bit_precision_coefficient |
Temperature_Sensor_Data_Precision_Insignificant_Bytes_t OBC_TEMP_SENSOR_precision_insignificant_bits = OBC_TEMP_SENSOR_TEN_BIT_PRECISION_INSIGNIFICANT_BYTES |
uint16_t OBC_TEMP_SENSOR_precision_scaling_factor = 100 |
const uint16_t OBC_TEMP_SENSOR_temp_register_addr = 0x00 |
const uint32_t OBC_TEMP_SENSOR_timeout_ms = 50 |