76 lines
2.1 KiB
C
76 lines
2.1 KiB
C
/*
|
|
* File: sht4x.h
|
|
* Description: Sensirion SHT4x sensor communication library
|
|
* Author: David Zaitlik
|
|
* Date: 2022-06-22
|
|
*
|
|
*
|
|
* Copyright (c) 2024 Veles Labs s.r.o.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef INC_SHT4X_H_
|
|
#define INC_SHT4X_H_
|
|
|
|
#include "stdint.h"
|
|
|
|
/*
|
|
* Defines & macros
|
|
*/
|
|
|
|
#define SHT4X_I2C_ADDRESS 0x44
|
|
|
|
/*
|
|
* Return values
|
|
*/
|
|
|
|
#define SHT4X_OK 0
|
|
#define SHT4X_ERROR -1 // generic error
|
|
#define SHT4X_CRC8_ERROR -2 // checksum failed
|
|
|
|
/*
|
|
* Data types
|
|
*/
|
|
|
|
typedef enum {
|
|
SHT4X_START_MEAS_HIGH_PRECISION = 0xFD,
|
|
SHT4X_START_MEAS_MEDIUM_PRECISION = 0xF6,
|
|
SHT4X_START_MEAS_LOW_PRECISION = 0xE0,
|
|
SHT4X_READ_SERIAL = 0x89,
|
|
SHT4X_SOFT_RESET = 0x94,
|
|
SHT4X_HEATER_200_mW_1_s = 0x39,
|
|
SHT4X_HEATER_200_mW_01_s = 0x32,
|
|
SHT4X_HEATER_110_mW_1_s = 0x2F,
|
|
SHT4X_HEATER_110_mW_01_s = 0x24,
|
|
SHT4X_HEATER_20_mW_1_s = 0x1E,
|
|
SHT4X_HEATER_20_mW_01_s = 0x15
|
|
} sht4x_cmd_t;
|
|
|
|
/*
|
|
* Function prototypes
|
|
*/
|
|
|
|
int8_t sht4x_send_cmd(sht4x_cmd_t cmd);
|
|
int8_t sht4x_read_data(uint8_t *buffer, int len);
|
|
int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity);
|
|
|
|
#endif /* INC_SHT4X_H_ */
|