LibDriver STTS22H
Loading...
Searching...
No Matches
driver_stts22h.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_STTS22H_H
38#define DRIVER_STTS22H_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
69
73typedef enum
74{
78
90
99
103typedef struct stts22h_handle_s
104{
105 uint8_t (*iic_init)(void);
106 uint8_t (*iic_deinit)(void);
107 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
108 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
109 void (*receive_callback)(uint8_t type);
110 void (*delay_ms)(uint32_t ms);
111 void (*debug_print)(const char *const fmt, ...);
112 uint8_t inited;
113 uint8_t iic_addr;
116
132
136
143
150#define DRIVER_STTS22H_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
151
158#define DRIVER_STTS22H_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
159
166#define DRIVER_STTS22H_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
167
174#define DRIVER_STTS22H_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
175
182#define DRIVER_STTS22H_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
183
190#define DRIVER_STTS22H_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
191
198#define DRIVER_STTS22H_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
199
206#define DRIVER_STTS22H_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
207
211
218
227uint8_t stts22h_info(stts22h_info_t *info);
228
239
250
262
274uint8_t stts22h_init(stts22h_handle_t *handle);
275
287uint8_t stts22h_deinit(stts22h_handle_t *handle);
288
302uint8_t stts22h_single_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg);
303
315
327
341uint8_t stts22h_continuous_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg);
342
354uint8_t stts22h_set_temperature_high_limit(stts22h_handle_t *handle, uint8_t raw);
355
367uint8_t stts22h_get_temperature_high_limit(stts22h_handle_t *handle, uint8_t *raw);
368
380uint8_t stts22h_set_temperature_low_limit(stts22h_handle_t *handle, uint8_t raw);
381
393uint8_t stts22h_get_temperature_low_limit(stts22h_handle_t *handle, uint8_t *raw);
394
407
420
433
446
459
472
485
498
510uint8_t stts22h_get_status(stts22h_handle_t *handle, uint8_t *status);
511
523uint8_t stts22h_temperature_convert_to_register(stts22h_handle_t *handle, float celsius_deg, uint8_t *reg);
524
536uint8_t stts22h_temperature_convert_to_data(stts22h_handle_t *handle, uint8_t reg, float *celsius_deg);
537
541
548
562uint8_t stts22h_set_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
563
577uint8_t stts22h_get_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
578
582
586
587#ifdef __cplusplus
588}
589#endif
590
591#endif
uint8_t stts22h_init(stts22h_handle_t *handle)
initialize the chip
uint8_t stts22h_set_temperature_low_limit(stts22h_handle_t *handle, uint8_t raw)
set temperature low limit
uint8_t stts22h_get_temperature_high_limit(stts22h_handle_t *handle, uint8_t *raw)
get temperature high limit
uint8_t stts22h_get_temperature_low_limit(stts22h_handle_t *handle, uint8_t *raw)
get temperature low limit
uint8_t stts22h_stop_continuous_read(stts22h_handle_t *handle)
stop the chip reading
uint8_t stts22h_get_status(stts22h_handle_t *handle, uint8_t *status)
get status
stts22h_status_t
stts22h status enumeration definition
uint8_t stts22h_get_addr_pin(stts22h_handle_t *handle, stts22h_address_t *addr_pin)
get the iic address pin
stts22h_bool_t
stts22h bool enumeration definition
uint8_t stts22h_set_iic_address_auto_increment(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable iic address auto increment
uint8_t stts22h_set_temperature_high_limit(stts22h_handle_t *handle, uint8_t raw)
set temperature high limit
struct stts22h_handle_s stts22h_handle_t
stts22h handle structure definition
uint8_t stts22h_get_disable_smbus_timeout(stts22h_handle_t *handle, stts22h_bool_t *enable)
get disable smbus timeout status
uint8_t stts22h_temperature_convert_to_data(stts22h_handle_t *handle, uint8_t reg, float *celsius_deg)
convert the register raw data to the temperature
uint8_t stts22h_set_addr_pin(stts22h_handle_t *handle, stts22h_address_t addr_pin)
set the iic address pin
uint8_t stts22h_set_output_data_rate(stts22h_handle_t *handle, stts22h_output_data_rate_t rate)
set output data rate
uint8_t stts22h_deinit(stts22h_handle_t *handle)
close the chip
uint8_t stts22h_get_iic_address_auto_increment(stts22h_handle_t *handle, stts22h_bool_t *enable)
get iic address auto increment status
uint8_t stts22h_get_block_data_update(stts22h_handle_t *handle, stts22h_bool_t *enable)
get block data update status
uint8_t stts22h_info(stts22h_info_t *info)
get chip's information
uint8_t stts22h_set_block_data_update(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable block data update
uint8_t stts22h_irq_handler(stts22h_handle_t *handle)
irq handler
uint8_t stts22h_set_disable_smbus_timeout(stts22h_handle_t *handle, stts22h_bool_t enable)
enable or disable disable smbus timeout
uint8_t stts22h_continuous_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg)
read data from the chip continuously
uint8_t stts22h_temperature_convert_to_register(stts22h_handle_t *handle, float celsius_deg, uint8_t *reg)
convert the temperature to the register raw data
stts22h_address_t
stts22h address enumeration definition
uint8_t stts22h_start_continuous_read(stts22h_handle_t *handle)
start the chip reading
uint8_t stts22h_single_read(stts22h_handle_t *handle, int16_t *raw, float *celsius_deg)
read data from the chip once
struct stts22h_info_s stts22h_info_t
stts22h information structure definition
uint8_t stts22h_get_output_data_rate(stts22h_handle_t *handle, stts22h_output_data_rate_t *rate)
get output data rate
stts22h_output_data_rate_t
stts22h output data rate enumeration definition
@ STTS22H_STATUS_OVER_HIGH_LIMIT
@ STTS22H_STATUS_UNDER_LOW_LIMIT
@ STTS22H_BOOL_TRUE
@ STTS22H_BOOL_FALSE
@ STTS22H_ADDRESS_VDD
@ STTS22H_ADDRESS_56K
@ STTS22H_ADDRESS_GND
@ STTS22H_ADDRESS_15K
@ STTS22H_OUTPUT_DATA_RATE_50HZ
@ STTS22H_OUTPUT_DATA_RATE_25HZ
@ STTS22H_OUTPUT_DATA_RATE_100HZ
@ STTS22H_OUTPUT_DATA_RATE_1HZ
@ STTS22H_OUTPUT_DATA_RATE_200HZ
uint8_t stts22h_get_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t stts22h_set_reg(stts22h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
stts22h handle structure definition
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
stts22h information structure definition
uint32_t driver_version
char manufacturer_name[32]