LibDriver SHT85
Loading...
Searching...
No Matches
driver_sht85.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_SHT85_H
38#define DRIVER_SHT85_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
79
89
103
107typedef struct sht85_handle_s
108{
109 uint8_t (*iic_init)(void);
110 uint8_t (*iic_deinit)(void);
111 uint8_t (*iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
112 uint8_t (*iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
113 void (*receive_callback)(uint16_t type);
114 void (*delay_ms)(uint32_t ms);
115 void (*debug_print)(const char *const fmt, ...);
117 uint8_t inited;
119
135
139
146
153#define DRIVER_SHT85_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
154
161#define DRIVER_SHT85_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
162
169#define DRIVER_SHT85_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
170
177#define DRIVER_SHT85_LINK_IIC_READ_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_read_address16 = FUC
178
185#define DRIVER_SHT85_LINK_IIC_WRITE_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_write_address16 = FUC
186
193#define DRIVER_SHT85_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
194
201#define DRIVER_SHT85_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
202
209#define DRIVER_SHT85_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
210
214
221
230uint8_t sht85_info(sht85_info_t *info);
231
242uint8_t sht85_init(sht85_handle_t *handle);
243
254uint8_t sht85_deinit(sht85_handle_t *handle);
255
270uint8_t sht85_single_read(sht85_handle_t *handle,
271 uint16_t *temperature_raw, float *temperature_s,
272 uint16_t *humidity_raw, float *humidity_s);
273
286
298
314 uint16_t *temperature_raw, float *temperature_s,
315 uint16_t *humidity_raw, float *humidity_s);
316
328uint8_t sht85_get_status(sht85_handle_t *handle, uint16_t *status);
329
340uint8_t sht85_clear_status(sht85_handle_t *handle);
341
352uint8_t sht85_set_repeatability(sht85_handle_t *handle, sht85_repeatability_t repeatability);
353
364uint8_t sht85_get_repeatability(sht85_handle_t *handle, sht85_repeatability_t *repeatability);
365
376uint8_t sht85_set_art(sht85_handle_t *handle);
377
388uint8_t sht85_soft_reset(sht85_handle_t *handle);
389
401uint8_t sht85_set_heater(sht85_handle_t *handle, sht85_bool_t enable);
402
414uint8_t sht85_get_serial_number(sht85_handle_t *handle, uint8_t sn[4]);
415
419
426
438uint8_t sht85_set_reg(sht85_handle_t *handle, uint16_t command);
439
453uint8_t sht85_get_reg(sht85_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len);
454
458
462
463#ifdef __cplusplus
464}
465#endif
466
467#endif
uint8_t sht85_start_continuous_read(sht85_handle_t *handle, sht85_rate_t rate)
start reading
uint8_t sht85_continuous_read(sht85_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data continuously
uint8_t sht85_set_heater(sht85_handle_t *handle, sht85_bool_t enable)
enable or disable the chip heater
uint8_t sht85_clear_status(sht85_handle_t *handle)
clear the current status
uint8_t sht85_get_serial_number(sht85_handle_t *handle, uint8_t sn[4])
get serial number
struct sht85_info_s sht85_info_t
sht85 information structure definition
uint8_t sht85_init(sht85_handle_t *handle)
initialize the chip
uint8_t sht85_set_repeatability(sht85_handle_t *handle, sht85_repeatability_t repeatability)
set the measurement repeatability
sht85_repeatability_t
sht85 repeatability enumeration definition
sht85_status_t
sht85 status enumeration definition
uint8_t sht85_stop_continuous_read(sht85_handle_t *handle)
stop reading
uint8_t sht85_deinit(sht85_handle_t *handle)
close the chip
uint8_t sht85_info(sht85_info_t *info)
get chip's information
sht85_rate_t
sht85 rate enumeration definition
uint8_t sht85_set_art(sht85_handle_t *handle)
set the chip art
sht85_bool_t
sht85 bool enumeration definition
uint8_t sht85_get_status(sht85_handle_t *handle, uint16_t *status)
get the current status
struct sht85_handle_s sht85_handle_t
sht85 handle structure definition
uint8_t sht85_single_read(sht85_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data once
uint8_t sht85_soft_reset(sht85_handle_t *handle)
soft reset the chip
uint8_t sht85_get_repeatability(sht85_handle_t *handle, sht85_repeatability_t *repeatability)
get the measurement repeatability
@ SHT85_REPEATABILITY_HIGH
@ SHT85_REPEATABILITY_LOW
@ SHT85_REPEATABILITY_MEDIUM
@ SHT85_STATUS_SYSTEM_RESET
@ SHT85_STATUS_HEATER_ON
@ SHT85_STATUS_ALERT_PENDING_STATUS
@ SHT85_STATUS_HUMIDITY_ALERT
@ SHT85_STATUS_COMMAND_STATUS
@ SHT85_STATUS_TEMPERATURE_ALERT
@ SHT85_STATUS_CHECKSUM_STATUS
@ SHT85_RATE_0P5HZ
@ SHT85_RATE_4HZ
@ SHT85_RATE_2HZ
@ SHT85_RATE_1HZ
@ SHT85_RATE_10HZ
@ SHT85_BOOL_TRUE
@ SHT85_BOOL_FALSE
uint8_t sht85_set_reg(sht85_handle_t *handle, uint16_t command)
set the chip register
uint8_t sht85_get_reg(sht85_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
get the chip register
sht85 handle structure definition
void(* delay_ms)(uint32_t ms)
uint8_t repeatability
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)
sht85 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]