LibDriver SHT4X
Loading...
Searching...
No Matches
driver_sht4x_basic.c
Go to the documentation of this file.
1
36
37#include "driver_sht4x_basic.h"
38
39static sht4x_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link functions */
61
62 /* set addr */
63 res = sht4x_set_addr(&gs_handle, addr);
64 if (res != 0)
65 {
66 sht4x_interface_debug_print("sht4x: set addr pin failed.\n");
67
68 return 1;
69 }
70
71 /* sht4x init */
72 res = sht4x_init(&gs_handle);
73 if (res != 0)
74 {
75 sht4x_interface_debug_print("sht4x: init failed.\n");
76
77 return 1;
78 }
79
80 return 0;
81}
82
92uint8_t sht4x_basic_read(float *temperature, float *humidity)
93{
94 uint16_t temperature_raw;
95 uint16_t humidity_raw;
96
97 /* read data */
99 (uint16_t *)&temperature_raw, temperature,
100 (uint16_t *)&humidity_raw, humidity) != 0)
101 {
102 return 1;
103 }
104
105 return 0;
106}
107
116{
117 /* close sht4x */
118 if (sht4x_deinit(&gs_handle) != 0)
119 {
120 return 1;
121 }
122
123 return 0;
124}
125
134uint8_t sht4x_basic_get_serial_number(uint8_t num[4])
135{
136 /* get serial number */
137 if (sht4x_get_serial_number(&gs_handle, num) != 0)
138 {
139 return 1;
140 }
141
142 return 0;
143}
driver sht4x basic header file
uint8_t sht4x_read(sht4x_handle_t *handle, sht4x_mode_t mode, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read temperature and humidity
struct sht4x_handle_s sht4x_handle_t
sht4x handle structure definition
uint8_t sht4x_get_serial_number(sht4x_handle_t *handle, uint8_t num[4])
get serial number
sht4x_address_t
sht4x address enumeration definition
uint8_t sht4x_set_addr(sht4x_handle_t *handle, sht4x_address_t addr)
set the iic address
uint8_t sht4x_init(sht4x_handle_t *handle)
initialize the chip
uint8_t sht4x_deinit(sht4x_handle_t *handle)
close the chip
uint8_t sht4x_basic_deinit(void)
basic example deinit
#define SHT4X_BASIC_DEFAULT_MODE
sht4x basic example default definition
uint8_t sht4x_basic_init(sht4x_address_t addr)
basic example init
uint8_t sht4x_basic_read(float *temperature, float *humidity)
basic example read
uint8_t sht4x_basic_get_serial_number(uint8_t num[4])
basic example get serial number
uint8_t sht4x_interface_iic_init(void)
interface iic bus init
void sht4x_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t sht4x_interface_iic_write_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus write command
uint8_t sht4x_interface_iic_read_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus read command
uint8_t sht4x_interface_iic_deinit(void)
interface iic bus deinit
void sht4x_interface_debug_print(const char *const fmt,...)
interface print format data