LibDriver MLX90614  1.0.0
MLX90614 full-featured driver
driver_mlx90614.h
Go to the documentation of this file.
1 
37 #ifndef DRIVER_MLX90614_H
38 #define DRIVER_MLX90614_H
39 
40 #include <stdio.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 #ifdef __cplusplus
45 extern "C"{
46 #endif
47 
62 typedef enum
63 {
66 
79 typedef enum
80 {
81  MLX90614_FLAG_EE_BUSY = (1 << 7),
82  MLX90614_FLAG_EE_DEAD = (1 << 5),
83  MLX90614_FLAG_INIT = (1 << 4),
85 
89 typedef enum
90 {
96 
100 typedef enum
101 {
110 
114 typedef enum
115 {
119 
123 typedef enum
124 {
128 
132 typedef enum
133 {
136 } mlx90614_ks_t;
137 
141 typedef enum
142 {
146 
150 typedef enum
151 {
161 
165 typedef enum
166 {
176 
189 typedef struct mlx90614_handle_s
190 {
191  uint8_t iic_addr;
192  uint8_t (*iic_init)(void);
193  uint8_t (*iic_deinit)(void);
194  uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
195  uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
196  void (*delay_ms)(uint32_t ms);
197  void (*debug_print)(const char *const fmt, ...);
198  uint8_t (*scl_write)(uint8_t v);
199  uint8_t (*sda_write)(uint8_t v);
200  uint8_t inited;
202 
206 typedef struct mlx90614_info_s
207 {
208  char chip_name[32];
209  char manufacturer_name[32];
210  char interface[8];
216  uint32_t driver_version;
218 
236 #define DRIVER_MLX90614_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
237 
244 #define DRIVER_MLX90614_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
245 
252 #define DRIVER_MLX90614_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
253 
260 #define DRIVER_MLX90614_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
261 
268 #define DRIVER_MLX90614_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
269 
276 #define DRIVER_MLX90614_LINK_SCL_WRITE(HANDLE, FUC) (HANDLE)->scl_write = FUC
277 
284 #define DRIVER_MLX90614_LINK_SDA_WRITE(HANDLE, FUC) (HANDLE)->sda_write = FUC
285 
292 #define DRIVER_MLX90614_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
293 
300 #define DRIVER_MLX90614_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
301 
321 uint8_t mlx90614_info(mlx90614_info_t *info);
322 
332 uint8_t mlx90614_set_addr(mlx90614_handle_t *handle, uint8_t addr);
333 
343 uint8_t mlx90614_get_addr(mlx90614_handle_t *handle, uint8_t *addr);
344 
355 uint8_t mlx90614_init(mlx90614_handle_t *handle);
356 
367 uint8_t mlx90614_deinit(mlx90614_handle_t *handle);
368 
382 uint8_t mlx90614_read_object1(mlx90614_handle_t *handle, uint16_t *raw, float *celsius);
383 
397 uint8_t mlx90614_read_object2(mlx90614_handle_t *handle, uint16_t *raw, float *celsius);
398 
411 uint8_t mlx90614_read_raw_ir_channel(mlx90614_handle_t *handle, uint16_t *channel_1, uint16_t *channel_2);
412 
425 uint8_t mlx90614_read_ambient(mlx90614_handle_t *handle, uint16_t *raw, float *celsius);
426 
442 uint8_t mlx90614_write_addr(mlx90614_handle_t *handle, uint8_t addr);
443 
455 uint8_t mlx90614_read_addr(mlx90614_handle_t *handle, uint8_t *addr);
456 
476 
489 
502 
514 uint8_t mlx90614_get_iir(mlx90614_handle_t *handle, mlx90614_iir_t *iir);
515 
528 
540 uint8_t mlx90614_get_mode(mlx90614_handle_t *handle, mlx90614_mode_t *mode);
541 
554 
567 
579 uint8_t mlx90614_set_ks(mlx90614_handle_t *handle, mlx90614_ks_t ks);
580 
592 uint8_t mlx90614_get_ks(mlx90614_handle_t *handle, mlx90614_ks_t *ks);
593 
606 
618 uint8_t mlx90614_get_kt2(mlx90614_handle_t *handle, mlx90614_kt2_t *kt2);
619 
632 
644 uint8_t mlx90614_get_gain(mlx90614_handle_t *handle, mlx90614_gain_t *gain);
645 
658 
671 
684 
697 
710 
722 uint8_t mlx90614_get_emissivity_correction_coefficient(mlx90614_handle_t *handle, uint16_t *value);
723 
738 
751 uint8_t mlx90614_emissivity_correction_coefficient_convert_to_data(mlx90614_handle_t *handle, uint16_t reg, double *s);
752 
764 uint8_t mlx90614_get_id(mlx90614_handle_t *handle, uint16_t id[4]);
765 
777 
789 
801 uint8_t mlx90614_get_flag(mlx90614_handle_t *handle, uint16_t *flag);
802 
814 
838 uint8_t mlx90614_set_reg(mlx90614_handle_t *handle, uint8_t reg, uint16_t data);
839 
852 uint8_t mlx90614_get_reg(mlx90614_handle_t *handle, uint8_t reg, uint16_t *data);
853 
862 #ifdef __cplusplus
863 }
864 #endif
865 
866 #endif
uint8_t mlx90614_set_gain(mlx90614_handle_t *handle, mlx90614_gain_t gain)
set the gain param
mlx90614_gain_t
mlx90614 gain enumeration definition
mlx90614_ir_sensor_t
mlx90614 ir sensor enumeration definition
mlx90614_ks_t
mlx90614 ks enumeration definition
uint8_t mlx90614_emissivity_correction_coefficient_convert_to_data(mlx90614_handle_t *handle, uint16_t reg, double *s)
emissivity correction coefficient convert to data
uint8_t mlx90614_set_fir_length(mlx90614_handle_t *handle, mlx90614_fir_length_t len)
set the ir sensor fir length
mlx90614_flag_t
mlx90614 flag enumeration definition
uint8_t mlx90614_get_emissivity_correction_coefficient(mlx90614_handle_t *handle, uint16_t *value)
get the emissivity correction coefficient
uint8_t mlx90614_set_repeat_sensor_test(mlx90614_handle_t *handle, mlx90614_bool_t enable)
enable or disable the repeat sensor test
uint8_t mlx90614_get_id(mlx90614_handle_t *handle, uint16_t id[4])
get the chip id
uint8_t mlx90614_get_mode(mlx90614_handle_t *handle, mlx90614_mode_t *mode)
get the mode
uint8_t mlx90614_set_mode(mlx90614_handle_t *handle, mlx90614_mode_t mode)
set the mode
uint8_t mlx90614_set_emissivity_correction_coefficient(mlx90614_handle_t *handle, uint16_t value)
set the emissivity correction coefficient
uint8_t mlx90614_get_kt2(mlx90614_handle_t *handle, mlx90614_kt2_t *kt2)
get the kt2 param
uint8_t mlx90614_get_sensor_test(mlx90614_handle_t *handle, mlx90614_bool_t *enable)
get the sensor test status
mlx90614_bool_t
mlx90614 bool enumeration definition
uint8_t mlx90614_get_flag(mlx90614_handle_t *handle, uint16_t *flag)
get the flag
uint8_t mlx90614_set_iir(mlx90614_handle_t *handle, mlx90614_iir_t iir)
set the iir param
uint8_t mlx90614_set_ir_sensor(mlx90614_handle_t *handle, mlx90614_ir_sensor_t sensor)
set the ir sensor mode
uint8_t mlx90614_get_gain(mlx90614_handle_t *handle, mlx90614_gain_t *gain)
get the gain param
uint8_t mlx90614_get_repeat_sensor_test(mlx90614_handle_t *handle, mlx90614_bool_t *enable)
get the repeat sensor test status
uint8_t mlx90614_get_iir(mlx90614_handle_t *handle, mlx90614_iir_t *iir)
get the iir param
uint8_t mlx90614_exit_sleep_mode(mlx90614_handle_t *handle)
exit from sleep mode
uint8_t mlx90614_set_ks(mlx90614_handle_t *handle, mlx90614_ks_t ks)
set the ks param
uint8_t mlx90614_get_ks(mlx90614_handle_t *handle, mlx90614_ks_t *ks)
get the ks param
mlx90614_mode_t
mlx90614 mode enumeration definition
uint8_t mlx90614_pwm_to_smbus(mlx90614_handle_t *handle)
change pwm mode to smbus mode
mlx90614_iir_t
mlx90614 iir enumeration definition
uint8_t mlx90614_get_ir_sensor(mlx90614_handle_t *handle, mlx90614_ir_sensor_t *sensor)
get the ir sensor mode
uint8_t mlx90614_set_kt2(mlx90614_handle_t *handle, mlx90614_kt2_t kt2)
set the kt2 param
uint8_t mlx90614_set_sensor_test(mlx90614_handle_t *handle, mlx90614_bool_t enable)
enable or disable the sensor test
uint8_t mlx90614_get_fir_length(mlx90614_handle_t *handle, mlx90614_fir_length_t *len)
get the ir sensor fir length
uint8_t mlx90614_enter_sleep_mode(mlx90614_handle_t *handle)
enter to sleep mode
mlx90614_kt2_t
mlx90614 kt2 enumeration definition
uint8_t mlx90614_emissivity_correction_coefficient_convert_to_register(mlx90614_handle_t *handle, double s, uint16_t *reg)
convert the emissivity correction coefficient to the register raw data
mlx90614_fir_length_t
mlx90614 fir length enumeration definition
@ MLX90614_GAIN_3
@ MLX90614_GAIN_25
@ MLX90614_GAIN_12P5
@ MLX90614_GAIN_1
@ MLX90614_GAIN_50
@ MLX90614_GAIN_6
@ MLX90614_GAIN_100
@ MLX90614_IR_SENSOR_SINGLE
@ MLX90614_IR_SENSOR_DUAL
@ MLX90614_KS_NEGATIVE
@ MLX90614_KS_POSITIVE
@ MLX90614_FLAG_INIT
@ MLX90614_FLAG_EE_BUSY
@ MLX90614_FLAG_EE_DEAD
@ MLX90614_BOOL_FALSE
@ MLX90614_BOOL_TRUE
@ MLX90614_MODE_TOBJ1_TOBJ2
@ MLX90614_MODE_TOBJ2
@ MLX90614_MODE_TA_TOBJ1
@ MLX90614_MODE_TA_TOBJ2
@ MLX90614_IIR_A1_0P25_B1_0P75
@ MLX90614_IIR_A1_0P571_B1_0P428
@ MLX90614_IIR_A1_0P5_B1_0P5
@ MLX90614_IIR_A1_0P166_B1_0P83
@ MLX90614_IIR_A1_0P8_B1_0P2
@ MLX90614_IIR_A1_0P666_B1_0P333
@ MLX90614_IIR_A1_0P125_B1_0P875
@ MLX90614_IIR_A1_1_B1_0
@ MLX90614_KT2_POSITIVE
@ MLX90614_KT2_NEGATIVE
@ MLX90614_FIR_LENGTH_16
@ MLX90614_FIR_LENGTH_64
@ MLX90614_FIR_LENGTH_128
@ MLX90614_FIR_LENGTH_1024
@ MLX90614_FIR_LENGTH_32
@ MLX90614_FIR_LENGTH_256
@ MLX90614_FIR_LENGTH_512
@ MLX90614_FIR_LENGTH_8
uint8_t mlx90614_read_raw_ir_channel(mlx90614_handle_t *handle, uint16_t *channel_1, uint16_t *channel_2)
read the ir channel raw data
uint8_t mlx90614_read_object1(mlx90614_handle_t *handle, uint16_t *raw, float *celsius)
read the object1
uint8_t mlx90614_info(mlx90614_info_t *info)
get chip information
uint8_t mlx90614_get_addr(mlx90614_handle_t *handle, uint8_t *addr)
get the address
uint8_t mlx90614_init(mlx90614_handle_t *handle)
initialize the chip
mlx90614_address_t
mlx90614 address enumeration definition
uint8_t mlx90614_set_addr(mlx90614_handle_t *handle, uint8_t addr)
set the address
uint8_t mlx90614_read_ambient(mlx90614_handle_t *handle, uint16_t *raw, float *celsius)
read the ambient
struct mlx90614_info_s mlx90614_info_t
mlx90614 information structure definition
uint8_t mlx90614_deinit(mlx90614_handle_t *handle)
close the chip
uint8_t mlx90614_read_object2(mlx90614_handle_t *handle, uint16_t *raw, float *celsius)
read the object2
struct mlx90614_handle_s mlx90614_handle_t
mlx90614 handle structure definition
@ MLX90614_ADDRESS_DEFAULT
uint8_t mlx90614_read_addr(mlx90614_handle_t *handle, uint8_t *addr)
read the address
uint8_t mlx90614_write_addr(mlx90614_handle_t *handle, uint8_t addr)
write the address
uint8_t mlx90614_get_reg(mlx90614_handle_t *handle, uint8_t reg, uint16_t *data)
get the chip register
uint8_t mlx90614_set_reg(mlx90614_handle_t *handle, uint8_t reg, uint16_t data)
set the chip register
mlx90614 handle structure definition
uint8_t(* sda_write)(uint8_t v)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* scl_write)(uint8_t v)
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)
mlx90614 information structure definition
uint32_t driver_version
char manufacturer_name[32]