LibDriver SHTC3
Loading...
Searching...
No Matches
driver_shtc3_register_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static shtc3_handle_t gs_handle;
41
50{
51 uint8_t res;
52 shtc3_info_t info;
53
54 /* link functions */
62
63 /* shtc3 info */
64 res = shtc3_info(&info);
65 if (res != 0)
66 {
67 shtc3_interface_debug_print("shtc3: get info failed.\n");
68
69 return 1;
70 }
71 else
72 {
73 /* print chip information */
74 shtc3_interface_debug_print("shtc3: chip is %s.\n", info.chip_name);
75 shtc3_interface_debug_print("shtc3: manufacturer is %s.\n", info.manufacturer_name);
76 shtc3_interface_debug_print("shtc3: interface is %s.\n", info.interface);
77 shtc3_interface_debug_print("shtc3: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
78 shtc3_interface_debug_print("shtc3: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
79 shtc3_interface_debug_print("shtc3: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
80 shtc3_interface_debug_print("shtc3: max current is %0.2fmA.\n", info.max_current_ma);
81 shtc3_interface_debug_print("shtc3: max temperature is %0.1fC.\n", info.temperature_max);
82 shtc3_interface_debug_print("shtc3: min temperature is %0.1fC.\n", info.temperature_min);
83 }
84
85 /* start register test */
86 shtc3_interface_debug_print("shtc3: start register test.\n");
87
88 /* shtc3 init */
89 res = shtc3_init(&gs_handle);
90 if (res != 0)
91 {
92 shtc3_interface_debug_print("shtc3: init failed.\n");
93
94 return 1;
95 }
96
97 /* shtc3_sleep test */
98 shtc3_interface_debug_print("shtc3: shtc3_sleep test.\n");
99
100 /* sleep */
101 res = shtc3_sleep(&gs_handle);
102 if (res != 0)
103 {
104 shtc3_interface_debug_print("shtc3: sleep failed.\n");
105 (void)shtc3_deinit(&gs_handle);
106
107 return 1;
108 }
109 shtc3_interface_debug_print("shtc3: sleep.\n");
110 shtc3_interface_debug_print("shtc3: check sleep %s.\n", (res == 0) ? "ok" : "error");
111
112 /* shtc3_wakeup test */
113 shtc3_interface_debug_print("shtc3: shtc3_wakeup test.\n");
114
115 /* wake up */
116 res = shtc3_wakeup(&gs_handle);
117 if (res != 0)
118 {
119 shtc3_interface_debug_print("shtc3: wakeup failed.\n");
120 (void)shtc3_deinit(&gs_handle);
121
122 return 1;
123 }
124 shtc3_interface_debug_print("shtc3: wakeup.\n");
125 shtc3_interface_debug_print("shtc3: check wakeup %s.\n", (res == 0) ? "ok" : "error");
126
127 /* shtc3_soft_reset test */
128 shtc3_interface_debug_print("shtc3: shtc3_soft_reset test.\n");
129
130 /* soft reset */
131 res = shtc3_soft_reset(&gs_handle);
132 if (res != 0)
133 {
134 shtc3_interface_debug_print("shtc3: soft reset failed.\n");
135 (void)shtc3_deinit(&gs_handle);
136
137 return 1;
138 }
139 shtc3_interface_debug_print("shtc3: soft reset.\n");
140 shtc3_interface_debug_print("shtc3: check soft reset %s.\n", (res == 0) ? "ok" : "error");
141
142 /* finish register test */
143 shtc3_interface_debug_print("shtc3: finish register test.\n");
144 (void)shtc3_deinit(&gs_handle);
145
146 return 0;
147}
driver shtc3 register test header file
uint8_t shtc3_init(shtc3_handle_t *handle)
initialize the chip
uint8_t shtc3_wakeup(shtc3_handle_t *handle)
wakeup
uint8_t shtc3_info(shtc3_info_t *info)
get chip's information
uint8_t shtc3_deinit(shtc3_handle_t *handle)
close the chip
uint8_t shtc3_soft_reset(shtc3_handle_t *handle)
soft reset the chip
struct shtc3_handle_s shtc3_handle_t
shtc3 handle structure definition
uint8_t shtc3_sleep(shtc3_handle_t *handle)
sleep
struct shtc3_info_s shtc3_info_t
shtc3 information structure definition
uint8_t shtc3_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
uint8_t shtc3_interface_iic_deinit(void)
interface iic bus deinit
uint8_t shtc3_interface_iic_init(void)
interface iic bus init
void shtc3_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t shtc3_interface_iic_read_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
interface iic bus read with 16 bits register address
void shtc3_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t shtc3_register_test(void)
register test
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]