30static HAL_StatusTypeDef
tempHum_onOff(I2C_HandleTypeDef *hi2c, uint8_t onOff)
78 HAL_StatusTypeDef status = HAL_ERROR;
97 for (uint8_t i = 0; i < len; i++) {
99 for (uint8_t bit = 8; bit > 0; --bit) {
101 crc = (crc << 1) ^ 0x31;
107 return (crc == checksum);
114 HAL_StatusTypeDef ret = HAL_ERROR;
126 ret = HAL_I2C_Master_Transmit(hi2c, (
_tempHumAddr << 1), &cmd, 1, 100);
134 ret = HAL_I2C_Master_Receive(hi2c, (
_tempHumAddr << 1), buffer, 6, 100);
148 uint16_t t_raw = (buffer[0] << 8) | buffer[1];
149 uint16_t rh_raw = (buffer[3] << 8) | buffer[4];
This file contains all the function prototypes for the i2c.c file.
HAL_StatusTypeDef I2C_IsDeviceReadyMT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout)
Wrapper around HAL_I2C_IsDeviceReady() that recovers from a busy bus. If the HAL I2C bus is in a BUSY...
#define PRIf_02D(fData)
Expands to integer and fractional arguments for use with PRIf_02. Splits a float/double into the inte...
#define PRIf_02
printf format string for printing a float/double as integer with 2 decimal places....
mems_MainBlock_t _memsMainBlock
Global instance of the main flash control block; loaded by mems_ReadMainBlock().
HAL_StatusTypeDef mems_WriteMainBlock()
writing the main block on flash. The main block is stored on address 0
Measurement data produced by the SHT45 temperature and humidity sensor. Populate by calling tmphm_sht...
void HAL_Delay(__IO uint32_t Delay)
HAL_StatusTypeDef tmphm_sht45_IsOn(I2C_HandleTypeDef *hi2c, uint8_t *onOff)
get state - sensor does not have on/off state - only for compatibility with others
HAL_StatusTypeDef tmphm_sht45_On(I2C_HandleTypeDef *hi2c)
Zapnutie sensora dummy.
HAL_StatusTypeDef tmphm_sht45_Init(I2C_HandleTypeDef *hi2c)
initialization, check if sensor is present or not. Checks main (0x44) and alternative address (0x45) ...
HAL_StatusTypeDef tmphm_sht45_Read(I2C_HandleTypeDef *hi2c)
read temperature and humidity from sensor, values are in _tempHumData
void tmphm_sht45_LogData(char *buf)
log data to buffer
static int8_t _isTempHumSensor
HAL_StatusTypeDef tmphm_sht45_Off(I2C_HandleTypeDef *hi2c)
turn off sensor - dummy
uint8_t tempHum_CheckCrc(uint8_t *data, uint8_t len, uint8_t checksum)
int8_t tmphm_sht45_Is(I2C_HandleTypeDef *hi2c, int8_t tryInit)
check if tempHum sensor is present
static HAL_StatusTypeDef tempHum_onOff(I2C_HandleTypeDef *hi2c, uint8_t onOff)
static uint16_t _tempHumAddr
tmphm_sht45_t _bck_tmphm_sht45Data
Snapshot copy of the last completed SHT45 measurement; used for LoRaWAN transmission.
tmphm_sht45_t _tmphm_sht45Data
Live measurement data from the SHT45 sensor; updated by tmphm_sht45_Read().