LibDriver SHT30
Loading...
Searching...
No Matches
driver_sht30.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_SHT30_H
39#define DRIVER_SHT30_H
40
41#include <stdio.h>
42#include <stdint.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
63typedef enum
64{
65 SHT30_ADDRESS_0 = (0x44 << 1),
66 SHT30_ADDRESS_1 = (0x45 << 1),
68
72typedef enum
73{
77
89
99
113
117typedef struct sht30_handle_s
118{
119 uint8_t (*iic_init)(void);
120 uint8_t (*iic_deinit)(void);
121 uint8_t (*iic_write_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
122 uint8_t (*iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len);
123 void (*receive_callback)(uint16_t type);
124 void (*delay_ms)(uint32_t ms);
125 void (*debug_print)(const char *const fmt, ...);
126 uint8_t iic_addr;
128 uint8_t inited;
130
146
150
157
164#define DRIVER_SHT30_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
165
172#define DRIVER_SHT30_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
173
180#define DRIVER_SHT30_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
181
188#define DRIVER_SHT30_LINK_IIC_READ_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_read_address16 = FUC
189
196#define DRIVER_SHT30_LINK_IIC_WRITE_ADDRESS16(HANDLE, FUC) (HANDLE)->iic_write_address16 = FUC
197
204#define DRIVER_SHT30_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
205
212#define DRIVER_SHT30_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
213
220#define DRIVER_SHT30_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
221
225
232
241uint8_t sht30_info(sht30_info_t *info);
242
253uint8_t sht30_set_addr_pin(sht30_handle_t *handle, sht30_address_t addr_pin);
254
265uint8_t sht30_get_addr_pin(sht30_handle_t *handle, sht30_address_t *addr_pin);
266
277uint8_t sht30_irq_handler(sht30_handle_t *handle);
278
289uint8_t sht30_init(sht30_handle_t *handle);
290
301uint8_t sht30_deinit(sht30_handle_t *handle);
302
318uint8_t sht30_single_read(sht30_handle_t *handle, sht30_bool_t clock_stretching_enable,
319 uint16_t *temperature_raw, float *temperature_s,
320 uint16_t *humidity_raw, float *humidity_s
321 );
322
335
347
363 uint16_t *temperature_raw, float *temperature_s,
364 uint16_t *humidity_raw, float *humidity_s);
365
377uint8_t sht30_get_status(sht30_handle_t *handle, uint16_t *status);
378
389uint8_t sht30_clear_status(sht30_handle_t *handle);
390
401uint8_t sht30_set_repeatability(sht30_handle_t *handle, sht30_repeatability_t repeatability);
402
413uint8_t sht30_get_repeatability(sht30_handle_t *handle, sht30_repeatability_t *repeatability);
414
425uint8_t sht30_set_art(sht30_handle_t *handle);
426
437uint8_t sht30_soft_reset(sht30_handle_t *handle);
438
450uint8_t sht30_set_heater(sht30_handle_t *handle, sht30_bool_t enable);
451
463uint8_t sht30_get_serial_number(sht30_handle_t *handle, uint8_t sn[4]);
464
477uint8_t sht30_set_high_alert_limit(sht30_handle_t *handle, uint16_t set, uint16_t clear);
478
491uint8_t sht30_get_high_alert_limit(sht30_handle_t *handle, uint16_t *set, uint16_t *clear);
492
505uint8_t sht30_set_low_alert_limit(sht30_handle_t *handle, uint16_t set, uint16_t clear);
506
519uint8_t sht30_get_low_alert_limit(sht30_handle_t *handle, uint16_t *set, uint16_t *clear);
520
533uint8_t sht30_alert_limit_convert_to_register(sht30_handle_t *handle, float temperature, float humidity, uint16_t *reg);
534
538
545
557uint8_t sht30_set_reg(sht30_handle_t *handle, uint16_t command);
558
572uint8_t sht30_get_reg(sht30_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len);
573
577
581
582#ifdef __cplusplus
583}
584#endif
585
586#endif
uint8_t sht30_stop_continuous_read(sht30_handle_t *handle)
stop reading
uint8_t sht30_info(sht30_info_t *info)
get chip's information
uint8_t sht30_start_continuous_read(sht30_handle_t *handle, sht30_rate_t rate)
start reading
uint8_t sht30_set_repeatability(sht30_handle_t *handle, sht30_repeatability_t repeatability)
set the measurement repeatability
sht30_rate_t
sht30 rate enumeration definition
sht30_repeatability_t
sht30 repeatability enumeration definition
uint8_t sht30_get_addr_pin(sht30_handle_t *handle, sht30_address_t *addr_pin)
get the iic address pin
uint8_t sht30_single_read(sht30_handle_t *handle, sht30_bool_t clock_stretching_enable, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data once
uint8_t sht30_init(sht30_handle_t *handle)
initialize the chip
uint8_t sht30_soft_reset(sht30_handle_t *handle)
soft reset the chip
uint8_t sht30_get_low_alert_limit(sht30_handle_t *handle, uint16_t *set, uint16_t *clear)
get low alert limit
sht30_bool_t
sht30 bool enumeration definition
uint8_t sht30_set_art(sht30_handle_t *handle)
set the chip art
sht30_address_t
sht30 address enumeration definition
struct sht30_info_s sht30_info_t
sht30 information structure definition
uint8_t sht30_alert_limit_convert_to_register(sht30_handle_t *handle, float temperature, float humidity, uint16_t *reg)
alert limit convert to register raw data
uint8_t sht30_set_heater(sht30_handle_t *handle, sht30_bool_t enable)
enable or disable the chip heater
uint8_t sht30_get_status(sht30_handle_t *handle, uint16_t *status)
get the current status
uint8_t sht30_irq_handler(sht30_handle_t *handle)
irq handler
uint8_t sht30_set_addr_pin(sht30_handle_t *handle, sht30_address_t addr_pin)
set the iic address pin
uint8_t sht30_continuous_read(sht30_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read data continuously
uint8_t sht30_set_high_alert_limit(sht30_handle_t *handle, uint16_t set, uint16_t clear)
set high alert limit
struct sht30_handle_s sht30_handle_t
sht30 handle structure definition
uint8_t sht30_get_high_alert_limit(sht30_handle_t *handle, uint16_t *set, uint16_t *clear)
get high alert limit
uint8_t sht30_get_repeatability(sht30_handle_t *handle, sht30_repeatability_t *repeatability)
get the measurement repeatability
uint8_t sht30_get_serial_number(sht30_handle_t *handle, uint8_t sn[4])
get serial number
sht30_status_t
sht30 status enumeration definition
uint8_t sht30_clear_status(sht30_handle_t *handle)
clear the current status
uint8_t sht30_set_low_alert_limit(sht30_handle_t *handle, uint16_t set, uint16_t clear)
set low alert limit
uint8_t sht30_deinit(sht30_handle_t *handle)
close the chip
@ SHT30_RATE_4HZ
@ SHT30_RATE_10HZ
@ SHT30_RATE_2HZ
@ SHT30_RATE_0P5HZ
@ SHT30_RATE_1HZ
@ SHT30_REPEATABILITY_MEDIUM
@ SHT30_REPEATABILITY_LOW
@ SHT30_REPEATABILITY_HIGH
@ SHT30_BOOL_TRUE
@ SHT30_BOOL_FALSE
@ SHT30_ADDRESS_1
@ SHT30_ADDRESS_0
@ SHT30_STATUS_CHECKSUM_STATUS
@ SHT30_STATUS_ALERT_PENDING_STATUS
@ SHT30_STATUS_HEATER_ON
@ SHT30_STATUS_SYSTEM_RESET
@ SHT30_STATUS_HUMIDITY_ALERT
@ SHT30_STATUS_COMMAND_STATUS
@ SHT30_STATUS_TEMPERATURE_ALERT
uint8_t sht30_get_reg(sht30_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
get the chip register
uint8_t sht30_set_reg(sht30_handle_t *handle, uint16_t command)
set the chip register
sht30 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)
sht30 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]