LibDriver SHTC3
Loading...
Searching...
No Matches
driver_shtc3.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_SHTC3_H
38#define DRIVER_SHTC3_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
71typedef struct shtc3_handle_s
72{
73 uint8_t (*iic_init)(void);
74 uint8_t (*iic_deinit)(void);
75 uint8_t (*iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
76 uint8_t (*iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
77 void (*receive_callback)(uint16_t type);
78 void (*delay_ms)(uint32_t ms);
79 void (*debug_print)(const char *const fmt, ...);
80 uint8_t inited;
82
98
102
109
116#define DRIVER_SHTC3_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
117
124#define DRIVER_SHTC3_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
125
132#define DRIVER_SHTC3_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
133
140#define DRIVER_SHTC3_LINK_IIC_READ_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_read_address16 = FUC
141
148#define DRIVER_SHTC3_LINK_IIC_WRITE_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_write_address16 = FUC
149
156#define DRIVER_SHTC3_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
157
164#define DRIVER_SHTC3_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
165
172#define DRIVER_SHTC3_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
173
177
184
193uint8_t shtc3_info(shtc3_info_t *info);
194
207uint8_t shtc3_init(shtc3_handle_t *handle);
208
220uint8_t shtc3_deinit(shtc3_handle_t *handle);
221
237uint8_t shtc3_read(shtc3_handle_t *handle, shtc3_bool_t clock_stretching_enable,
238 uint16_t *temperature_raw, float *temperature_s,
239 uint16_t *humidity_raw, float *humidity_s);
240
256uint8_t shtc3_read_low_power(shtc3_handle_t *handle, shtc3_bool_t clock_stretching_enable,
257 uint16_t *temperature_raw, float *temperature_s,
258 uint16_t *humidity_raw, float *humidity_s);
259
270uint8_t shtc3_soft_reset(shtc3_handle_t *handle);
271
282uint8_t shtc3_sleep(shtc3_handle_t *handle);
283
294uint8_t shtc3_wakeup(shtc3_handle_t *handle);
295
299
306
318uint8_t shtc3_set_reg(shtc3_handle_t *handle, uint16_t command);
319
333uint8_t shtc3_get_reg(shtc3_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len);
334
338
342
343#ifdef __cplusplus
344}
345#endif
346
347#endif
shtc3_bool_t
shtc3 bool enumeration definition
uint8_t shtc3_init(shtc3_handle_t *handle)
initialize the chip
uint8_t shtc3_wakeup(shtc3_handle_t *handle)
wakeup
uint8_t shtc3_info(shtc3_info_t *info)
get chip's information
uint8_t shtc3_read(shtc3_handle_t *handle, shtc3_bool_t clock_stretching_enable, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
normal read
uint8_t shtc3_deinit(shtc3_handle_t *handle)
close the chip
uint8_t shtc3_soft_reset(shtc3_handle_t *handle)
soft reset the chip
struct shtc3_handle_s shtc3_handle_t
shtc3 handle structure definition
uint8_t shtc3_sleep(shtc3_handle_t *handle)
sleep
uint8_t shtc3_read_low_power(shtc3_handle_t *handle, shtc3_bool_t clock_stretching_enable, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read in low power mode
struct shtc3_info_s shtc3_info_t
shtc3 information structure definition
@ SHTC3_BOOL_FALSE
@ SHTC3_BOOL_TRUE
uint8_t shtc3_set_reg(shtc3_handle_t *handle, uint16_t command)
set the chip register
uint8_t shtc3_get_reg(shtc3_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
get the chip register
shtc3 handle structure definition
void(* delay_ms)(uint32_t ms)
uint8_t(* iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
void(* receive_callback)(uint16_t type)
uint8_t(* iic_init)(void)
uint8_t(* iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
shtc3 information structure definition
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
float max_current_ma
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]