LibDriver MLX90614
Loading...
Searching...
No Matches
driver_mlx90614_basic.c
Go to the documentation of this file.
1
36
38
39static mlx90614_handle_t gs_handle;
40
49{
50 uint8_t res;
51
52 /* link interface function */
62
63 /* set address */
65 if (res != 0)
66 {
67 mlx90614_interface_debug_print("mlx90614: set addr failed.\n");
68
69 return 1;
70 }
71
72 /* mlx90614 init */
73 res = mlx90614_init(&gs_handle);
74 if (res != 0)
75 {
76 mlx90614_interface_debug_print("mlx90614: init failed.\n");
77
78 return 1;
79 }
80
81 /* pwm to smbus */
82 res = mlx90614_pwm_to_smbus(&gs_handle);
83 if (res != 0)
84 {
85 mlx90614_interface_debug_print("mlx90614: pwm to smbus failed.\n");
86 (void)mlx90614_deinit(&gs_handle);
87
88 return 1;
89 }
90
91 /* exit sleep mode */
92 res = mlx90614_exit_sleep_mode(&gs_handle);
93 if (res != 0)
94 {
95 mlx90614_interface_debug_print("mlx90614: exit sleep mode failed.\n");
96 (void)mlx90614_deinit(&gs_handle);
97
98 return 1;
99 }
100
101 return 0;
102}
103
112{
113 uint8_t res;
114
115 /* deinit */
116 res = mlx90614_deinit(&gs_handle);
117 if (res != 0)
118 {
119 return 1;
120 }
121 else
122 {
123 return 0;
124 }
125}
126
136uint8_t mlx90614_basic_read(float *ambient, float *object)
137{
138 uint8_t res;
139 uint16_t raw;
140
141 /* read ambient */
142 res = mlx90614_read_ambient(&gs_handle, (uint16_t *)&raw, ambient);
143 if (res != 0)
144 {
145 return 1;
146 }
147
148 /* read object1 */
149 res = mlx90614_read_object1(&gs_handle, (uint16_t *)&raw, object);
150 if (res != 0)
151 {
152 return 1;
153 }
154
155 return 0;
156}
driver mlx90614 basic header file
uint8_t mlx90614_exit_sleep_mode(mlx90614_handle_t *handle)
exit from sleep mode
uint8_t mlx90614_pwm_to_smbus(mlx90614_handle_t *handle)
change pwm mode to smbus mode
uint8_t mlx90614_read_object1(mlx90614_handle_t *handle, uint16_t *raw, float *celsius)
read the object1
uint8_t mlx90614_init(mlx90614_handle_t *handle)
initialize the chip
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
uint8_t mlx90614_deinit(mlx90614_handle_t *handle)
close the chip
struct mlx90614_handle_s mlx90614_handle_t
mlx90614 handle structure definition
@ MLX90614_ADDRESS_DEFAULT
uint8_t mlx90614_basic_init(void)
basic example init
uint8_t mlx90614_basic_deinit(void)
basic example deinit
uint8_t mlx90614_basic_read(float *ambient, float *object)
basic example read
uint8_t mlx90614_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t mlx90614_interface_iic_init(void)
interface iic bus init
void mlx90614_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t mlx90614_interface_iic_deinit(void)
interface iic bus deinit
uint8_t mlx90614_interface_sda_write(uint8_t value)
interface sda write
uint8_t mlx90614_interface_scl_write(uint8_t value)
interface scl write
uint8_t mlx90614_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void mlx90614_interface_debug_print(const char *const fmt,...)
interface print format data