MLX90632 Driver Library
a258525c
Universal MCU library for the 90632
|
Implementation of MLX90632 driver with virtual i2c read/write functions. More...
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... | |
Implementation of MLX90632 driver with virtual i2c read/write functions.
Copy of Kernel driver, except that it is stripped of Linux kernel specifics which are replaced by simple i2c read/write functions. There are some Linux kernel macros left behind as they make code more readable and easier to understand, but if you already have your own implementation then preprocessor should handle it just fine.
Repository contains README.md for compilation and unit-test instructions.
#define ARRAY_SIZE | ( | arr | ) | (sizeof(arr) / sizeof(arr[0])) |
Return number of elements in array.
Definition at line 75 of file mlx90632.h.
#define BIT | ( | x | ) | (1UL << (x)) |
Definition at line 64 of file mlx90632.h.
#define BITS_PER_LONG 64 |
Define how many bits per long your CPU has.
Definition at line 69 of file mlx90632.h.
#define EINVAL 22 |
From linux errno.h.
Definition at line 49 of file mlx90632.h.
#define ENOKEY 126 |
From linux errno.h.
Definition at line 58 of file mlx90632.h.
#define EPROTONOSUPPORT 93 |
From linux errno.h.
Definition at line 52 of file mlx90632.h.
#define ERANGE 34 |
From linux errno.h.
Definition at line 55 of file mlx90632.h.
#define ETIMEDOUT 110 |
From linux errno.h.
Definition at line 46 of file mlx90632.h.
#define GENMASK | ( | h, | |
l | |||
) | (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) |
Definition at line 71 of file mlx90632.h.
#define MLX90632_ADDR_EEPROM 0x2480 |
Start address of user eeprom.
Definition at line 80 of file mlx90632.h.
#define MLX90632_ADDR_RAM 0x4000 |
Start address of ram.
Definition at line 79 of file mlx90632.h.
#define MLX90632_BURST_MEAS_NOT_PENDING MLX90632_CFG_SOB(0) |
Definition at line 165 of file mlx90632.h.
#define MLX90632_BURST_MEASUREMENT_TYPE | ( | meas_type | ) | (meas_type + 0x80) |
The MSBit is only used in the software to indicate burst type measurement.
The 5 LS Bits define medical or extended measurement and are used to set the hardware
Definition at line 199 of file mlx90632.h.
#define MLX90632_CFG_MTYP | ( | ctrl_val | ) | (ctrl_val & MLX90632_CFG_MTYP_MASK) |
Extract the MeasType bits.
Definition at line 147 of file mlx90632.h.
#define MLX90632_CFG_MTYP_MASK GENMASK(8, MLX90632_CFG_MTYP_SHIFT) |
Meas select Mask.
Definition at line 146 of file mlx90632.h.
#define MLX90632_CFG_MTYP_SHIFT 4 |
Meas select start shift.
Definition at line 145 of file mlx90632.h.
#define MLX90632_CFG_PWR | ( | ctrl_val | ) | (ctrl_val & MLX90632_CFG_PWR_MASK) |
Extract the PowerMode bits.
Definition at line 144 of file mlx90632.h.
#define MLX90632_CFG_PWR_MASK GENMASK(2, 1) |
PowerMode Mask.
Definition at line 143 of file mlx90632.h.
#define MLX90632_CFG_SOB | ( | ctrl_val | ) | (ctrl_val << MLX90632_CFG_SOB_SHIFT) |
Definition at line 150 of file mlx90632.h.
#define MLX90632_CFG_SOB_MASK BIT(MLX90632_CFG_SOB_SHIFT) |
Definition at line 149 of file mlx90632.h.
#define MLX90632_CFG_SOB_SHIFT 11 |
Start burst measurement in step mode.
Definition at line 148 of file mlx90632.h.
#define MLX90632_CFG_SOC_MASK BIT(MLX90632_CFG_SOC_SHIFT) |
Definition at line 142 of file mlx90632.h.
#define MLX90632_CFG_SOC_SHIFT 3 |
Start measurement in step mode.
Definition at line 141 of file mlx90632.h.
#define MLX90632_DSPv5 0x05 /* EEPROM DSP version */ |
Definition at line 184 of file mlx90632.h.
#define MLX90632_EE_Aa 0x2414 |
Aa calibration const register 32bit.
Definition at line 93 of file mlx90632.h.
#define MLX90632_EE_Ab 0x2416 |
Ab calibration const register 32bit.
Definition at line 94 of file mlx90632.h.
#define MLX90632_EE_Ba 0x2418 |
Ba calibration const register 32bit.
Definition at line 95 of file mlx90632.h.
#define MLX90632_EE_Bb 0x241a |
Bb calibration const register 32bit.
Definition at line 96 of file mlx90632.h.
#define MLX90632_EE_Ca 0x241c |
Ca calibration const register 32bit.
Definition at line 97 of file mlx90632.h.
#define MLX90632_EE_Cb 0x241e |
Cb calibration const register 32bit.
Definition at line 98 of file mlx90632.h.
#define MLX90632_EE_CONTROL MLX90632_EE_CTRL |
More human readable for Control register.
Definition at line 84 of file mlx90632.h.
#define MLX90632_EE_CTRL 0x24d4 |
Control register initial value.
Definition at line 83 of file mlx90632.h.
#define MLX90632_EE_Da 0x2420 |
Da calibration const register 32bit.
Definition at line 99 of file mlx90632.h.
#define MLX90632_EE_Db 0x2422 |
Db calibration const register 32bit.
Definition at line 100 of file mlx90632.h.
#define MLX90632_EE_Ea 0x2424 |
Ea calibration constant register 32bit.
Definition at line 101 of file mlx90632.h.
#define MLX90632_EE_Eb 0x2426 |
Eb calibration constant register 32bit.
Definition at line 102 of file mlx90632.h.
#define MLX90632_EE_EXTENDED_MEAS1 0x24F1 |
Extended measurement 1 16bit.
Definition at line 113 of file mlx90632.h.
#define MLX90632_EE_EXTENDED_MEAS2 0x24F2 |
Extended measurement 2 16bit.
Definition at line 114 of file mlx90632.h.
#define MLX90632_EE_EXTENDED_MEAS3 0x24F3 |
Extended measurement 3 16bit.
Definition at line 115 of file mlx90632.h.
#define MLX90632_EE_Fa 0x2428 |
Fa calibration constant register 32bit.
Definition at line 103 of file mlx90632.h.
#define MLX90632_EE_Fb 0x242a |
Fb calibration constant register 32bit.
Definition at line 104 of file mlx90632.h.
#define MLX90632_EE_Ga 0x242c |
Ga calibration constant register 32bit.
Definition at line 105 of file mlx90632.h.
#define MLX90632_EE_Gb 0x242e |
Ambient Beta calibration constant 16bit.
Definition at line 106 of file mlx90632.h.
#define MLX90632_EE_Ha 0x2481 |
Ha customer calibration value register 16bit.
Definition at line 108 of file mlx90632.h.
#define MLX90632_EE_Hb 0x2482 |
Hb customer calibration value register 16bit.
Definition at line 109 of file mlx90632.h.
#define MLX90632_EE_I2C_ADDRESS 0x24d5 |
I2C address register initial value.
Definition at line 86 of file mlx90632.h.
#define MLX90632_EE_Ka 0x242f |
IR Beta calibration constant 16bit.
Definition at line 107 of file mlx90632.h.
#define MLX90632_EE_MEDICAL_MEAS1 0x24E1 |
Medical measurement 1 16bit.
Definition at line 111 of file mlx90632.h.
#define MLX90632_EE_MEDICAL_MEAS2 0x24E2 |
Medical measurement 2 16bit.
Definition at line 112 of file mlx90632.h.
#define MLX90632_EE_P_G 0x240e |
Calibration constant ambient gain register 32bit.
Definition at line 90 of file mlx90632.h.
#define MLX90632_EE_P_O 0x2412 |
Calibration constant ambient offset register 32bit.
Definition at line 92 of file mlx90632.h.
#define MLX90632_EE_P_R 0x240c |
Calibration constant ambient reference register 32bit.
Definition at line 89 of file mlx90632.h.
#define MLX90632_EE_P_T 0x2410 |
Calibration constant ambient tc2 register 32bit.
Definition at line 91 of file mlx90632.h.
#define MLX90632_EE_REFRESH_RATE | ( | ee_val | ) | (ee_val & MLX90632_EE_REFRESH_RATE_MASK) |
Extract the Refresh Rate bits.
Definition at line 132 of file mlx90632.h.
#define MLX90632_EE_REFRESH_RATE_MASK GENMASK(MLX90632_EE_REFRESH_RATE_START, MLX90632_EE_REFRESH_RATE_SHIFT) |
Refresh Rate Mask.
Definition at line 131 of file mlx90632.h.
#define MLX90632_EE_REFRESH_RATE_SHIFT 8 |
Refresh Rate shift.
Definition at line 130 of file mlx90632.h.
#define MLX90632_EE_REFRESH_RATE_START 10 |
Refresh Rate Start bit.
Definition at line 129 of file mlx90632.h.
#define MLX90632_EE_SEED 0x3f6d |
Seed for the CRC calculations.
Definition at line 189 of file mlx90632.h.
#define MLX90632_EE_VERSION 0x240b |
EEPROM version reg - assumed 0x101.
Definition at line 87 of file mlx90632.h.
#define MLX90632_EEPROM_VERSION MLX90632_ID_MEDICAL |
Legacy define - to be deprecated.
Definition at line 185 of file mlx90632.h.
#define MLX90632_EEPROM_WRITE_KEY 0x554C |
EEPROM write key 0x55 and 0x4c.
Definition at line 186 of file mlx90632.h.
#define MLX90632_MAX_MEAS_NUM 31 |
Maximum number of measurements in list.
Definition at line 188 of file mlx90632.h.
#define MLX90632_MAX_NUMBER_MESUREMENT_READ_TRIES 100 |
Maximum number of read tries before quiting with timeout error.
Definition at line 205 of file mlx90632.h.
#define MLX90632_MEAS_MAX_TIME 2000 |
Maximum measurement time in ms for the lowest possible refresh rate.
Definition at line 204 of file mlx90632.h.
#define MLX90632_MEASUREMENT_BURST_STATUS | ( | mtyp_type | ) | (mtyp_type & 0x80) |
Extract the measurement burst/continuous type from MTYP.
Definition at line 202 of file mlx90632.h.
#define MLX90632_MEASUREMENT_TYPE_STATUS | ( | mtyp_type | ) | (mtyp_type & 0x7F) |
Extract the measurement type from MTYP.
Definition at line 201 of file mlx90632.h.
#define MLX90632_MTYP | ( | reg_val | ) | (MLX90632_CFG_MTYP(reg_val) >> MLX90632_CFG_MTYP_SHIFT) |
Extract MTYP from Control register.
Definition at line 162 of file mlx90632.h.
#define MLX90632_MTYP_EXTENDED 0x11 |
Definition at line 196 of file mlx90632.h.
#define MLX90632_MTYP_EXTENDED_BURST 0x91 |
Definition at line 198 of file mlx90632.h.
#define MLX90632_MTYP_MEDICAL 0x00 |
Definition at line 195 of file mlx90632.h.
#define MLX90632_MTYP_MEDICAL_BURST 0x80 |
Definition at line 197 of file mlx90632.h.
#define MLX90632_MTYP_STATUS | ( | ctrl_val | ) | (ctrl_val << MLX90632_CFG_MTYP_SHIFT) |
Definition at line 159 of file mlx90632.h.
#define MLX90632_MTYP_STATUS_EXTENDED MLX90632_MTYP_STATUS(17) |
Extended measurement type.
Definition at line 161 of file mlx90632.h.
#define MLX90632_MTYP_STATUS_MEDICAL MLX90632_MTYP_STATUS(0) |
Medical measurement type.
Definition at line 160 of file mlx90632.h.
#define MLX90632_NEW_REG_VALUE | ( | old_reg, | |
new_value, | |||
h, | |||
l | |||
) | ((old_reg & (0xFFFF ^ GENMASK(h, l))) | (new_value << MLX90632_EE_REFRESH_RATE_SHIFT)) |
Definition at line 210 of file mlx90632.h.
#define MLX90632_PWR_STATUS | ( | ctrl_val | ) | (ctrl_val << 1) |
Definition at line 153 of file mlx90632.h.
#define MLX90632_PWR_STATUS_CONTINUOUS MLX90632_PWR_STATUS(3) |
Pwrmode continuous.
Definition at line 157 of file mlx90632.h.
#define MLX90632_PWR_STATUS_HALT MLX90632_PWR_STATUS(0) |
Pwrmode hold.
Definition at line 154 of file mlx90632.h.
#define MLX90632_PWR_STATUS_SLEEP_STEP MLX90632_PWR_STATUS(1) |
Pwrmode sleep step.
Definition at line 155 of file mlx90632.h.
#define MLX90632_PWR_STATUS_STEP MLX90632_PWR_STATUS(2) |
Pwrmode step.
Definition at line 156 of file mlx90632.h.
#define MLX90632_RAM_1 | ( | meas_num | ) | (MLX90632_ADDR_RAM + 3 * meas_num) |
Definition at line 176 of file mlx90632.h.
#define MLX90632_RAM_2 | ( | meas_num | ) | (MLX90632_ADDR_RAM + 3 * meas_num + 1) |
Definition at line 177 of file mlx90632.h.
#define MLX90632_RAM_3 | ( | meas_num | ) | (MLX90632_ADDR_RAM + 3 * meas_num + 2) |
Definition at line 178 of file mlx90632.h.
#define MLX90632_REF_12 12.0 |
ResCtrlRef value of Channel 1 or Channel 2.
Definition at line 190 of file mlx90632.h.
#define MLX90632_REF_3 12.0 |
ResCtrlRef value of Channel 3.
Definition at line 191 of file mlx90632.h.
#define MLX90632_REFRESH_RATE | ( | ee_val | ) | (MLX90632_EE_REFRESH_RATE(ee_val) >> MLX90632_EE_REFRESH_RATE_SHIFT) |
Extract Refresh Rate from ee register.
Definition at line 133 of file mlx90632.h.
#define MLX90632_REFRESH_RATE_STATUS | ( | mlx90632_meas | ) | (mlx90632_meas << MLX90632_EE_REFRESH_RATE_SHIFT) |
Extract the Refresh Rate bits.
Definition at line 134 of file mlx90632.h.
#define MLX90632_REG_CTRL 0x3001 |
Control Register address.
Definition at line 140 of file mlx90632.h.
#define MLX90632_REG_I2C_ADDR 0x3000 |
Chip I2C address register.
Definition at line 137 of file mlx90632.h.
#define MLX90632_REG_STATUS 0x3fff |
Device status register.
Definition at line 168 of file mlx90632.h.
#define MLX90632_RESET_CMD 0x0006 |
Reset sensor (address or global)
Definition at line 187 of file mlx90632.h.
#define MLX90632_START_BURST_MEAS MLX90632_CFG_SOB(1) |
Definition at line 164 of file mlx90632.h.
#define MLX90632_STAT_BRST BIT(8) |
Device brown out reset indicator.
Definition at line 171 of file mlx90632.h.
#define MLX90632_STAT_BUSY BIT(10) |
Device busy indicator.
Definition at line 169 of file mlx90632.h.
#define MLX90632_STAT_CYCLE_POS GENMASK(6, 2) |
Data position in measurement table.
Definition at line 172 of file mlx90632.h.
#define MLX90632_STAT_DATA_RDY BIT(0) |
Data ready indicator.
Definition at line 173 of file mlx90632.h.
#define MLX90632_STAT_EE_BUSY BIT(9) |
Device EEPROM busy indicator.
Definition at line 170 of file mlx90632.h.
#define MLX90632_TIMING_EEPROM 100 |
Time between EEPROM writes.
Definition at line 181 of file mlx90632.h.
#define MLX90632_XTD_RNG_KEY 0x0500 /**Extended range support indication key */ |
Definition at line 192 of file mlx90632.h.
typedef enum mlx90632_meas_e mlx90632_meas_t |
enum mlx90632_meas_e |
Enumerator | |
---|---|
MLX90632_MEAS_HZ_ERROR | |
MLX90632_MEAS_HZ_HALF | |
MLX90632_MEAS_HZ_1 | |
MLX90632_MEAS_HZ_2 | |
MLX90632_MEAS_HZ_4 | |
MLX90632_MEAS_HZ_8 | |
MLX90632_MEAS_HZ_16 | |
MLX90632_MEAS_HZ_32 | |
MLX90632_MEAS_HZ_64 |
Definition at line 118 of file mlx90632.h.
int32_t mlx90632_addressed_reset | ( | void | ) |
Trigger system reset for mlx90632.
Perform full reset of mlx90632 using reset command. It also waits for at least 150us to ensure the mlx90632 device is properly reset and ready for further communications.
<0 | Something failed. Check errno.h for more information |
0 | The mlx90632 device was properly reset and is now ready for communication. |
Definition at line 475 of file mlx90632.c.
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.
DSPv5 implementation of ambient temperature calculation
[in] | ambient_new_raw | ambient temperature from MLX90632_RAM_3. The channel 1 or 2 is determined by value in MLX90632_STAT_CYCLE_POS |
[in] | ambient_old_raw | ambient temperature from MLX90632_RAM_3. The channel 1 or 2 is determined by value not in MLX90632_STAT_CYCLE_POS |
[in] | P_T | Register value on MLX90632_EE_P_T |
[in] | P_R | Register value on MLX90632_EE_P_R |
[in] | P_G | Register value on MLX90632_EE_P_G |
[in] | P_O | Register value on MLX90632_EE_P_O |
[in] | Gb | Register value on MLX90632_EE_Gb |
Definition at line 264 of file mlx90632.c.
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.
DSPv5 implementation of object temperature calculation with customer calibration data
[in] | object | object temperature from mlx90632_preprocess_temp_object |
[in] | ambient | ambient temperature from mlx90632_preprocess_temp_ambient |
[in] | Ea | Register value on MLX90632_EE_Ea |
[in] | Eb | Register value on MLX90632_EE_Eb |
[in] | Ga | Register value on MLX90632_EE_Ga |
[in] | Fb | Register value on MLX90632_EE_Fb |
[in] | Fa | Register value on MLX90632_EE_Fa |
[in] | Ha | Register value on MLX90632_EE_Ha |
[in] | Hb | Register value on MLX90632_EE_Hb |
Definition at line 389 of file mlx90632.c.
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.
when the object has emissivity lower than 1 then it does not just emit InfraRed light, but also reflects it. That is why measurement of the ambient temperature around object is important to help calculating more precise object temperature. This function makes it possible to add object environment temperature and offset it with sensor's ambient temperature to calculate more precise object temperature. DSPv5 implementation of object temperature calculation with customer calibration data
[in] | object | object temperature from mlx90632_preprocess_temp_object |
[in] | ambient | sensor ambient temperature from mlx90632_preprocess_temp_ambient |
[in] | reflected | reflected (environment) temperature from a sensor different than the MLX90632 or acquired by other means |
[in] | Ea | Register value on MLX90632_EE_Ea |
[in] | Eb | Register value on MLX90632_EE_Eb |
[in] | Ga | Register value on MLX90632_EE_Ga |
[in] | Fb | Register value on MLX90632_EE_Fb |
[in] | Fa | Register value on MLX90632_EE_Fa |
[in] | Ha | Register value on MLX90632_EE_Ha |
[in] | Hb | Register value on MLX90632_EE_Hb |
Definition at line 410 of file mlx90632.c.
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.
The function is returning valid measurement time only for burst mode measurements. An error will be returned if it is called with a continuous measurement type parameter.
>=0 | Refresh time in ms |
<0 | Something went wrong. Check errno.h for more details. |
Definition at line 503 of file mlx90632.c.
double mlx90632_get_emissivity | ( | void | ) |
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.
[in] | meas | Measurement to read the frefresh rate for |
>=0 | Refresh time in ms |
<0 | Something went wrong. Check errno.h for more details. |
Definition at line 488 of file mlx90632.c.
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.
MLX90632_MEAS_HZ_ERROR | if there is an error |
refresh_rate | as the mlx90632_meas_e |
Definition at line 681 of file mlx90632.c.
int32_t mlx90632_init | ( | void | ) |
Initialize MLX90632 driver and confirm EEPROM version.
EEPROM version is important to match sensor EEPROM content and calculations. This is why this function checks for correct EEPROM version before it does checksum validation of the EEPROM content.
0 | Successfully initialized MLX90632 driver, extended range measurement not supported |
Definition at line 441 of file mlx90632.c.
double mlx90632_preprocess_temp_ambient | ( | int16_t | ambient_new_raw, |
int16_t | ambient_old_raw, | ||
int16_t | Gb | ||
) |
Calculation of raw ambient output.
Preprocessing of the raw ambient value
[in] | ambient_new_raw | ambient temperature from MLX90632_RAM_3. The meas_num 1 or 2 is determined by value in MLX90632_STAT_CYCLE_POS |
[in] | ambient_old_raw | ambient temperature from MLX90632_RAM_3. The meas_num 1 or 2 is determined by value not in MLX90632_STAT_CYCLE_POS |
[in] | Gb | Register value on MLX90632_EE_Gb |
Definition at line 242 of file mlx90632.c.
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.
Preprocessing of the raw object value
[in] | object_new_raw | object temperature from MLX90632_RAM_1 or MLX90632_RAM_2. The meas_number 1 or 2 is determined by value in MLX90632_STAT_CYCLE_POS |
[in] | object_old_raw | object temperature from MLX90632_RAM_1 or MLX90632_RAM_2. The meas_number 1 or 2 is determined by value not in MLX90632_STAT_CYCLE_POS |
[in] | ambient_new_raw | ambient temperature from MLX90632_RAM_3. The meas_number 1 or 2 is determined by value in MLX90632_STAT_CYCLE_POS |
[in] | ambient_old_raw | ambient temperature from MLX90632_RAM_3. The meas_number 1 or 2 is determined by value not in MLX90632_STAT_CYCLE_POS |
[in] | Ka | Register value on MLX90632_EE_Ka |
Definition at line 252 of file mlx90632.c.
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.
Trigger and read raw ambient and object temperatures. This values still need to be pre-processed via mlx90632_preprocess_temp_ambient and mlx90632_preprocess_temp_object functions and then processed via mlx90632_calc_temp_ambient and mlx90632_calc_temp_object to retrieve values in milliCelsius
[out] | ambient_new_raw | Pointer to where new raw ambient temperature is written |
[out] | object_new_raw | Pointer to where new raw object temperature is written |
[out] | ambient_old_raw | Pointer to where old raw ambient temperature is written |
[out] | object_old_raw | Pointer to where old raw object temperature is written |
0 | Successfully read both temperatures |
<0 | Something went wrong. Check errno.h for more details |
Read new and old ambient values from sensor
Read new and old object values from sensor
Definition at line 198 of file mlx90632.c.
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.
Trigger and read raw ambient and object temperatures. This values still need to be pre-processed via mlx90632_preprocess_temp_ambient and mlx90632_preprocess_temp_object functions and then processed via mlx90632_calc_temp_ambient and mlx90632_calc_temp_object to retrieve values in milliCelsius
[out] | ambient_new_raw | Pointer to where new raw ambient temperature is written |
[out] | object_new_raw | Pointer to where new raw object temperature is written |
[out] | ambient_old_raw | Pointer to where old raw ambient temperature is written |
[out] | object_old_raw | Pointer to where old raw object temperature is written |
0 | Successfully read both temperatures |
<0 | Something went wrong. Check errno.h for more details |
Read new and old ambient values from sensor
Read new and old object values from sensor
Definition at line 219 of file mlx90632.c.
void mlx90632_set_emissivity | ( | double | value | ) |
Set emissivity which is retained in single variable.
[in] | value | Value provided by user of object emissivity. Defaults to 1.0 and cannot be 0.0. |
Definition at line 372 of file mlx90632.c.
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.
[in] | measRate | refresh rate to set with mlx90632_meas_e |
<0 | Something went wrong. Consult errno.h for more details. |
Definition at line 650 of file mlx90632.c.
int mlx90632_start_measurement | ( | void | ) |
Trigger start measurement for mlx90632.
Trigger measurement cycle and wait for data to be ready. It does not read anything, just triggers and completes.
<0 | Something failed. Check errno.h for more information |
>=0 | Channel position where new (recently updated) measurement can be found |
Definition at line 47 of file mlx90632.c.
int32_t mlx90632_start_measurement_burst | ( | void | ) |
Trigger start of burst measurement for mlx90632.
Trigger a single measurement cycle and wait for data to be ready. It does not read anything, just triggers and completes. The SOB bit is set so that the complete measurement table is re-freshed.
<0 | Something failed. Check errno.h for more information |
0 | New data is available and waiting to be processed |
Definition at line 553 of file mlx90632.c.