LibDriver SHT30
Loading...
Searching...
No Matches
driver_sht30_shot.c
Go to the documentation of this file.
1
37
38#include "driver_sht30_shot.h"
39
40static sht30_handle_t gs_handle;
41
51{
52 uint8_t res;
53
54 /* link functions */
63
64 /* set addr pin */
65 res = sht30_set_addr_pin(&gs_handle, addr_pin);
66 if (res != 0)
67 {
68 sht30_interface_debug_print("sht30: set addr pin failed.\n");
69
70 return 1;
71 }
72
73 /* sht30 init */
74 res = sht30_init(&gs_handle);
75 if (res != 0)
76 {
77 sht30_interface_debug_print("sht30: init failed.\n");
78
79 return 1;
80 }
81
82 /* wait 10 ms */
84
85 /* set default repeatability */
87 if (res != 0)
88 {
89 sht30_interface_debug_print("sht30: set repeatability failed.\n");
90 (void)sht30_deinit(&gs_handle);
91
92 return 1;
93 }
94
95 /* set art */
96 res = sht30_set_art(&gs_handle);
97 if (res != 0)
98 {
99 sht30_interface_debug_print("sht30: set art failed.\n");
100 (void)sht30_deinit(&gs_handle);
101
102 return 1;
103 }
104
105 /* wait 10 ms */
107
108 /* set default heater */
110 if (res != 0)
111 {
112 sht30_interface_debug_print("sht30: set heater failed.\n");
113 (void)sht30_deinit(&gs_handle);
114
115 return 1;
116 }
117
118 return 0;
119}
120
130uint8_t sht30_shot_read(float *temperature, float *humidity)
131{
132 uint16_t temperature_raw;
133 uint16_t humidity_raw;
134
135 /* read data */
136 if (sht30_single_read(&gs_handle, SHT30_SHOT_DEFAULT_CLOCK_STRETCHING, (uint16_t *)&temperature_raw, temperature,
137 (uint16_t *)&humidity_raw, humidity) != 0)
138 {
139 return 1;
140 }
141
142 return 0;
143}
144
152uint8_t sht30_shot_deinit(void)
153{
154 /* close sht30 */
155 if (sht30_deinit(&gs_handle) != 0)
156 {
157 return 1;
158 }
159
160 return 0;
161}
162
171uint8_t sht30_shot_get_serial_number(uint8_t sn[4])
172{
173 /* get serial number */
174 if (sht30_get_serial_number(&gs_handle, sn) != 0)
175 {
176 return 1;
177 }
178
179 return 0;
180}
driver sht30 shot header file
uint8_t sht30_set_repeatability(sht30_handle_t *handle, sht30_repeatability_t repeatability)
set the measurement repeatability
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_set_art(sht30_handle_t *handle)
set the chip art
sht30_address_t
sht30 address enumeration definition
uint8_t sht30_set_heater(sht30_handle_t *handle, sht30_bool_t enable)
enable or disable the chip heater
uint8_t sht30_set_addr_pin(sht30_handle_t *handle, sht30_address_t addr_pin)
set the iic address pin
struct sht30_handle_s sht30_handle_t
sht30 handle structure definition
uint8_t sht30_get_serial_number(sht30_handle_t *handle, uint8_t sn[4])
get serial number
uint8_t sht30_deinit(sht30_handle_t *handle)
close the chip
uint8_t sht30_shot_deinit(void)
shot example deinit
uint8_t sht30_shot_get_serial_number(uint8_t sn[4])
shot example get serial number
uint8_t sht30_shot_init(sht30_address_t addr_pin)
shot example init
#define SHT30_SHOT_DEFAULT_REPEATABILITY
uint8_t sht30_shot_read(float *temperature, float *humidity)
shot example read
#define SHT30_SHOT_DEFAULT_CLOCK_STRETCHING
sht30 shot example default definition
#define SHT30_SHOT_DEFAULT_HEATER
uint8_t sht30_interface_iic_init(void)
interface iic bus init
uint8_t sht30_interface_iic_deinit(void)
interface iic bus deinit
void sht30_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t sht30_interface_iic_write_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
interface iic bus write with 16 bits register address
void sht30_interface_receive_callback(uint16_t type)
interface receive callback
void sht30_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t sht30_interface_iic_scl_read_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
interface iic bus read with 16 bits register address