-
Notifications
You must be signed in to change notification settings - Fork 18
/
shtc3.h
52 lines (42 loc) · 1.63 KB
/
shtc3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Konstantin Belyalov. All rights reserved.
// Licensed under the MIT license.
#ifndef __SHTC3_H
#define __SHTC3_H
#include "main.h"
#ifdef __cplusplus
#define EXPORT extern "C"
#else
#define EXPORT
#endif
// The shtc3 provides a serial number individualized for each device
// Params:
// - `hi2c` I2C bus
// Returns device id or 0 in case of error.
EXPORT uint16_t shtc3_read_id(I2C_HandleTypeDef *hi2c);
// Put sensor into sleep mode
// Params:
// - `hi2c` I2C bus
// Returns device id or 0 in case of error.
EXPORT uint32_t shtc3_sleep(I2C_HandleTypeDef *hi2c);
// Wake up sensor.
// You must wait for 240us to let sensor enter into IDLE mode.
// Params:
// - `hi2c` I2C bus
// Returns zero in case of error
EXPORT uint32_t shtc3_wakeup(I2C_HandleTypeDef *hi2c);
// Performs full cycle: starts temperature/humidity measurements using "clock stretch" method.
// Params:
// - `hi2c` I2C bus
// - `temp` measured temperature, in C multiplied by 100 (e.g. 24.1C -> 2410)
// - `hum` measured relative humidity, in percents
// Returns zero in case of error
EXPORT uint32_t shtc3_perform_measurements(I2C_HandleTypeDef *hi2c, int32_t* temp, int32_t* hum);
// Start temperature/humidity measurements using "clock stretch" approach, in low power mode.
// After completed - values can be obtained by shtc3_read_measurements()
// Params:
// - `hi2c` I2C bus
// - `temp` measured temperature, in C multiplied by 100 (e.g. 24.1C -> 2410)
// - `hum` measured relative humidity, in percents
// Returns zero in case of error
EXPORT uint32_t shtc3_perform_measurements_low_power(I2C_HandleTypeDef *hi2c, int32_t* out_temp, int32_t* out_hum);
#endif