1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef SENSOR_TEMPERATURE_DRIVER_H
10 #define SENSOR_TEMPERATURE_DRIVER_H
11 
12 #include "hdf_workqueue.h"
13 #include "osal_timer.h"
14 #include "sensor_config_parser.h"
15 #include "sensor_platform_if.h"
16 
17 #define TEMPERATURE_DEFAULT_SAMPLING_1000_MS    1000000000
18 
19 struct TemperatureData {
20     int32_t temperature;
21 };
22 
23 struct TemperatureOpsCall {
24     int32_t (*Init)(struct SensorCfgData *data);
25     int32_t (*ReadData)(struct SensorCfgData *data);
26 };
27 
28 struct TemperatureDrvData {
29     struct IDeviceIoService ioService;
30     struct HdfDeviceObject *device;
31     HdfWorkQueue temperatureWorkQueue;
32     HdfWork temperatureWork;
33     OsalTimer temperatureTimer;
34     bool detectFlag;
35     bool enable;
36     int64_t interval;
37     struct SensorCfgData *temperatureCfg;
38     struct TemperatureOpsCall ops;
39 };
40 
41 int32_t TemperatureRegisterChipOps(const struct TemperatureOpsCall *ops);
42 struct SensorCfgData *TemperatureCreateCfgData(const struct DeviceResourceNode *node);
43 void TemperatureReleaseCfgData(struct SensorCfgData *temperatureCfg);
44 
45 #endif /* SENSOR_TEMPERATURE_DRIVER_H */
46