35 #define POW10 10000000000LL    38 #define VERSION "test"   138     *ambient_new_raw = (int16_t)read_tmp;
   143     *ambient_old_raw = (int16_t)read_tmp;
   163                                              int16_t *object_new_raw, int16_t *object_old_raw)
   168     uint8_t channel, channel_old;
   178     read = (int16_t)read_tmp;
   183     *object_new_raw = (read + (int16_t)read_tmp) / 2;
   188     read = (int16_t)read_tmp;
   193     *object_old_raw = (read + (int16_t)read_tmp) / 2;
   199                                int16_t *object_new_raw, int16_t *object_old_raw)
   201     int32_t ret, start_measurement_ret;
   205     if (start_measurement_ret < 0)
   206         return start_measurement_ret;
   220                                      int16_t *object_new_raw, int16_t *object_old_raw)
   222     int32_t ret, start_measurement_ret;
   226     if (start_measurement_ret < 0)
   227         return start_measurement_ret;
   246     kGb = ((double)Gb) / 1024.0;
   248     VR_Ta = ambient_old_raw + kGb * (ambient_new_raw / (
MLX90632_REF_3));
   253                                        int16_t ambient_new_raw, int16_t ambient_old_raw,
   258     kKa = ((double)Ka) / 1024.0;
   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;
   265                                   int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb)
   267     double Asub, Bsub, Ablock, Bblock, Cblock, AMB;
   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;
   277     return Bblock + Ablock + Cblock;
   301                                                   int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb,
   304     double calcedGa, calcedGb, calcedFa, TAdut4, first_sqrt;
   306     double KsTAtmp, Alpha_corr;
   307     double Ha_customer, Hb_customer;
   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);
   320     first_sqrt = sqrt(calcedFa + TAdut4);
   322     return sqrt(first_sqrt) - 273.15 - Hb_customer;
   349                                                             int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb,
   352     double calcedGa, calcedGb, calcedFa, first_sqrt;
   354     double KsTAtmp, Alpha_corr;
   355     double Ha_customer, Hb_customer;
   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));
   366     first_sqrt = sqrt(calcedFa + TaTr4);
   368     return sqrt(first_sqrt) - 273.15 - Hb_customer;
   379     if (emissivity == 0.0)
   390                                  int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
   391                                  int16_t Ha, int16_t Hb)
   393     double kEa, kEb, TAdut;
   398     kEa = ((double)Ea) / ((double)65536.0);
   399     kEb = ((double)Eb) / ((double)256.0);
   400     TAdut = (((double)ambient) - kEb) / kEa + 25;
   403     for (i = 0; i < 5; ++i)
   411                                            int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
   412                                            int16_t Ha, int16_t Hb)
   414     double kEa, kEb, TAdut;
   421     kEa = ((double)Ea) / ((double)65536.0);
   422     kEb = ((double)Eb) / ((double)256.0);
   423     TAdut = (((double)ambient) - kEb) / kEa + 25;
   425     TaTr4 = reflected + 273.15;
   426     TaTr4 = TaTr4 * TaTr4;
   427     TaTr4 = TaTr4 * TaTr4;
   428     ta4 = TAdut + 273.15;
   431     TaTr4 = TaTr4 - (TaTr4 - ta4) / tmp_emi;
   434     for (i = 0; i < 5; ++i)
   444     uint16_t eeprom_version, reg_status;
   506     int32_t refresh_time;
   527         refresh_time = refresh_time + ret;
   541         refresh_time = refresh_time + ret;
   547         refresh_time = refresh_time + ret;
   652     uint16_t meas1, meas2;
   661     if (meas1 != new_value)
   673     if (meas2 != new_value)
 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. 
 
#define MLX90632_EE_VERSION
EEPROM version reg - assumed 0x101. 
 
#define MLX90632_MEAS_MAX_TIME
Maximum measurement time in ms for the lowest possible refresh rate. 
 
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...
 
#define MLX90632_EE_REFRESH_RATE_MASK
Refresh Rate Mask. 
 
#define MLX90632_RAM_3(meas_num)
 
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. 
 
STATIC int32_t mlx90632_unlock_eeporm()
 
#define MLX90632_RAM_1(meas_num)
 
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
 
#define MLX90632_REF_3
ResCtrlRef value of Channel 3. 
 
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...
 
#define MLX90632_START_BURST_MEAS
 
#define EPROTONOSUPPORT
From linux errno.h. 
 
int32_t mlx90632_init(void)
Initialize MLX90632 driver and confirm EEPROM version. 
 
#define MLX90632_STAT_BUSY
Device busy indicator. 
 
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...
 
int32_t mlx90632_start_measurement_burst(void)
Trigger start of burst measurement for mlx90632. 
 
STATIC int32_t mlx90632_wait_for_eeprom_not_busy()
 
#define MLX90632_RAM_2(meas_num)
 
void msleep(int msecs)
Blocking function for sleeping in milliseconds. 
 
#define MLX90632_EE_MEDICAL_MEAS2
Medical measurement 2 16bit. 
 
#define MLX90632_XTD_RNG_KEY
 
#define MLX90632_STAT_EE_BUSY
Device EEPROM busy indicator. 
 
#define MLX90632_MAX_NUMBER_MESUREMENT_READ_TRIES
Maximum number of read tries before quiting with timeout error. 
 
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. 
 
#define MLX90632_EEPROM_WRITE_KEY
EEPROM write key 0x55 and 0x4c. 
 
#define MLX90632_STAT_CYCLE_POS
Data position in measurement table. 
 
#define MLX90632_NEW_REG_VALUE(old_reg, new_value, h, l)
 
#define MLX90632_EE_MEDICAL_MEAS1
Medical measurement 1 16bit. 
 
#define MLX90632_EE_EXTENDED_MEAS3
Extended measurement 3 16bit. 
 
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...
 
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...
 
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. 
 
STATIC int32_t mlx90632_write_eeprom(uint16_t address, uint16_t data)
 
static const char mlx90632version[]
 
STATIC int32_t mlx90632_erase_eeprom(uint16_t address)
 
#define MLX90632_MTYP_EXTENDED_BURST
 
double mlx90632_preprocess_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
Calculation of raw ambient output. 
 
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. 
 
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. 
 
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. 
 
#define MLX90632_REG_STATUS
Device status register. 
 
#define MLX90632_EE_REFRESH_RATE_SHIFT
Refresh Rate shift. 
 
MLX90632 driver with virtual i2c communication. 
 
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. 
 
MLX90632 driver dependencies. 
 
#define MLX90632_REF_12
ResCtrlRef value of Channel 1 or Channel 2. 
 
#define MLX90632_STAT_DATA_RDY
Data ready indicator. 
 
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...
 
#define MLX90632_EE_EXTENDED_MEAS2
Extended measurement 2 16bit. 
 
int32_t mlx90632_addressed_reset(void)
Trigger system reset for mlx90632. 
 
void usleep(int min_range, int max_range)
Blocking function for sleeping in microseconds. 
 
double mlx90632_get_emissivity(void)
Read value of emissivity. 
 
#define EINVAL
From linux errno.h. 
 
#define MLX90632_EE_EXTENDED_MEAS1
Extended measurement 1 16bit. 
 
#define MLX90632_REG_CTRL
Control Register address. 
 
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 ...
 
#define MLX90632_EE_REFRESH_RATE_START
Refresh Rate Start bit. 
 
#define MLX90632_RESET_CMD
Reset sensor (address or global) 
 
#define MLX90632_REFRESH_RATE(ee_val)
Extract Refresh Rate from ee register. 
 
#define ETIMEDOUT
From linux errno.h. 
 
void mlx90632_set_emissivity(double value)
Set emissivity which is retained in single variable. 
 
int mlx90632_start_measurement(void)
Trigger start measurement for mlx90632. 
 
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.