LibDriver MAX44009
Loading...
Searching...
No Matches
driver_max44009.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MAX44009_H
38#define DRIVER_MAX44009_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
67
71typedef enum
72{
76
91
95typedef struct max44009_handle_s
96{
97 uint8_t iic_addr;
98 uint8_t (*iic_init)(void);
99 uint8_t (*iic_deinit)(void);
100 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
101 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
102 void (*delay_ms)(uint32_t ms);
103 void (*debug_print)(const char *const fmt, ...);
104 uint8_t inited;
106
122
126
133
140#define DRIVER_MAX44009_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
141
148#define DRIVER_MAX44009_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
149
156#define DRIVER_MAX44009_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
157
164#define DRIVER_MAX44009_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
165
172#define DRIVER_MAX44009_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
173
180#define DRIVER_MAX44009_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
181
188#define DRIVER_MAX44009_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
189
193
200
209uint8_t max44009_info(max44009_info_t *info);
210
221
232
243uint8_t max44009_init(max44009_handle_t *handle);
244
256uint8_t max44009_deinit(max44009_handle_t *handle);
257
270uint8_t max44009_read(max44009_handle_t *handle, uint16_t *raw, float *lux);
271
284
297
310
323
336
349
362
375
388
401
414
426uint8_t max44009_set_interrupt_high_threshold(max44009_handle_t *handle, uint8_t threshold);
427
439uint8_t max44009_get_interrupt_high_threshold(max44009_handle_t *handle, uint8_t *threshold);
440
452uint8_t max44009_set_interrupt_low_threshold(max44009_handle_t *handle, uint8_t threshold);
453
465uint8_t max44009_get_interrupt_low_threshold(max44009_handle_t *handle, uint8_t *threshold);
466
478uint8_t max44009_set_threshold_timer(max44009_handle_t *handle, uint8_t t);
479
491uint8_t max44009_get_threshold_timer(max44009_handle_t *handle, uint8_t *t);
492
504uint8_t max44009_threshold_convert_to_register(max44009_handle_t *handle, float lux, uint8_t *reg);
505
517uint8_t max44009_threshold_convert_to_data(max44009_handle_t *handle, uint8_t reg, float *lux);
518
530uint8_t max44009_timer_convert_to_register(max44009_handle_t *handle, float ms, uint8_t *reg);
531
543uint8_t max44009_timer_convert_to_data(max44009_handle_t *handle, uint8_t reg, float *ms);
544
548
555
569uint8_t max44009_set_reg(max44009_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
570
584uint8_t max44009_get_reg(max44009_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
585
589
593
594#ifdef __cplusplus
595}
596#endif
597
598#endif
uint8_t max44009_get_current_div_8(max44009_handle_t *handle, max44009_bool_t *enable)
get current div 8
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_get_interrupt(max44009_handle_t *handle, max44009_bool_t *enable)
get interrupt status
max44009_integration_time_t
max44009 integration time enumeration definition
uint8_t max44009_timer_convert_to_data(max44009_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to timer
uint8_t max44009_set_current_div_8(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable current div 8
uint8_t max44009_get_interrupt_status(max44009_handle_t *handle, max44009_bool_t *enable)
get interrupt status
uint8_t max44009_set_interrupt_high_threshold(max44009_handle_t *handle, uint8_t threshold)
set interrupt high threshold
uint8_t max44009_get_interrupt_high_threshold(max44009_handle_t *handle, uint8_t *threshold)
get interrupt high threshold
uint8_t max44009_get_addr_pin(max44009_handle_t *handle, max44009_address_t *addr_pin)
get the address pin
struct max44009_handle_s max44009_handle_t
max44009 handle structure definition
uint8_t max44009_threshold_convert_to_register(max44009_handle_t *handle, float lux, uint8_t *reg)
convert the threshold to the register raw data
uint8_t max44009_get_auto_range(max44009_handle_t *handle, max44009_bool_t *enable)
get auto range
uint8_t max44009_set_addr_pin(max44009_handle_t *handle, max44009_address_t addr_pin)
set the address pin
uint8_t max44009_get_threshold_timer(max44009_handle_t *handle, uint8_t *t)
get threshold timer
uint8_t max44009_set_interrupt_low_threshold(max44009_handle_t *handle, uint8_t threshold)
set interrupt low threshold
uint8_t max44009_info(max44009_info_t *info)
get chip's information
struct max44009_info_s max44009_info_t
max44009 information structure definition
uint8_t max44009_set_continuous_mode(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable continuous mode
uint8_t max44009_get_continuous_mode(max44009_handle_t *handle, max44009_bool_t *enable)
get continuous mode stauts
max44009_address_t
max44009 address enumeration definition
uint8_t max44009_threshold_convert_to_data(max44009_handle_t *handle, uint8_t reg, float *lux)
convert the register raw data to the threshold
uint8_t max44009_set_interrupt(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable interrupt
uint8_t max44009_get_integration_time(max44009_handle_t *handle, max44009_integration_time_t *t)
get integration time
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_get_interrupt_low_threshold(max44009_handle_t *handle, uint8_t *threshold)
get interrupt low threshold
uint8_t max44009_set_auto_range(max44009_handle_t *handle, max44009_bool_t enable)
enable or disable auto range
uint8_t max44009_set_threshold_timer(max44009_handle_t *handle, uint8_t t)
set threshold timer
max44009_bool_t
max44009 bool enumeration definition
uint8_t max44009_timer_convert_to_register(max44009_handle_t *handle, float ms, uint8_t *reg)
convert the timer to the register raw data
@ MAX44009_INTEGRATION_TIME_400MS
@ MAX44009_INTEGRATION_TIME_12P5MS
@ MAX44009_INTEGRATION_TIME_200MS
@ MAX44009_INTEGRATION_TIME_100MS
@ MAX44009_INTEGRATION_TIME_800MS
@ MAX44009_INTEGRATION_TIME_6P25MS
@ MAX44009_INTEGRATION_TIME_50MS
@ MAX44009_INTEGRATION_TIME_25MS
@ MAX44009_ADDRESS_0
@ MAX44009_ADDRESS_1
@ MAX44009_BOOL_TRUE
@ MAX44009_BOOL_FALSE
uint8_t max44009_set_reg(max44009_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t max44009_get_reg(max44009_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
max44009 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
max44009 information structure definition
char manufacturer_name[32]