LibDriver MAX44009
Loading...
Searching...
No Matches
driver_max44009_basic.c
Go to the documentation of this file.
1
36
38
39static max44009_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link interface function */
61
62 /* set addr pin */
63 res = max44009_set_addr_pin(&gs_handle, addr_pin);
64 if (res != 0)
65 {
66 max44009_interface_debug_print("max44009: set addr pin test.\n");
67
68 return 1;
69 }
70
71 /* init */
72 res = max44009_init(&gs_handle);
73 if (res != 0)
74 {
75 max44009_interface_debug_print("max44009: init failed.\n");
76
77 return 1;
78 }
79
80 /* set default auto range */
82 if (res != 0)
83 {
84 max44009_interface_debug_print("max44009: set auto range failed.\n");
85 (void)max44009_deinit(&gs_handle);
86
87 return 1;
88 }
89
90 /* set default continuous mode */
92 if (res != 0)
93 {
94 max44009_interface_debug_print("max44009: set continuous mode failed.\n");
95 (void)max44009_deinit(&gs_handle);
96
97 return 1;
98 }
99
100#if (MAX44009_BASIC_DEFAULT_AUTO_RANGE != MAX44009_BOOL_FALSE)
101 /* set default current div 8 */
103 if (res != 0)
104 {
105 max44009_interface_debug_print("max44009: set current div 8 failed.\n");
106 (void)max44009_deinit(&gs_handle);
107
108 return 1;
109 }
110
111 /* set default integration time */
113 if (res != 0)
114 {
115 max44009_interface_debug_print("max44009: set integration time failed.\n");
116 (void)max44009_deinit(&gs_handle);
117
118 return 1;
119 }
120#endif
121
122 /* disable interrupt */
124 if (res != 0)
125 {
126 max44009_interface_debug_print("max44009: set interrupt failed.\n");
127 (void)max44009_deinit(&gs_handle);
128
129 return 1;
130 }
131
132 return 0;
133}
134
143uint8_t max44009_basic_read(float *lux)
144{
145 uint8_t res;
146 uint16_t raw;
147
148 /* read */
149 res = max44009_read(&gs_handle, &raw, lux);
150 if (res != 0)
151 {
152 return 1;
153 }
154
155 return 0;
156}
157
166{
167 uint8_t res;
168
169 /* deinit */
170 res = max44009_deinit(&gs_handle);
171 if (res != 0)
172 {
173 return 1;
174 }
175
176 return 0;
177}
driver max44009 basic header file
uint8_t max44009_read(max44009_handle_t *handle, uint16_t *raw, float *lux)
read data
uint8_t max44009_set_integration_time(max44009_handle_t *handle, max44009_integration_time_t t)
set integration time
uint8_t max44009_set_current_div_8(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable current div 8
struct max44009_handle_s max44009_handle_t
max44009 handle structure definition
uint8_t max44009_set_addr_pin(max44009_handle_t *handle, max44009_address_t addr_pin)
set the address pin
uint8_t max44009_set_continuous_mode(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable continuous mode
max44009_address_t
max44009 address enumeration definition
uint8_t max44009_set_interrupt(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable interrupt
uint8_t max44009_deinit(max44009_handle_t *handle)
close the chip
uint8_t max44009_init(max44009_handle_t *handle)
initialize the chip
uint8_t max44009_set_auto_range(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable auto range
@ MAX44009_BOOL_FALSE
uint8_t max44009_basic_init(max44009_address_t addr_pin)
basic example init
uint8_t max44009_basic_read(float *lux)
basic example read
#define MAX44009_BASIC_DEFAULT_CURRENT_DIV_8
uint8_t max44009_basic_deinit(void)
basic example deinit
#define MAX44009_BASIC_DEFAULT_AUTO_RANGE
max44009 basic example default definition
#define MAX44009_BASIC_DEFAULT_CONTINUOUS_MODE
#define MAX44009_BASIC_DEFAULT_INTEGRATION_TIME
void max44009_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t max44009_interface_iic_init(void)
interface iic bus init
uint8_t max44009_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t max44009_interface_iic_deinit(void)
interface iic bus deinit
uint8_t max44009_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void max44009_interface_delay_ms(uint32_t ms)
interface delay ms