LibDriver JED1XX
Loading...
Searching...
No Matches
driver_jed1xx_basic.c
Go to the documentation of this file.
1
36
37#include "driver_jed1xx_basic.h"
38
39static jed1xx_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link interface function */
61
62 /* set type */
63 res = jed1xx_set_type(&gs_handle, type);
64 if (res != 0)
65 {
66 jed1xx_interface_debug_print("jed1xx: set type failed.\n");
67
68 return 1;
69 }
70
71 /* jed1xx init */
72 res = jed1xx_init(&gs_handle);
73 if (res != 0)
74 {
75 jed1xx_interface_debug_print("jed1xx: init failed.\n");
76
77 return 1;
78 }
79
80 return 0;
81}
82
91uint8_t jed1xx_basic_read(float *ppm)
92{
93 uint16_t raw;
94
95 /* read */
96 if (jed1xx_read(&gs_handle, &raw, ppm) != 0)
97 {
98 return 1;
99 }
100
101 return 0;
102}
103
112{
113 /* deinit jed1xx and close bus */
114 if (jed1xx_deinit(&gs_handle) != 0)
115 {
116 return 1;
117 }
118
119 return 0;
120}
driver jed1xx basic header file
uint8_t jed1xx_deinit(jed1xx_handle_t *handle)
close the chip
struct jed1xx_handle_s jed1xx_handle_t
jed1xx handle 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_init(jed1xx_handle_t *handle)
initialize the chip
uint8_t jed1xx_basic_read(float *ppm)
basic example read
uint8_t jed1xx_basic_deinit(void)
basic example deinit
uint8_t jed1xx_basic_init(jed1xx_type_t type)
basic example init
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