foxBMS - Unit Tests
1.3.0
The foxBMS Unit Tests API Documentation
|
Driver for the Sensirion SHT35-DIS I2C humidity/temperature sensor. More...
Go to the source code of this file.
Functions | |
static uint8_t | HTSEN_CalculateCrc8 (const uint8_t *data, uint32_t length) |
computes CRC8. More... | |
static int16_t | HTSEN_ConvertRawTemperature (uint16_t data) |
computes temperature measurement from raw value. More... | |
static uint8_t | HTSEN_ConvertRawHumidity (uint16_t data) |
computes humidity measurement from raw value. More... | |
void | HTSEN_Trigger (void) |
triggers a measurement of the I2C humidity/temperature sensor. More... | |
uint8_t | TEST_HTSEN_TestCalculateCrc8 (uint8_t *data, uint32_t length) |
Variables | |
static HTSEN_STATE_e | htsen_state = HTSEN_START_MEAS |
describes the current state of the measurement More... | |
static uint8_t | htsen_counter = 0u |
static uint8_t | htsen_timeout_10ms = 0u |
static DATA_BLOCK_HTSEN_s | htsen_data = {.header.uniqueId = DATA_BLOCK_ID_HTSEN} |
Driver for the Sensirion SHT35-DIS I2C humidity/temperature sensor.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
Definition in file htsensor.c.
#define HTSEN_BYTE_SHIFT (8u) |
Defines for byte positions for data handling
Definition at line 90 of file htsensor.c.
#define HTSEN_CLOCK_STRETCHING (false) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 132 of file htsensor.c.
#define HTSEN_CRC_8BIT_MASK (0xFFu) |
Defines for sensor CRC computation
Definition at line 100 of file htsensor.c.
#define HTSEN_CRC_BYTE_SHIFT (0x8u) |
Defines for sensor CRC computation
Definition at line 98 of file htsensor.c.
#define HTSEN_CRC_MSB_MASK (0x80u) |
Defines for sensor CRC computation
Definition at line 99 of file htsensor.c.
#define HTSEN_CRC_POLYNOMIAL (0x31u) |
Defines for sensor CRC computation
Definition at line 96 of file htsensor.c.
#define HTSEN_CRC_SEED (0xFF) |
Defines for sensor CRC computation
Definition at line 97 of file htsensor.c.
#define HTSEN_FULL_SCALE (65535.0f) |
Conversion coefficients to get measurement from raw humidity value
Definition at line 80 of file htsensor.c.
#define HTSEN_HIGH_REPEATABILITY (0x00u) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 135 of file htsensor.c.
#define HTSEN_HUMIDITY_BYTE_CRC (5u) |
Defines for byte positions for data handling
Definition at line 89 of file htsensor.c.
#define HTSEN_HUMIDITY_LSB (4u) |
Defines for byte positions for data handling
Definition at line 87 of file htsensor.c.
#define HTSEN_HUMIDITY_MSB (3u) |
Defines for byte positions for data handling
Definition at line 88 of file htsensor.c.
#define HTSEN_HUMIDITY_SCALING (100.0f) |
Conversion coefficients to get measurement from raw humidity value
Definition at line 79 of file htsensor.c.
#define HTSEN_I2C_ADDRESS (0x44u) |
Sensor I2C address
Definition at line 64 of file htsensor.c.
#define HTSEN_LOW_REPEATABILITY (0x16u) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 137 of file htsensor.c.
#define HTSEN_MEASUREMENT_LENGTH_IN_BYTES (2u) |
Defines for byte positions for data handling
Definition at line 91 of file htsensor.c.
#define HTSEN_MEDIUM_REPEATABILITY (0x0Bu) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 136 of file htsensor.c.
#define HTSEN_READ_TIMEOUT_10ms (10u) |
Timeout to avoid infinite loops when waiting for results
Definition at line 67 of file htsensor.c.
#define HTSEN_SINGLE_MEAS_LSB (HTSEN_HIGH_REPEATABILITY) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 145 of file htsensor.c.
#define HTSEN_SINGLE_MEAS_MSB (0x24u) |
Definition of single measurement command data sheet February 2019 - Version 6, table 9, page 10
Clock stretching can be used to let sensor tell that the measurement is not finished by pulling the clock low Not recommended: if system is stopped during clock stretching, sensor could be blocked in this mode and render I2C bus unusable. !!!—WARNING—!!!: if clock stretching is used, the timeout in the receive loop of the function I2C_ReadDirect() must be adapted, the current value is too small compared to the time the slave will make the master wait in the clock stretching mode.
Depending on the clock stretching setting, the code for the instructions changes: -> With stretching
Definition at line 134 of file htsensor.c.
#define HTSEN_TEMP_DEG_TO_DDEG (10.0f) |
Conversion coefficients to get measurement from raw temperature value
Definition at line 75 of file htsensor.c.
#define HTSEN_TEMP_OFFSET (-45.0f) |
Conversion coefficients to get measurement from raw temperature value
Definition at line 74 of file htsensor.c.
#define HTSEN_TEMP_SCALING (175.0f) |
Conversion coefficients to get measurement from raw temperature value
Definition at line 73 of file htsensor.c.
#define HTSEN_TEMPERATURE_BYTE_CRC (2u) |
Defines for byte positions for data handling
Definition at line 86 of file htsensor.c.
#define HTSEN_TEMPERATURE_LSB (1u) |
Defines for byte positions for data handling
Definition at line 84 of file htsensor.c.
#define HTSEN_TEMPERATURE_MSB (0u) |
Defines for byte positions for data handling
Definition at line 85 of file htsensor.c.
#define HTSEN_TIME_MEAS_WAIT_10ms (2u) |
Timeout to wait for measurement in 10ms
Definition at line 70 of file htsensor.c.
#define HTSEN_TOTAL_DATA_LENGTH_IN_BYTES (6u) |
Defines for byte positions for data handling
Definition at line 92 of file htsensor.c.
|
static |
computes CRC8.
[in] | data | data to use to compute CRC |
[in] | length | length of data |
Definition at line 192 of file htsensor.c.
|
static |
computes humidity measurement from raw value.
[in] | data | raw humidity value |
Definition at line 218 of file htsensor.c.
|
static |
computes temperature measurement from raw value.
[in] | data | raw temperature value |
Definition at line 211 of file htsensor.c.
void HTSEN_Trigger | ( | void | ) |
triggers a measurement of the I2C humidity/temperature sensor.
This function steps through the state-machine that handles the measurement with the I2C sensor.
Definition at line 225 of file htsensor.c.
uint8_t TEST_HTSEN_TestCalculateCrc8 | ( | uint8_t * | data, |
uint32_t | length | ||
) |
|
static |
counter to wait before reading measurements after they were triggered
Definition at line 157 of file htsensor.c.
|
static |
variable to store the measurement results
Definition at line 162 of file htsensor.c.
|
static |
describes the current state of the measurement
This variable is used as a state-variable for switching through the steps of a conversion.
Definition at line 155 of file htsensor.c.
|
static |
timeout to restart measurement cycle if waiting too much to get results
Definition at line 159 of file htsensor.c.