1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * 4094332d3Sopenharmony_ci * HDF is dual licensed: you can use it either under the terms of 5094332d3Sopenharmony_ci * the GPL, or the BSD license, at your option. 6094332d3Sopenharmony_ci * See the LICENSE file in the root of this repository for complete details. 7094332d3Sopenharmony_ci */ 8094332d3Sopenharmony_ci 9094332d3Sopenharmony_ci#ifndef HUMIDITY_SHT30_H 10094332d3Sopenharmony_ci#define HUMIDITY_SHT30_H 11094332d3Sopenharmony_ci 12094332d3Sopenharmony_ci#include "sensor_config_parser.h" 13094332d3Sopenharmony_ci#include "sensor_humidity_driver.h" 14094332d3Sopenharmony_ci 15094332d3Sopenharmony_ci/* Humidity registers addr */ 16094332d3Sopenharmony_ci#define SHT30_HUM_DATA_ADDR 0x240B // Data 17094332d3Sopenharmony_ci 18094332d3Sopenharmony_ci/* Humidity data */ 19094332d3Sopenharmony_ci#define SHT30_HUM_DATA_BUF_LEN 6 20094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_ZERO 0 21094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_ONE 1 22094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_TWO 2 23094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_THREE 3 24094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_FOUR 4 25094332d3Sopenharmony_ci#define SHT30_HUM_VALUE_INDEX_FIVE 5 26094332d3Sopenharmony_ci 27094332d3Sopenharmony_ci#define SHT30_HUM_SLOPE 10000 // 100.0 * 100 28094332d3Sopenharmony_ci#define SHT30_HUM_RESOLUTION 0xFFFF 29094332d3Sopenharmony_ci#define SHT30_HUM_SHFIT_1_BIT 1 30094332d3Sopenharmony_ci 31094332d3Sopenharmony_ci/* Humidity crc8 */ 32094332d3Sopenharmony_ci#define SHT30_HUM_CRC8_BASE 0xFF 33094332d3Sopenharmony_ci#define SHT30_HUM_CRC8_MASK 0x80 34094332d3Sopenharmony_ci#define SHT30_HUM_CRC8_POLYNOMIAL 0x31 35094332d3Sopenharmony_ci#define SHT30_HUM_CRC8_LEN 2 36094332d3Sopenharmony_ci 37094332d3Sopenharmony_ciint32_t DetectHumiditySht30Chip(struct SensorCfgData *data); 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_cistruct Sht30DrvData { 40094332d3Sopenharmony_ci struct IDeviceIoService ioService; 41094332d3Sopenharmony_ci struct HdfDeviceObject *device; 42094332d3Sopenharmony_ci struct SensorCfgData *sensorCfg; 43094332d3Sopenharmony_ci}; 44094332d3Sopenharmony_ci 45094332d3Sopenharmony_ci#endif /* HUMIDITY_SHT30_H */ 46