37 #ifndef _MLX90632_LIB_ 38 #define _MLX90632_LIB_ 51 #ifndef EPROTONOSUPPORT 52 #define EPROTONOSUPPORT 93 64 #define BIT(x)(1UL << (x)) 68 #warning "Using default BITS_PER_LONG value" 69 #define BITS_PER_LONG 64 71 #define GENMASK(h, l) \ 72 (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) 75 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) 79 #define MLX90632_ADDR_RAM 0x4000 80 #define MLX90632_ADDR_EEPROM 0x2480 83 #define MLX90632_EE_CTRL 0x24d4 84 #define MLX90632_EE_CONTROL MLX90632_EE_CTRL 86 #define MLX90632_EE_I2C_ADDRESS 0x24d5 87 #define MLX90632_EE_VERSION 0x240b 89 #define MLX90632_EE_P_R 0x240c 90 #define MLX90632_EE_P_G 0x240e 91 #define MLX90632_EE_P_T 0x2410 92 #define MLX90632_EE_P_O 0x2412 93 #define MLX90632_EE_Aa 0x2414 94 #define MLX90632_EE_Ab 0x2416 95 #define MLX90632_EE_Ba 0x2418 96 #define MLX90632_EE_Bb 0x241a 97 #define MLX90632_EE_Ca 0x241c 98 #define MLX90632_EE_Cb 0x241e 99 #define MLX90632_EE_Da 0x2420 100 #define MLX90632_EE_Db 0x2422 101 #define MLX90632_EE_Ea 0x2424 102 #define MLX90632_EE_Eb 0x2426 103 #define MLX90632_EE_Fa 0x2428 104 #define MLX90632_EE_Fb 0x242a 105 #define MLX90632_EE_Ga 0x242c 106 #define MLX90632_EE_Gb 0x242e 107 #define MLX90632_EE_Ka 0x242f 108 #define MLX90632_EE_Ha 0x2481 109 #define MLX90632_EE_Hb 0x2482 111 #define MLX90632_EE_MEDICAL_MEAS1 0x24E1 112 #define MLX90632_EE_MEDICAL_MEAS2 0x24E2 113 #define MLX90632_EE_EXTENDED_MEAS1 0x24F1 114 #define MLX90632_EE_EXTENDED_MEAS2 0x24F2 115 #define MLX90632_EE_EXTENDED_MEAS3 0x24F3 129 #define MLX90632_EE_REFRESH_RATE_START 10 130 #define MLX90632_EE_REFRESH_RATE_SHIFT 8 131 #define MLX90632_EE_REFRESH_RATE_MASK GENMASK(MLX90632_EE_REFRESH_RATE_START, MLX90632_EE_REFRESH_RATE_SHIFT) 132 #define MLX90632_EE_REFRESH_RATE(ee_val) (ee_val & MLX90632_EE_REFRESH_RATE_MASK) 133 #define MLX90632_REFRESH_RATE(ee_val) (MLX90632_EE_REFRESH_RATE(ee_val) >> MLX90632_EE_REFRESH_RATE_SHIFT) 134 #define MLX90632_REFRESH_RATE_STATUS(mlx90632_meas) (mlx90632_meas << MLX90632_EE_REFRESH_RATE_SHIFT) 137 #define MLX90632_REG_I2C_ADDR 0x3000 140 #define MLX90632_REG_CTRL 0x3001 141 #define MLX90632_CFG_SOC_SHIFT 3 142 #define MLX90632_CFG_SOC_MASK BIT(MLX90632_CFG_SOC_SHIFT) 143 #define MLX90632_CFG_PWR_MASK GENMASK(2, 1) 144 #define MLX90632_CFG_PWR(ctrl_val) (ctrl_val & MLX90632_CFG_PWR_MASK) 145 #define MLX90632_CFG_MTYP_SHIFT 4 146 #define MLX90632_CFG_MTYP_MASK GENMASK(8, MLX90632_CFG_MTYP_SHIFT) 147 #define MLX90632_CFG_MTYP(ctrl_val) (ctrl_val & MLX90632_CFG_MTYP_MASK) 148 #define MLX90632_CFG_SOB_SHIFT 11 149 #define MLX90632_CFG_SOB_MASK BIT(MLX90632_CFG_SOB_SHIFT) 150 #define MLX90632_CFG_SOB(ctrl_val) (ctrl_val << MLX90632_CFG_SOB_SHIFT) 153 #define MLX90632_PWR_STATUS(ctrl_val) (ctrl_val << 1) 154 #define MLX90632_PWR_STATUS_HALT MLX90632_PWR_STATUS(0) 155 #define MLX90632_PWR_STATUS_SLEEP_STEP MLX90632_PWR_STATUS(1) 156 #define MLX90632_PWR_STATUS_STEP MLX90632_PWR_STATUS(2) 157 #define MLX90632_PWR_STATUS_CONTINUOUS MLX90632_PWR_STATUS(3) 159 #define MLX90632_MTYP_STATUS(ctrl_val) (ctrl_val << MLX90632_CFG_MTYP_SHIFT) 160 #define MLX90632_MTYP_STATUS_MEDICAL MLX90632_MTYP_STATUS(0) 161 #define MLX90632_MTYP_STATUS_EXTENDED MLX90632_MTYP_STATUS(17) 162 #define MLX90632_MTYP(reg_val) (MLX90632_CFG_MTYP(reg_val) >> MLX90632_CFG_MTYP_SHIFT) 164 #define MLX90632_START_BURST_MEAS MLX90632_CFG_SOB(1) 165 #define MLX90632_BURST_MEAS_NOT_PENDING MLX90632_CFG_SOB(0) 168 #define MLX90632_REG_STATUS 0x3fff 169 #define MLX90632_STAT_BUSY BIT(10) 170 #define MLX90632_STAT_EE_BUSY BIT(9) 171 #define MLX90632_STAT_BRST BIT(8) 172 #define MLX90632_STAT_CYCLE_POS GENMASK(6, 2) 173 #define MLX90632_STAT_DATA_RDY BIT(0) 176 #define MLX90632_RAM_1(meas_num) (MLX90632_ADDR_RAM + 3 * meas_num) 177 #define MLX90632_RAM_2(meas_num) (MLX90632_ADDR_RAM + 3 * meas_num + 1) 178 #define MLX90632_RAM_3(meas_num) (MLX90632_ADDR_RAM + 3 * meas_num + 2) 181 #define MLX90632_TIMING_EEPROM 100 184 #define MLX90632_DSPv5 0x05 185 #define MLX90632_EEPROM_VERSION MLX90632_ID_MEDICAL 186 #define MLX90632_EEPROM_WRITE_KEY 0x554C 187 #define MLX90632_RESET_CMD 0x0006 188 #define MLX90632_MAX_MEAS_NUM 31 189 #define MLX90632_EE_SEED 0x3f6d 190 #define MLX90632_REF_12 12.0 191 #define MLX90632_REF_3 12.0 192 #define MLX90632_XTD_RNG_KEY 0x0500 195 #define MLX90632_MTYP_MEDICAL 0x00 196 #define MLX90632_MTYP_EXTENDED 0x11 197 #define MLX90632_MTYP_MEDICAL_BURST 0x80 198 #define MLX90632_MTYP_EXTENDED_BURST 0x91 199 #define MLX90632_BURST_MEASUREMENT_TYPE(meas_type) (meas_type + 0x80) 201 #define MLX90632_MEASUREMENT_TYPE_STATUS(mtyp_type) (mtyp_type & 0x7F) 202 #define MLX90632_MEASUREMENT_BURST_STATUS(mtyp_type) (mtyp_type & 0x80) 204 #define MLX90632_MEAS_MAX_TIME 2000 205 #define MLX90632_MAX_NUMBER_MESUREMENT_READ_TRIES 100 210 #define MLX90632_NEW_REG_VALUE(old_reg, new_value, h, l) \ 211 ((old_reg & (0xFFFF ^ GENMASK(h, l))) | (new_value << MLX90632_EE_REFRESH_RATE_SHIFT)) 230 int16_t *object_new_raw, int16_t *object_old_raw);
249 int16_t *object_new_raw, int16_t *object_old_raw);
282 int16_t ambient_new_raw, int16_t ambient_old_raw,
302 int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb);
325 int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
326 int16_t Ha, int16_t Hb);
353 int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
354 int16_t Ha, int16_t Hb);
461 int16_t *object_new_raw, int16_t *object_old_raw);
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...
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...
double mlx90632_preprocess_temp_ambient(int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
Calculation of raw ambient output.
int mlx90632_start_measurement(void)
Trigger start measurement for mlx90632.
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...
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.
int32_t mlx90632_addressed_reset(void)
Trigger system reset for mlx90632.
MLX90632 extended range measurement support functions.
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.
int32_t mlx90632_init(void)
Initialize MLX90632 driver and confirm EEPROM version.
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...
enum mlx90632_meas_e mlx90632_meas_t
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.
int32_t mlx90632_start_measurement_burst(void)
Trigger start of burst measurement for mlx90632.
double mlx90632_get_emissivity(void)
Read value of emissivity.
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.
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...
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.
void mlx90632_set_emissivity(double value)
Set emissivity which is retained in single variable.
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.
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.