MLX90632 Driver Library  a258525c
Universal MCU library for the 90632
mlx90632.c
Go to the documentation of this file.
1 
28 #include <stdint.h>
29 #include <math.h>
30 #include <errno.h>
31 
32 #include "mlx90632.h"
33 #include "mlx90632_depends.h"
34 
35 #define POW10 10000000000LL
36 
37 #ifndef VERSION
38 #define VERSION "test"
39 #endif
40 
41 static const char mlx90632version[] __attribute__((used)) = { VERSION };
42 
43 #ifndef STATIC
44 #define STATIC static
45 #endif
46 
48 {
50  uint16_t reg_status;
51 
52  ret = mlx90632_i2c_read(MLX90632_REG_STATUS, &reg_status);
53  if (ret < 0)
54  return ret;
55 
57  if (ret < 0)
58  return ret;
59 
60  while (tries-- > 0)
61  {
62  ret = mlx90632_i2c_read(MLX90632_REG_STATUS, &reg_status);
63  if (ret < 0)
64  return ret;
65  if (reg_status & MLX90632_STAT_DATA_RDY)
66  break;
67  /* minimum wait time to complete measurement
68  * should be calculated according to refresh rate
69  * atm 10ms - 11ms
70  */
71  usleep(10000, 11000);
72  }
73 
74  if (tries < 0)
75  {
76  // data not ready
77  return -ETIMEDOUT;
78  }
79 
80  return (reg_status & MLX90632_STAT_CYCLE_POS) >> 2;
81 }
82 
97 STATIC int32_t mlx90632_channel_new_select(int32_t ret, uint8_t *channel_new, uint8_t *channel_old)
98 {
99  switch (ret)
100  {
101  case 1:
102  *channel_new = 1;
103  *channel_old = 2;
104  break;
105 
106  case 2:
107  *channel_new = 2;
108  *channel_old = 1;
109  break;
110 
111  default:
112  return -EINVAL;
113  }
114  return 0;
115 }
116 
130 STATIC int32_t mlx90632_read_temp_ambient_raw(int16_t *ambient_new_raw, int16_t *ambient_old_raw)
131 {
132  int32_t ret;
133  uint16_t read_tmp;
134 
135  ret = mlx90632_i2c_read(MLX90632_RAM_3(1), &read_tmp);
136  if (ret < 0)
137  return ret;
138  *ambient_new_raw = (int16_t)read_tmp;
139 
140  ret = mlx90632_i2c_read(MLX90632_RAM_3(2), &read_tmp);
141  if (ret < 0)
142  return ret;
143  *ambient_old_raw = (int16_t)read_tmp;
144 
145  return ret;
146 }
147 
162 STATIC int32_t mlx90632_read_temp_object_raw(int32_t start_measurement_ret,
163  int16_t *object_new_raw, int16_t *object_old_raw)
164 {
165  int32_t ret;
166  uint16_t read_tmp;
167  int16_t read;
168  uint8_t channel, channel_old;
169 
170  ret = mlx90632_channel_new_select(start_measurement_ret, &channel, &channel_old);
171  if (ret != 0)
172  return -EINVAL;
173 
174  ret = mlx90632_i2c_read(MLX90632_RAM_2(channel), &read_tmp);
175  if (ret < 0)
176  return ret;
177 
178  read = (int16_t)read_tmp;
179 
180  ret = mlx90632_i2c_read(MLX90632_RAM_1(channel), &read_tmp);
181  if (ret < 0)
182  return ret;
183  *object_new_raw = (read + (int16_t)read_tmp) / 2;
184 
185  ret = mlx90632_i2c_read(MLX90632_RAM_2(channel_old), &read_tmp);
186  if (ret < 0)
187  return ret;
188  read = (int16_t)read_tmp;
189 
190  ret = mlx90632_i2c_read(MLX90632_RAM_1(channel_old), &read_tmp);
191  if (ret < 0)
192  return ret;
193  *object_old_raw = (read + (int16_t)read_tmp) / 2;
194 
195  return ret;
196 }
197 
198 int32_t mlx90632_read_temp_raw(int16_t *ambient_new_raw, int16_t *ambient_old_raw,
199  int16_t *object_new_raw, int16_t *object_old_raw)
200 {
201  int32_t ret, start_measurement_ret;
202 
203  // trigger and wait for measurement to complete
204  start_measurement_ret = mlx90632_start_measurement();
205  if (start_measurement_ret < 0)
206  return start_measurement_ret;
207 
209  ret = mlx90632_read_temp_ambient_raw(ambient_new_raw, ambient_old_raw);
210  if (ret < 0)
211  return ret;
212 
214  ret = mlx90632_read_temp_object_raw(start_measurement_ret, object_new_raw, object_old_raw);
215 
216  return ret;
217 }
218 
219 int32_t mlx90632_read_temp_raw_burst(int16_t *ambient_new_raw, int16_t *ambient_old_raw,
220  int16_t *object_new_raw, int16_t *object_old_raw)
221 {
222  int32_t ret, start_measurement_ret;
223 
224  // trigger and wait for measurement to complete
225  start_measurement_ret = mlx90632_start_measurement_burst();
226  if (start_measurement_ret < 0)
227  return start_measurement_ret;
228 
230  ret = mlx90632_read_temp_ambient_raw(ambient_new_raw, ambient_old_raw);
231  if (ret < 0)
232  return ret;
233 
235  ret = mlx90632_read_temp_object_raw(2, object_new_raw, object_old_raw);
236 
237  return ret;
238 }
239 
240 
241 /* DSPv5 */
242 double mlx90632_preprocess_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
243 {
244  double VR_Ta, kGb;
245 
246  kGb = ((double)Gb) / 1024.0;
247 
248  VR_Ta = ambient_old_raw + kGb * (ambient_new_raw / (MLX90632_REF_3));
249  return ((ambient_new_raw / (MLX90632_REF_3)) / VR_Ta) * 524288.0;
250 }
251 
252 double mlx90632_preprocess_temp_object(int16_t object_new_raw, int16_t object_old_raw,
253  int16_t ambient_new_raw, int16_t ambient_old_raw,
254  int16_t Ka)
255 {
256  double VR_IR, kKa;
257 
258  kKa = ((double)Ka) / 1024.0;
259 
260  VR_IR = ambient_old_raw + kKa * (ambient_new_raw / (MLX90632_REF_3));
261  return ((((object_new_raw + object_old_raw) / 2) / (MLX90632_REF_12)) / VR_IR) * 524288.0;
262 }
263 
264 double mlx90632_calc_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int32_t P_T,
265  int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb)
266 {
267  double Asub, Bsub, Ablock, Bblock, Cblock, AMB;
268 
269  AMB = mlx90632_preprocess_temp_ambient(ambient_new_raw, ambient_old_raw, Gb);
270 
271  Asub = ((double)P_T) / (double)17592186044416.0;
272  Bsub = (double)AMB - ((double)P_R / (double)256.0);
273  Ablock = Asub * (Bsub * Bsub);
274  Bblock = (Bsub / (double)P_G) * (double)1048576.0;
275  Cblock = (double)P_O / (double)256.0;
276 
277  return Bblock + Ablock + Cblock;
278 }
279 
300 STATIC double mlx90632_calc_temp_object_iteration(double prev_object_temp, int32_t object, double TAdut,
301  int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb,
302  double emissivity)
303 {
304  double calcedGa, calcedGb, calcedFa, TAdut4, first_sqrt;
305  // temp variables
306  double KsTAtmp, Alpha_corr;
307  double Ha_customer, Hb_customer;
308 
309 
310  Ha_customer = Ha / ((double)16384.0);
311  Hb_customer = Hb / ((double)1024.0);
312  calcedGa = ((double)Ga * (prev_object_temp - 25)) / ((double)68719476736.0);
313  KsTAtmp = (double)Fb * (TAdut - 25);
314  calcedGb = KsTAtmp / ((double)68719476736.0);
315  Alpha_corr = (((double)(Fa * POW10)) * Ha_customer * (double)(1 + calcedGa + calcedGb)) /
316  ((double)70368744177664.0);
317  calcedFa = object / (emissivity * (Alpha_corr / POW10));
318  TAdut4 = (TAdut + 273.15) * (TAdut + 273.15) * (TAdut + 273.15) * (TAdut + 273.15);
319 
320  first_sqrt = sqrt(calcedFa + TAdut4);
321 
322  return sqrt(first_sqrt) - 273.15 - Hb_customer;
323 }
324 
348 STATIC double mlx90632_calc_temp_object_iteration_reflected(double prev_object_temp, int32_t object, double TAdut, double TaTr4,
349  int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb,
350  double emissivity)
351 {
352  double calcedGa, calcedGb, calcedFa, first_sqrt;
353  // temp variables
354  double KsTAtmp, Alpha_corr;
355  double Ha_customer, Hb_customer;
356 
357  Ha_customer = Ha / ((double)16384.0);
358  Hb_customer = Hb / ((double)1024.0);
359  calcedGa = ((double)Ga * (prev_object_temp - 25)) / ((double)68719476736.0);
360  KsTAtmp = (double)Fb * (TAdut - 25);
361  calcedGb = KsTAtmp / ((double)68719476736.0);
362  Alpha_corr = (((double)(Fa * POW10)) * Ha_customer * (double)(1 + calcedGa + calcedGb)) /
363  ((double)70368744177664.0);
364  calcedFa = object / (emissivity * (Alpha_corr / POW10));
365 
366  first_sqrt = sqrt(calcedFa + TaTr4);
367 
368  return sqrt(first_sqrt) - 273.15 - Hb_customer;
369 }
370 
371 static double emissivity = 0.0;
372 void mlx90632_set_emissivity(double value)
373 {
374  emissivity = value;
375 }
376 
378 {
379  if (emissivity == 0.0)
380  {
381  return 1.0;
382  }
383  else
384  {
385  return emissivity;
386  }
387 }
388 
389 double mlx90632_calc_temp_object(int32_t object, int32_t ambient,
390  int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
391  int16_t Ha, int16_t Hb)
392 {
393  double kEa, kEb, TAdut;
394  double temp = 25.0;
395  double tmp_emi = mlx90632_get_emissivity();
396  int8_t i;
397 
398  kEa = ((double)Ea) / ((double)65536.0);
399  kEb = ((double)Eb) / ((double)256.0);
400  TAdut = (((double)ambient) - kEb) / kEa + 25;
401 
402  //iterate through calculations
403  for (i = 0; i < 5; ++i)
404  {
405  temp = mlx90632_calc_temp_object_iteration(temp, object, TAdut, Ga, Fa, Fb, Ha, Hb, tmp_emi);
406  }
407  return temp;
408 }
409 
410 double mlx90632_calc_temp_object_reflected(int32_t object, int32_t ambient, double reflected,
411  int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
412  int16_t Ha, int16_t Hb)
413 {
414  double kEa, kEb, TAdut;
415  double temp = 25.0;
416  double tmp_emi = mlx90632_get_emissivity();
417  double TaTr4;
418  double ta4;
419  int8_t i;
420 
421  kEa = ((double)Ea) / ((double)65536.0);
422  kEb = ((double)Eb) / ((double)256.0);
423  TAdut = (((double)ambient) - kEb) / kEa + 25;
424 
425  TaTr4 = reflected + 273.15;
426  TaTr4 = TaTr4 * TaTr4;
427  TaTr4 = TaTr4 * TaTr4;
428  ta4 = TAdut + 273.15;
429  ta4 = ta4 * ta4;
430  ta4 = ta4 * ta4;
431  TaTr4 = TaTr4 - (TaTr4 - ta4) / tmp_emi;
432 
433  //iterate through calculations
434  for (i = 0; i < 5; ++i)
435  {
436  temp = mlx90632_calc_temp_object_iteration_reflected(temp, object, TAdut, TaTr4, Ga, Fa, Fb, Ha, Hb, tmp_emi);
437  }
438  return temp;
439 }
440 
441 int32_t mlx90632_init(void)
442 {
443  int32_t ret;
444  uint16_t eeprom_version, reg_status;
445 
446  ret = mlx90632_i2c_read(MLX90632_EE_VERSION, &eeprom_version);
447  if (ret < 0)
448  {
449  return ret;
450  }
451 
452  if ((eeprom_version & 0x00FF) != MLX90632_DSPv5)
453  {
454  // this here can fail because of big/little endian of cpu/i2c
455  return -EPROTONOSUPPORT;
456  }
457 
458  ret = mlx90632_i2c_read(MLX90632_REG_STATUS, &reg_status);
459  if (ret < 0)
460  return ret;
461 
462  // Prepare a clean start with setting NEW_DATA to 0
464  if (ret < 0)
465  return ret;
466 
467  if ((eeprom_version & 0x7F00) == MLX90632_XTD_RNG_KEY)
468  {
469  return ERANGE;
470  }
471 
472  return 0;
473 }
474 
476 {
477  int32_t ret;
478 
479  ret = mlx90632_i2c_write(0x3005, MLX90632_RESET_CMD);
480  if (ret < 0)
481  return ret;
482 
483  usleep(150, 200);
484 
485  return 0;
486 }
487 
488 int32_t mlx90632_get_measurement_time(uint16_t meas)
489 {
490  int32_t ret;
491  uint16_t reg;
492 
493  ret = mlx90632_i2c_read(meas, &reg);
494  if (ret < 0)
495  return ret;
496 
498  reg = reg >> 8;
499 
500  return MLX90632_MEAS_MAX_TIME >> reg;
501 }
502 
504 {
505  int32_t ret;
506  int32_t refresh_time;
507 
508  ret = mlx90632_get_meas_type();
509  if (ret < 0)
510  return ret;
511 
513  return -EINVAL;
514 
515  if (ret == MLX90632_MTYP_MEDICAL_BURST)
516  {
518  if (ret < 0)
519  return ret;
520 
521  refresh_time = ret;
522 
524  if (ret < 0)
525  return ret;
526 
527  refresh_time = refresh_time + ret;
528  }
529  else
530  {
532  if (ret < 0)
533  return ret;
534 
535  refresh_time = ret;
536 
538  if (ret < 0)
539  return ret;
540 
541  refresh_time = refresh_time + ret;
542 
544  if (ret < 0)
545  return ret;
546 
547  refresh_time = refresh_time + ret;
548  }
549 
550  return refresh_time;
551 }
552 
554 {
555  int32_t ret;
557  uint16_t reg;
558 
560  if (ret < 0)
561  return ret;
562 
564 
566  if (ret < 0)
567  return ret;
568 
570  if (ret < 0)
571  return ret;
572  msleep(ret); /* Waiting for refresh of all the measurement tables */
573 
574  while (tries-- > 0)
575  {
577  if (ret < 0)
578  return ret;
579  if ((reg & MLX90632_STAT_BUSY) == 0)
580  break;
581  /* minimum wait time to complete measurement
582  * should be calculated according to refresh rate
583  * atm 10ms - 11ms
584  */
585  usleep(10000, 11000);
586  }
587 
588  if (tries < 0)
589  {
590  // data not ready
591  return -ETIMEDOUT;
592  }
593 
594  return 0;
595 }
596 
597 
599 {
601 }
602 
604 {
605  uint16_t reg_status;
606  int32_t ret = mlx90632_i2c_read(MLX90632_REG_STATUS, &reg_status);
607 
608  while (ret >= 0 && reg_status & MLX90632_STAT_EE_BUSY)
609  {
610  ret = mlx90632_i2c_read(MLX90632_REG_STATUS, &reg_status);
611  }
612 
613  return ret;
614 }
615 
616 STATIC int32_t mlx90632_erase_eeprom(uint16_t address)
617 {
618  int32_t ret = mlx90632_unlock_eeporm();
619 
620  if (ret < 0)
621  return ret;
622 
623  ret = mlx90632_i2c_write(address, 0x00);
624  if (ret < 0)
625  return ret;
626 
628  return ret;
629 }
630 
631 STATIC int32_t mlx90632_write_eeprom(uint16_t address, uint16_t data)
632 {
633  int32_t ret = mlx90632_erase_eeprom(address);
634 
635  if (ret < 0)
636  return ret;
637 
638  ret = mlx90632_unlock_eeporm();
639  if (ret < 0)
640  return ret;
641 
642  ret = mlx90632_i2c_write(address, data);
643  if (ret < 0)
644  return ret;
645 
647  return ret;
648 }
649 
651 {
652  uint16_t meas1, meas2;
653 
654  int32_t ret = mlx90632_i2c_read(MLX90632_EE_MEDICAL_MEAS1, &meas1);
655 
656  if (ret < 0)
657  return ret;
658 
660 
661  if (meas1 != new_value)
662  {
664  if (ret < 0)
665  return ret;
666  }
667 
669  if (ret < 0)
670  return ret;
671 
673  if (meas2 != new_value)
674  {
676  }
677 
678  return ret;
679 }
680 
682 {
683  int32_t ret;
684  uint16_t meas1;
685 
687  if (ret < 0)
688  return MLX90632_MEAS_HZ_ERROR;
689 
690  return MLX90632_REFRESH_RATE(meas1);
691 }
692 
int32_t mlx90632_read_temp_raw_burst(int16_t *ambient_new_raw, int16_t *ambient_old_raw, int16_t *object_new_raw, int16_t *object_old_raw)
Read raw ambient and object temperature in sleeping step mode.
Definition: mlx90632.c:219
#define MLX90632_EE_VERSION
EEPROM version reg - assumed 0x101.
Definition: mlx90632.h:87
#define MLX90632_MEAS_MAX_TIME
Maximum measurement time in ms for the lowest possible refresh rate.
Definition: mlx90632.h:204
mlx90632_meas_t mlx90632_get_refresh_rate(void)
Gets the value in MLX90632_EE_MEAS_1 and converts it to the appropriate MLX90632_MEAS enum...
Definition: mlx90632.c:681
#define MLX90632_EE_REFRESH_RATE_MASK
Refresh Rate Mask.
Definition: mlx90632.h:131
#define MLX90632_RAM_3(meas_num)
Definition: mlx90632.h:178
double mlx90632_preprocess_temp_object(int16_t object_new_raw, int16_t object_old_raw, int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Ka)
Calculation of raw object output.
Definition: mlx90632.c:252
STATIC int32_t mlx90632_unlock_eeporm()
Definition: mlx90632.c:598
#define MLX90632_RAM_1(meas_num)
Definition: mlx90632.h:176
int32_t mlx90632_i2c_read(int16_t register_address, uint16_t *value)
Read the register_address value from the mlx90632.
#define MLX90632_MTYP_MEDICAL_BURST
Definition: mlx90632.h:197
#define MLX90632_REF_3
ResCtrlRef value of Channel 3.
Definition: mlx90632.h:191
int32_t mlx90632_set_refresh_rate(mlx90632_meas_t measRate)
Sets the refresh rate of the sensor using the MLX90632_EE_MEAS_1 and MLX90632_EE_MEAS_2 registers...
Definition: mlx90632.c:650
#define VERSION
Definition: mlx90632.c:38
#define MLX90632_START_BURST_MEAS
Definition: mlx90632.h:164
#define EPROTONOSUPPORT
From linux errno.h.
Definition: mlx90632.h:52
int32_t mlx90632_init(void)
Initialize MLX90632 driver and confirm EEPROM version.
Definition: mlx90632.c:441
#define MLX90632_STAT_BUSY
Device busy indicator.
Definition: mlx90632.h:169
double mlx90632_calc_temp_object_reflected(int32_t object, int32_t ambient, double reflected, int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb)
Calculation of object temperature when the environment temperature differs from the sensor temperatur...
Definition: mlx90632.c:410
int32_t mlx90632_start_measurement_burst(void)
Trigger start of burst measurement for mlx90632.
Definition: mlx90632.c:553
STATIC int32_t mlx90632_wait_for_eeprom_not_busy()
Definition: mlx90632.c:603
#define MLX90632_RAM_2(meas_num)
Definition: mlx90632.h:177
void msleep(int msecs)
Blocking function for sleeping in milliseconds.
#define MLX90632_EE_MEDICAL_MEAS2
Medical measurement 2 16bit.
Definition: mlx90632.h:112
#define MLX90632_XTD_RNG_KEY
Definition: mlx90632.h:192
#define MLX90632_STAT_EE_BUSY
Device EEPROM busy indicator.
Definition: mlx90632.h:170
#define MLX90632_MAX_NUMBER_MESUREMENT_READ_TRIES
Maximum number of read tries before quiting with timeout error.
Definition: mlx90632.h:205
double mlx90632_calc_temp_object(int32_t object, int32_t ambient, int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb)
Calculation of object temperature.
Definition: mlx90632.c:389
#define MLX90632_EEPROM_WRITE_KEY
EEPROM write key 0x55 and 0x4c.
Definition: mlx90632.h:186
#define MLX90632_STAT_CYCLE_POS
Data position in measurement table.
Definition: mlx90632.h:172
#define MLX90632_NEW_REG_VALUE(old_reg, new_value, h, l)
Definition: mlx90632.h:210
#define MLX90632_EE_MEDICAL_MEAS1
Medical measurement 1 16bit.
Definition: mlx90632.h:111
#define MLX90632_EE_EXTENDED_MEAS3
Extended measurement 3 16bit.
Definition: mlx90632.h:115
STATIC int32_t mlx90632_channel_new_select(int32_t ret, uint8_t *channel_new, uint8_t *channel_old)
Based on mlx90632_start_measurement return value fill channel_new and channel_old variables with prop...
Definition: mlx90632.c:97
int32_t mlx90632_get_measurement_time(uint16_t meas)
Reads the refresh rate and calculates the time needed for a single measurment from the EEPROM setting...
Definition: mlx90632.c:488
int32_t mlx90632_read_temp_raw(int16_t *ambient_new_raw, int16_t *ambient_old_raw, int16_t *object_new_raw, int16_t *object_old_raw)
Read raw ambient and object temperature.
Definition: mlx90632.c:198
#define STATIC
Definition: mlx90632.c:44
STATIC int32_t mlx90632_write_eeprom(uint16_t address, uint16_t data)
Definition: mlx90632.c:631
static const char mlx90632version[]
Definition: mlx90632.c:41
STATIC int32_t mlx90632_erase_eeprom(uint16_t address)
Definition: mlx90632.c:616
#define MLX90632_MTYP_EXTENDED_BURST
Definition: mlx90632.h:198
double mlx90632_preprocess_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
Calculation of raw ambient output.
Definition: mlx90632.c:242
STATIC double mlx90632_calc_temp_object_iteration(double prev_object_temp, int32_t object, double TAdut, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb, double emissivity)
Iterative calculation of object temperature.
Definition: mlx90632.c:300
int32_t mlx90632_i2c_write(int16_t register_address, uint16_t value)
Write value to register_address of the mlx90632.
int32_t mlx90632_get_meas_type(void)
Get the current measurement type set in the MLX90632.
enum mlx90632_meas_e mlx90632_meas_t
#define ERANGE
From linux errno.h.
Definition: mlx90632.h:55
double mlx90632_calc_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int32_t P_T, int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb)
Calculation of ambient temperature.
Definition: mlx90632.c:264
#define MLX90632_REG_STATUS
Device status register.
Definition: mlx90632.h:168
#define MLX90632_EE_REFRESH_RATE_SHIFT
Refresh Rate shift.
Definition: mlx90632.h:130
MLX90632 driver with virtual i2c communication.
#define POW10
Definition: mlx90632.c:35
STATIC int32_t mlx90632_read_temp_ambient_raw(int16_t *ambient_new_raw, int16_t *ambient_old_raw)
Read ambient raw old and new values based on mlx90632_start_measurement return value.
Definition: mlx90632.c:130
MLX90632 driver dependencies.
#define MLX90632_REF_12
ResCtrlRef value of Channel 1 or Channel 2.
Definition: mlx90632.h:190
#define MLX90632_STAT_DATA_RDY
Data ready indicator.
Definition: mlx90632.h:173
int32_t mlx90632_calculate_dataset_ready_time(void)
Reads the refresh rate and calculates the time needed for a whole measurment table from the EEPROM se...
Definition: mlx90632.c:503
#define MLX90632_EE_EXTENDED_MEAS2
Extended measurement 2 16bit.
Definition: mlx90632.h:114
#define MLX90632_DSPv5
Definition: mlx90632.h:184
int32_t mlx90632_addressed_reset(void)
Trigger system reset for mlx90632.
Definition: mlx90632.c:475
void usleep(int min_range, int max_range)
Blocking function for sleeping in microseconds.
double mlx90632_get_emissivity(void)
Read value of emissivity.
Definition: mlx90632.c:377
#define EINVAL
From linux errno.h.
Definition: mlx90632.h:49
#define MLX90632_EE_EXTENDED_MEAS1
Extended measurement 1 16bit.
Definition: mlx90632.h:113
#define MLX90632_REG_CTRL
Control Register address.
Definition: mlx90632.h:140
STATIC double mlx90632_calc_temp_object_iteration_reflected(double prev_object_temp, int32_t object, double TAdut, double TaTr4, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb, double emissivity)
Iterative calculation of object temperature when the environment temperature differs from the sensor ...
Definition: mlx90632.c:348
#define MLX90632_EE_REFRESH_RATE_START
Refresh Rate Start bit.
Definition: mlx90632.h:129
#define MLX90632_RESET_CMD
Reset sensor (address or global)
Definition: mlx90632.h:187
#define MLX90632_REFRESH_RATE(ee_val)
Extract Refresh Rate from ee register.
Definition: mlx90632.h:133
static double emissivity
Definition: mlx90632.c:371
#define ETIMEDOUT
From linux errno.h.
Definition: mlx90632.h:46
void mlx90632_set_emissivity(double value)
Set emissivity which is retained in single variable.
Definition: mlx90632.c:372
int mlx90632_start_measurement(void)
Trigger start measurement for mlx90632.
Definition: mlx90632.c:47
STATIC int32_t mlx90632_read_temp_object_raw(int32_t start_measurement_ret, int16_t *object_new_raw, int16_t *object_old_raw)
Read object raw old and new values based on mlx90632_start_measurement return value.
Definition: mlx90632.c:162