LibDriver STS3X
Loading...
Searching...
No Matches
driver_sts3x_shot.c
Go to the documentation of this file.
1
36
37#include "driver_sts3x_shot.h"
38
39static sts3x_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link functions */
61
62 /* set addr pin */
63 res = sts3x_set_addr_pin(&gs_handle, addr_pin);
64 if (res != 0)
65 {
66 sts3x_interface_debug_print("sts3x: set addr pin failed.\n");
67
68 return 1;
69 }
70
71 /* sts3x init */
72 res = sts3x_init(&gs_handle);
73 if (res != 0)
74 {
75 sts3x_interface_debug_print("sts3x: init failed.\n");
76
77 return 1;
78 }
79
80 /* set default repeatability */
82 if (res != 0)
83 {
84 sts3x_interface_debug_print("sts3x: set repeatability failed.\n");
85 (void)sts3x_deinit(&gs_handle);
86
87 return 1;
88 }
89
90 /* wait 10 ms */
92
93 /* set default heater */
95 if (res != 0)
96 {
97 sts3x_interface_debug_print("sts3x: set heater failed.\n");
98 (void)sts3x_deinit(&gs_handle);
99
100 return 1;
101 }
102
103 return 0;
104}
105
114uint8_t sts3x_shot_read(float *temperature)
115{
116 uint16_t temperature_raw;
117
118 /* read data */
119 if (sts3x_single_read(&gs_handle, STS3X_SHOT_DEFAULT_CLOCK_STRETCHING, (uint16_t *)&temperature_raw, temperature) != 0)
120 {
121 return 1;
122 }
123
124 return 0;
125}
126
134uint8_t sts3x_shot_deinit(void)
135{
136 /* close sts3x */
137 if (sts3x_deinit(&gs_handle) != 0)
138 {
139 return 1;
140 }
141
142 return 0;
143}
driver sts3x shot header file
uint8_t sts3x_set_addr_pin(sts3x_handle_t *handle, sts3x_address_t addr_pin)
set the iic address pin
sts3x_address_t
sts3x address enumeration definition
uint8_t sts3x_set_repeatability(sts3x_handle_t *handle, sts3x_repeatability_t repeatability)
set the measurement repeatability
struct sts3x_handle_s sts3x_handle_t
sts3x handle structure definition
uint8_t sts3x_init(sts3x_handle_t *handle)
initialize the chip
uint8_t sts3x_set_heater(sts3x_handle_t *handle, sts3x_bool_t enable)
enable or disable the chip heater
uint8_t sts3x_deinit(sts3x_handle_t *handle)
close the chip
uint8_t sts3x_single_read(sts3x_handle_t *handle, sts3x_bool_t clock_stretching_enable, uint16_t *temperature_raw, float *temperature_s)
read data once
#define STS3X_SHOT_DEFAULT_HEATER
uint8_t sts3x_shot_read(float *temperature)
shot example read
#define STS3X_SHOT_DEFAULT_CLOCK_STRETCHING
sts3x shot example default definition
#define STS3X_SHOT_DEFAULT_REPEATABILITY
uint8_t sts3x_shot_init(sts3x_address_t addr_pin)
shot example init
uint8_t sts3x_shot_deinit(void)
shot example deinit
void sts3x_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t sts3x_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 sts3x_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t sts3x_interface_iic_deinit(void)
interface iic bus deinit
uint8_t sts3x_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
uint8_t sts3x_interface_iic_init(void)
interface iic bus init