LibDriver JED1XX
Loading...
Searching...
No Matches
driver_jed1xx_read_test.c
Go to the documentation of this file.
1
36
38
39static jed1xx_handle_t gs_handle;
40
50uint8_t jed1xx_read_test(jed1xx_type_t type, uint32_t times)
51{
52 uint8_t res;
53 uint32_t i;
54 uint16_t raw;
55 float ppm;
56 jed1xx_info_t info;
57
58 /* link interface function */
66
67 /* get jed1xx information */
68 res = jed1xx_info(&info);
69 if (res != 0)
70 {
71 jed1xx_interface_debug_print("jed1xx: get info failed.\n");
72
73 return 1;
74 }
75 else
76 {
77 /* print jed1xx information */
78 jed1xx_interface_debug_print("jed1xx: chip is %s.\n", info.chip_name);
79 jed1xx_interface_debug_print("jed1xx: manufacturer is %s.\n", info.manufacturer_name);
80 jed1xx_interface_debug_print("jed1xx: interface is %s.\n", info.interface);
81 jed1xx_interface_debug_print("jed1xx: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
82 jed1xx_interface_debug_print("jed1xx: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
83 jed1xx_interface_debug_print("jed1xx: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
84 jed1xx_interface_debug_print("jed1xx: max current is %0.2fmA.\n", info.max_current_ma);
85 jed1xx_interface_debug_print("jed1xx: max temperature is %0.1fC.\n", info.temperature_max);
86 jed1xx_interface_debug_print("jed1xx: min temperature is %0.1fC.\n", info.temperature_min);
87 }
88
89 /* start basic read test */
90 jed1xx_interface_debug_print("jed1xx: start read test.\n");
91
92 /* set type */
93 res = jed1xx_set_type(&gs_handle, type);
94 if (res != 0)
95 {
96 jed1xx_interface_debug_print("jed1xx: set type failed.\n");
97
98 return 1;
99 }
100
101 /* jed1xx init */
102 res = jed1xx_init(&gs_handle);
103 if (res != 0)
104 {
105 jed1xx_interface_debug_print("jed1xx: init failed.\n");
106
107 return 1;
108 }
109
110 /* delay 3000 ms for read */
112 for (i = 0; i < times; i++)
113 {
114 /* read data */
115 res = jed1xx_read(&gs_handle, &raw, &ppm);
116 if (res != 0)
117 {
118 jed1xx_interface_debug_print("jed1xx: read failed.\n");
119 (void)jed1xx_deinit(&gs_handle);
120
121 return 1;
122 }
123
124 /* print result */
125 jed1xx_interface_debug_print("jed1xx: output raw is 0x%04X.\n", raw);
126 jed1xx_interface_debug_print("jed1xx: output is %.01fppm.\n", ppm);
127
128 /* delay 3000 ms*/
130 }
131
132 /* finish basic read test and exit */
133 jed1xx_interface_debug_print("jed1xx: finish read test.\n");
134 (void)jed1xx_deinit(&gs_handle);
135
136 return 0;
137}
driver jed1xx read test header file
uint8_t jed1xx_deinit(jed1xx_handle_t *handle)
close the chip
struct jed1xx_handle_s jed1xx_handle_t
jed1xx handle structure definition
struct jed1xx_info_s jed1xx_info_t
jed1xx information structure definition
uint8_t jed1xx_set_type(jed1xx_handle_t *handle, jed1xx_type_t type)
set the chip type
uint8_t jed1xx_read(jed1xx_handle_t *handle, uint16_t *raw, float *ppm)
read data
jed1xx_type_t
jed1xx type enumeration definition
uint8_t jed1xx_info(jed1xx_info_t *info)
get chip's information
uint8_t jed1xx_init(jed1xx_handle_t *handle)
initialize the chip
uint8_t jed1xx_interface_iic_init(void)
interface iic bus init
void jed1xx_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t jed1xx_interface_iic_deinit(void)
interface iic bus deinit
void jed1xx_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t jed1xx_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t jed1xx_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t jed1xx_read_test(jed1xx_type_t type, uint32_t times)
read test
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]