LibDriver TCS34725
Loading...
Searching...
No Matches
driver_tcs34725_basic.c
Go to the documentation of this file.
1
37
39
40static tcs34725_handle_t gs_handle;
41
50{
51 uint8_t res;
52
53 /* link interface function */
61
62 /* tcs34725 init */
63 res = tcs34725_init(&gs_handle);
64 if (res != 0)
65 {
66 tcs34725_interface_debug_print("tcs34725: init failed.\n");
67
68 return 1;
69 }
70
71 /* set rgbc interrupt */
73 if (res != 0)
74 {
75 tcs34725_interface_debug_print("tcs34725: set rgbc interrupt failed.\n");
76 (void)tcs34725_deinit(&gs_handle);
77
78 return 1;
79 }
80
81 /* set wait */
83 if (res != 0)
84 {
85 tcs34725_interface_debug_print("tcs34725: set wait failed.\n");
86 (void)tcs34725_deinit(&gs_handle);
87
88 return 1;
89 }
90
91 /* set rgbc */
93 if (res != 0)
94 {
95 tcs34725_interface_debug_print("tcs34725: set rgbc failed.\n");
96 (void)tcs34725_deinit(&gs_handle);
97
98 return 1;
99 }
100
101 /* set rgbc integration time */
103 if (res != 0)
104 {
105 tcs34725_interface_debug_print("tcs34725: set rgbc integration time failed.\n");
106 (void)tcs34725_deinit(&gs_handle);
107
108 return 1;
109 }
110
111 /* set wait time */
113 if (res != 0)
114 {
115 tcs34725_interface_debug_print("tcs34725: set wait time failed.\n");
116 (void)tcs34725_deinit(&gs_handle);
117
118 return 1;
119 }
120
121 /* set rgbc clear low interrupt threshold */
123 if (res != 0)
124 {
125 tcs34725_interface_debug_print("tcs34725: set rgbc clear low interrupt threshold failed.\n");
126 (void)tcs34725_deinit(&gs_handle);
127
128 return 1;
129 }
130
131 /* set rgbc clear high interrupt threshold */
133 if (res != 0)
134 {
135 tcs34725_interface_debug_print("tcs34725: set rgbc clear high interrupt threshold failed.\n");
136 (void)tcs34725_deinit(&gs_handle);
137
138 return 1;
139 }
140
141 /* set gain */
143 if (res != 0)
144 {
145 tcs34725_interface_debug_print("tcs34725: set gain failed.\n");
146 (void)tcs34725_deinit(&gs_handle);
147
148 return 1;
149 }
150
151 /* set interrupt mode */
153 if (res != 0)
154 {
155 tcs34725_interface_debug_print("tcs34725: set interrupt mode failed.\n");
156 (void)tcs34725_deinit(&gs_handle);
157
158 return 1;
159 }
160
161 /* set power on */
163 if (res != 0)
164 {
165 tcs34725_interface_debug_print("tcs34725: set power on failed.\n");
166 (void)tcs34725_deinit(&gs_handle);
167
168 return 1;
169 }
170
171 return 0;
172}
173
185uint8_t tcs34725_basic_read(uint16_t *red, uint16_t *green, uint16_t *blue, uint16_t *clear)
186{
187 /* read data */
188 if (tcs34725_read_rgbc(&gs_handle, red, green, blue, clear) != 0)
189 {
190 return 1;
191 }
192 else
193 {
194 return 0;
195 }
196}
197
206{
207 /* tcs34725 deinit */
208 if (tcs34725_deinit(&gs_handle) != 0)
209 {
210 return 1;
211 }
212 else
213 {
214 return 0;
215 }
216}
driver tcs34725 basic header file
uint8_t tcs34725_set_rgbc_integration_time(tcs34725_handle_t *handle, tcs34725_integration_time_t t)
set the rgbc adc integration time
uint8_t tcs34725_deinit(tcs34725_handle_t *handle)
close the chip
uint8_t tcs34725_set_gain(tcs34725_handle_t *handle, tcs34725_gain_t gain)
set the adc gain
uint8_t tcs34725_set_rgbc(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the rgbc adc
uint8_t tcs34725_set_wait_time(tcs34725_handle_t *handle, tcs34725_wait_time_t t)
set the wait time
uint8_t tcs34725_set_power_on(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the power
struct tcs34725_handle_s tcs34725_handle_t
tcs34725 handle structure definition
uint8_t tcs34725_init(tcs34725_handle_t *handle)
initialize the chip
uint8_t tcs34725_read_rgbc(tcs34725_handle_t *handle, uint16_t *red, uint16_t *green, uint16_t *blue, uint16_t *clear)
read the rgbc data
uint8_t tcs34725_set_wait(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the wait time
#define TCS34725_BASIC_DEFAULT_WAIT
#define TCS34725_BASIC_DEFAULT_INTEGRATION_TIME
uint8_t tcs34725_basic_deinit(void)
basic example deinit
#define TCS34725_BASIC_DEFAULT_CLEAR_LOW_INTERRUPT_THRESHOLD
#define TCS34725_BASIC_DEFAULT_RGBC
uint8_t tcs34725_basic_init(void)
basic example init
#define TCS34725_BASIC_DEFAULT_INTERRUPT_MODE
#define TCS34725_BASIC_DEFAULT_CLEAR_HIGH_INTERRUPT_THRESHOLD
#define TCS34725_BASIC_DEFAULT_POWER_ON
#define TCS34725_BASIC_DEFAULT_RGBC_INTERRUPT
tcs34725 basic example default definition
#define TCS34725_BASIC_DEFAULT_WAIT_TIME
uint8_t tcs34725_basic_read(uint16_t *red, uint16_t *green, uint16_t *blue, uint16_t *clear)
basic example read
#define TCS34725_BASIC_DEFAULT_GAIN
void tcs34725_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t tcs34725_interface_iic_init(void)
interface iic bus init
uint8_t tcs34725_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t tcs34725_interface_iic_deinit(void)
interface iic bus deinit
uint8_t tcs34725_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void tcs34725_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t tcs34725_set_rgbc_clear_high_interrupt_threshold(tcs34725_handle_t *handle, uint16_t threshold)
set the rgbc clear high interrupt threshold
uint8_t tcs34725_set_rgbc_interrupt(tcs34725_handle_t *handle, tcs34725_bool_t enable)
enable or disable the rgbc interrupt
uint8_t tcs34725_set_rgbc_clear_low_interrupt_threshold(tcs34725_handle_t *handle, uint16_t threshold)
set the rgbc clear low interrupt threshold
uint8_t tcs34725_set_interrupt_mode(tcs34725_handle_t *handle, tcs34725_interrupt_mode_t mode)
set the interrupt mode