MLX90632 Driver Library  a258525c
Universal MCU library for the 90632
mlx90632.h File Reference

MLX90632 driver with virtual i2c communication. More...

#include <errno.h>
#include "mlx90632_extended_meas.h"
+ Include dependency graph for mlx90632.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ETIMEDOUT   110
 From linux errno.h. More...
 
#define EINVAL   22
 From linux errno.h. More...
 
#define EPROTONOSUPPORT   93
 From linux errno.h. More...
 
#define ERANGE   34
 From linux errno.h. More...
 
#define ENOKEY   126
 From linux errno.h. More...
 
#define BIT(x)   (1UL << (x))
 
#define BITS_PER_LONG   64
 Define how many bits per long your CPU has. More...
 
#define GENMASK(h, l)   (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
 
#define ARRAY_SIZE(arr)   (sizeof(arr) / sizeof(arr[0]))
 Return number of elements in array. More...
 
#define MLX90632_ADDR_RAM   0x4000
 Start address of ram. More...
 
#define MLX90632_ADDR_EEPROM   0x2480
 Start address of user eeprom. More...
 
#define MLX90632_EE_CTRL   0x24d4
 Control register initial value. More...
 
#define MLX90632_EE_CONTROL   MLX90632_EE_CTRL
 More human readable for Control register. More...
 
#define MLX90632_EE_I2C_ADDRESS   0x24d5
 I2C address register initial value. More...
 
#define MLX90632_EE_VERSION   0x240b
 EEPROM version reg - assumed 0x101. More...
 
#define MLX90632_EE_P_R   0x240c
 Calibration constant ambient reference register 32bit. More...
 
#define MLX90632_EE_P_G   0x240e
 Calibration constant ambient gain register 32bit. More...
 
#define MLX90632_EE_P_T   0x2410
 Calibration constant ambient tc2 register 32bit. More...
 
#define MLX90632_EE_P_O   0x2412
 Calibration constant ambient offset register 32bit. More...
 
#define MLX90632_EE_Aa   0x2414
 Aa calibration const register 32bit. More...
 
#define MLX90632_EE_Ab   0x2416
 Ab calibration const register 32bit. More...
 
#define MLX90632_EE_Ba   0x2418
 Ba calibration const register 32bit. More...
 
#define MLX90632_EE_Bb   0x241a
 Bb calibration const register 32bit. More...
 
#define MLX90632_EE_Ca   0x241c
 Ca calibration const register 32bit. More...
 
#define MLX90632_EE_Cb   0x241e
 Cb calibration const register 32bit. More...
 
#define MLX90632_EE_Da   0x2420
 Da calibration const register 32bit. More...
 
#define MLX90632_EE_Db   0x2422
 Db calibration const register 32bit. More...
 
#define MLX90632_EE_Ea   0x2424
 Ea calibration constant register 32bit. More...
 
#define MLX90632_EE_Eb   0x2426
 Eb calibration constant register 32bit. More...
 
#define MLX90632_EE_Fa   0x2428
 Fa calibration constant register 32bit. More...
 
#define MLX90632_EE_Fb   0x242a
 Fb calibration constant register 32bit. More...
 
#define MLX90632_EE_Ga   0x242c
 Ga calibration constant register 32bit. More...
 
#define MLX90632_EE_Gb   0x242e
 Ambient Beta calibration constant 16bit. More...
 
#define MLX90632_EE_Ka   0x242f
 IR Beta calibration constant 16bit. More...
 
#define MLX90632_EE_Ha   0x2481
 Ha customer calibration value register 16bit. More...
 
#define MLX90632_EE_Hb   0x2482
 Hb customer calibration value register 16bit. More...
 
#define MLX90632_EE_MEDICAL_MEAS1   0x24E1
 Medical measurement 1 16bit. More...
 
#define MLX90632_EE_MEDICAL_MEAS2   0x24E2
 Medical measurement 2 16bit. More...
 
#define MLX90632_EE_EXTENDED_MEAS1   0x24F1
 Extended measurement 1 16bit. More...
 
#define MLX90632_EE_EXTENDED_MEAS2   0x24F2
 Extended measurement 2 16bit. More...
 
#define MLX90632_EE_EXTENDED_MEAS3   0x24F3
 Extended measurement 3 16bit. More...
 
#define MLX90632_EE_REFRESH_RATE_START   10
 Refresh Rate Start bit. More...
 
#define MLX90632_EE_REFRESH_RATE_SHIFT   8
 Refresh Rate shift. More...
 
#define MLX90632_EE_REFRESH_RATE_MASK   GENMASK(MLX90632_EE_REFRESH_RATE_START, MLX90632_EE_REFRESH_RATE_SHIFT)
 Refresh Rate Mask. More...
 
#define MLX90632_EE_REFRESH_RATE(ee_val)   (ee_val & MLX90632_EE_REFRESH_RATE_MASK)
 Extract the Refresh Rate bits. More...
 
#define MLX90632_REFRESH_RATE(ee_val)   (MLX90632_EE_REFRESH_RATE(ee_val) >> MLX90632_EE_REFRESH_RATE_SHIFT)
 Extract Refresh Rate from ee register. More...
 
#define MLX90632_REFRESH_RATE_STATUS(mlx90632_meas)   (mlx90632_meas << MLX90632_EE_REFRESH_RATE_SHIFT)
 Extract the Refresh Rate bits. More...
 
#define MLX90632_REG_I2C_ADDR   0x3000
 Chip I2C address register. More...
 
#define MLX90632_REG_CTRL   0x3001
 Control Register address. More...
 
#define MLX90632_CFG_SOC_SHIFT   3
 Start measurement in step mode. More...
 
#define MLX90632_CFG_SOC_MASK   BIT(MLX90632_CFG_SOC_SHIFT)
 
#define MLX90632_CFG_PWR_MASK   GENMASK(2, 1)
 PowerMode Mask. More...
 
#define MLX90632_CFG_PWR(ctrl_val)   (ctrl_val & MLX90632_CFG_PWR_MASK)
 Extract the PowerMode bits. More...
 
#define MLX90632_CFG_MTYP_SHIFT   4
 Meas select start shift. More...
 
#define MLX90632_CFG_MTYP_MASK   GENMASK(8, MLX90632_CFG_MTYP_SHIFT)
 Meas select Mask. More...
 
#define MLX90632_CFG_MTYP(ctrl_val)   (ctrl_val & MLX90632_CFG_MTYP_MASK)
 Extract the MeasType bits. More...
 
#define MLX90632_CFG_SOB_SHIFT   11
 Start burst measurement in step mode. More...
 
#define MLX90632_CFG_SOB_MASK   BIT(MLX90632_CFG_SOB_SHIFT)
 
#define MLX90632_CFG_SOB(ctrl_val)   (ctrl_val << MLX90632_CFG_SOB_SHIFT)
 
#define MLX90632_PWR_STATUS(ctrl_val)   (ctrl_val << 1)
 
#define MLX90632_PWR_STATUS_HALT   MLX90632_PWR_STATUS(0)
 Pwrmode hold. More...
 
#define MLX90632_PWR_STATUS_SLEEP_STEP   MLX90632_PWR_STATUS(1)
 Pwrmode sleep step. More...
 
#define MLX90632_PWR_STATUS_STEP   MLX90632_PWR_STATUS(2)
 Pwrmode step. More...
 
#define MLX90632_PWR_STATUS_CONTINUOUS   MLX90632_PWR_STATUS(3)
 Pwrmode continuous. More...
 
#define MLX90632_MTYP_STATUS(ctrl_val)   (ctrl_val << MLX90632_CFG_MTYP_SHIFT)
 
#define MLX90632_MTYP_STATUS_MEDICAL   MLX90632_MTYP_STATUS(0)
 Medical measurement type. More...
 
#define MLX90632_MTYP_STATUS_EXTENDED   MLX90632_MTYP_STATUS(17)
 Extended measurement type. More...
 
#define MLX90632_MTYP(reg_val)   (MLX90632_CFG_MTYP(reg_val) >> MLX90632_CFG_MTYP_SHIFT)
 Extract MTYP from Control register. More...
 
#define MLX90632_START_BURST_MEAS   MLX90632_CFG_SOB(1)
 
#define MLX90632_BURST_MEAS_NOT_PENDING   MLX90632_CFG_SOB(0)
 
#define MLX90632_REG_STATUS   0x3fff
 Device status register. More...
 
#define MLX90632_STAT_BUSY   BIT(10)
 Device busy indicator. More...
 
#define MLX90632_STAT_EE_BUSY   BIT(9)
 Device EEPROM busy indicator. More...
 
#define MLX90632_STAT_BRST   BIT(8)
 Device brown out reset indicator. More...
 
#define MLX90632_STAT_CYCLE_POS   GENMASK(6, 2)
 Data position in measurement table. More...
 
#define MLX90632_STAT_DATA_RDY   BIT(0)
 Data ready indicator. More...
 
#define MLX90632_RAM_1(meas_num)   (MLX90632_ADDR_RAM + 3 * meas_num)
 
#define MLX90632_RAM_2(meas_num)   (MLX90632_ADDR_RAM + 3 * meas_num + 1)
 
#define MLX90632_RAM_3(meas_num)   (MLX90632_ADDR_RAM + 3 * meas_num + 2)
 
#define MLX90632_TIMING_EEPROM   100
 Time between EEPROM writes. More...
 
#define MLX90632_DSPv5   0x05 /* EEPROM DSP version */
 
#define MLX90632_EEPROM_VERSION   MLX90632_ID_MEDICAL
 Legacy define - to be deprecated. More...
 
#define MLX90632_EEPROM_WRITE_KEY   0x554C
 EEPROM write key 0x55 and 0x4c. More...
 
#define MLX90632_RESET_CMD   0x0006
 Reset sensor (address or global) More...
 
#define MLX90632_MAX_MEAS_NUM   31
 Maximum number of measurements in list. More...
 
#define MLX90632_EE_SEED   0x3f6d
 Seed for the CRC calculations. More...
 
#define MLX90632_REF_12   12.0
 ResCtrlRef value of Channel 1 or Channel 2. More...
 
#define MLX90632_REF_3   12.0
 ResCtrlRef value of Channel 3. More...
 
#define MLX90632_XTD_RNG_KEY   0x0500 /**Extended range support indication key */
 
#define MLX90632_MTYP_MEDICAL   0x00
 
#define MLX90632_MTYP_EXTENDED   0x11
 
#define MLX90632_MTYP_MEDICAL_BURST   0x80
 
#define MLX90632_MTYP_EXTENDED_BURST   0x91
 
#define MLX90632_BURST_MEASUREMENT_TYPE(meas_type)   (meas_type + 0x80)
 The MSBit is only used in the software to indicate burst type measurement. More...
 
#define MLX90632_MEASUREMENT_TYPE_STATUS(mtyp_type)   (mtyp_type & 0x7F)
 Extract the measurement type from MTYP. More...
 
#define MLX90632_MEASUREMENT_BURST_STATUS(mtyp_type)   (mtyp_type & 0x80)
 Extract the measurement burst/continuous type from MTYP. More...
 
#define MLX90632_MEAS_MAX_TIME   2000
 Maximum measurement time in ms for the lowest possible refresh rate. More...
 
#define MLX90632_MAX_NUMBER_MESUREMENT_READ_TRIES   100
 Maximum number of read tries before quiting with timeout error. More...
 
#define MLX90632_NEW_REG_VALUE(old_reg, new_value, h, l)   ((old_reg & (0xFFFF ^ GENMASK(h, l))) | (new_value << MLX90632_EE_REFRESH_RATE_SHIFT))
 

Typedefs

typedef enum mlx90632_meas_e mlx90632_meas_t
 

Enumerations

Functions

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. More...
 
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. More...
 
double mlx90632_preprocess_temp_ambient (int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
 Calculation of raw ambient output. More...
 
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. More...
 
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. More...
 
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. More...
 
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 temperature. More...
 
int32_t mlx90632_init (void)
 Initialize MLX90632 driver and confirm EEPROM version. More...
 
int mlx90632_start_measurement (void)
 Trigger start measurement for mlx90632. More...
 
void mlx90632_set_emissivity (double value)
 Set emissivity which is retained in single variable. More...
 
double mlx90632_get_emissivity (void)
 Read value of emissivity. More...
 
int32_t mlx90632_start_measurement_burst (void)
 Trigger start of burst measurement for mlx90632. More...
 
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 settings. More...
 
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 settings. More...
 
int32_t mlx90632_addressed_reset (void)
 Trigger system reset for mlx90632. More...
 
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. More...
 
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. More...
 

Detailed Description

MLX90632 driver with virtual i2c communication.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file mlx90632.h.