no-OS
|
Implementation of MAX31827 Driver. More...
Go to the source code of this file.
Classes | |
struct | max31827_device |
MAX31827 descriptor. More... | |
struct | max31827_init_param |
MAX31827 init param. More... | |
Enumerations | |
enum | max31827_cnv { MAX31827_CNV_1_DIV_64_HZ = 1, MAX31827_CNV_1_DIV_32_HZ, MAX31827_CNV_1_DIV_16_HZ, MAX31827_CNV_1_DIV_4_HZ, MAX31827_CNV_1_HZ, MAX31827_CNV_4_HZ, MAX31827_CNV_8_HZ } |
MAX31827 conversion rate. More... | |
enum | max31827_resolution { MAX31827_RES_8_BIT = 0, MAX31827_RES_9_BIT, MAX31827_RES_10_BIT, MAX31827_RES_12_BIT } |
MAX31827 temperature resolution. More... | |
Functions | |
int | max31827_reg_read (struct max31827_device *dev, uint8_t addr, uint16_t *val) |
Read a register value. More... | |
int | max31827_reg_write (struct max31827_device *dev, uint8_t addr, uint16_t val) |
Write a register value. More... | |
int | max31827_reg_update_bits (struct max31827_device *dev, uint8_t addr, uint16_t mask, uint16_t val) |
Read-modify-write operation. More... | |
int | max31827_init (struct max31827_device **dev, struct max31827_init_param *init_param) |
Device and comm init function. More... | |
int | max31827_remove (struct max31827_device *dev) |
Free resources allocated by the init function. More... | |
int | max31827_init_client (struct max31827_device *dev, struct max31827_init_param *init_param) |
Initialize MAX31827 device setup. More... | |
int | max31827_read_temp (struct max31827_device *dev, uint8_t addr, int32_t *val) |
Read a temperature from a register. More... | |
int | max31827_read_temp_input (struct max31827_device *dev, int32_t *val) |
Read input temperature. More... | |
int | max31827_shutdown_write (struct max31827_device *dev, uint8_t reg, uint16_t mask, uint16_t val) |
Shutdown then write register value. More... | |
int | max31827_write_alarm_val (struct max31827_device *dev, unsigned int reg, int32_t val) |
Write the alarm value to the specified register. More... | |
Variables | |
const uint16_t | max31827_conversions [8] |
MAX31827 conversion period in ms. More... | |
const uint16_t | max31827_resolutions [4] |
MAX31827 temperature resolution. More... | |
const int | max31827_conv_times [4] |
MAX31827 temperature conversion times in us. More... | |
Implementation of MAX31827 Driver.
Copyright 2024(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MAX31827_ALRM_POL_HIGH 0x1 |
#define MAX31827_ALRM_POL_LOW 0x0 |
#define MAX31827_CONF_1SHOT_MASK NO_OS_BIT(0) |
#define MAX31827_CONF_ALRM_POL_MASK NO_OS_BIT(8) |
#define MAX31827_CONF_CNV_RATE | ( | x | ) | no_os_field_get(MAX31827_CONF_CNV_RATE_MASK, x) |
#define MAX31827_CONF_CNV_RATE_MASK NO_OS_GENMASK(3, 1) |
#define MAX31827_CONF_COMP_INT_MASK NO_OS_BIT(9) |
#define MAX31827_CONF_FLT_Q_MASK NO_OS_GENMASK(11, 10) |
#define MAX31827_CONF_O_TEMP_STAT | ( | x | ) | no_os_field_get(MAX31827_CONF_O_TEMP_STAT_MASK, x) |
#define MAX31827_CONF_O_TEMP_STAT_MASK NO_OS_BIT(15) |
#define MAX31827_CONF_PEC_EN_MASK NO_OS_BIT(4) |
#define MAX31827_CONF_REG 0x2 |
#define MAX31827_CONF_RESO | ( | x | ) | no_os_field_get(MAX31827_CONF_RESO_MASK, x) |
#define MAX31827_CONF_RESO_MASK NO_OS_GENMASK(7, 6) |
#define MAX31827_CONF_TIMEOUT_MASK NO_OS_BIT(5) |
#define MAX31827_CONF_U_TEMP_STAT | ( | x | ) | no_os_field_get(MAX31827_CONF_U_TEMP_STAT_MASK, x) |
#define MAX31827_CONF_U_TEMP_STAT_MASK NO_OS_BIT(14) |
#define MAX31827_DEVICE_ENABLE | ( | x | ) | ((x) ? 0xA : 0x0) |
#define MAX31827_FLT_Q_1 0x0 |
#define MAX31827_FLT_Q_4 0x2 |
#define MAX31827_M_DGR_TO_16_BIT | ( | x | ) | (((x) << 4) / 1000) |
#define MAX31827_T_REG 0x0 |
#define MAX31827_TH_HYST_REG 0x8 |
#define MAX31827_TH_REG 0x4 |
#define MAX31827_TL_HYST_REG 0xA |
#define MAX31827_TL_REG 0x6 |
enum max31827_cnv |
enum max31827_resolution |
int max31827_init | ( | struct max31827_device ** | dev, |
struct max31827_init_param * | init_param | ||
) |
Device and comm init function.
Device and comm init function
dev | - MAX31827 descriptor to be initialized |
init_param | - Init parameter for descriptor |
int max31827_init_client | ( | struct max31827_device * | dev, |
struct max31827_init_param * | init_param | ||
) |
Initialize MAX31827 device setup.
Initialize MAX31827 device setup
dev | - MAX31827 descriptor to be initialized |
init_param | - Init parameter for descriptor |
int max31827_read_temp | ( | struct max31827_device * | dev, |
uint8_t | addr, | ||
int32_t * | val | ||
) |
Read a temperature from a register.
Read a temperature from a register
dev | - MAX31827 descriptor |
addr | - register address |
val | - temperature value |
int max31827_read_temp_input | ( | struct max31827_device * | dev, |
int32_t * | val | ||
) |
Read input temperature.
Read input temperature
dev | - MAX31827 descriptor |
val | - temperature value |
For 12-bit resolution the conversion time is 140 ms, thus an additional 15 ms is needed to complete the conversion: 125 ms + 15 ms = 140 ms
int max31827_reg_read | ( | struct max31827_device * | dev, |
uint8_t | addr, | ||
uint16_t * | val | ||
) |
Read a register value.
Read a register value
dev | - MAX31827 descriptor |
addr | - register address |
val | - register value |
int max31827_reg_update_bits | ( | struct max31827_device * | dev, |
uint8_t | addr, | ||
uint16_t | mask, | ||
uint16_t | val | ||
) |
Read-modify-write operation.
Read-modify-write operation
dev | - MAX31827 descriptor |
addr | - register address |
mask | - Mask for specific register bits to be updated |
val | - register value |
int max31827_reg_write | ( | struct max31827_device * | dev, |
uint8_t | addr, | ||
uint16_t | val | ||
) |
Write a register value.
Write a register value
dev | - MAX31827 descriptor |
addr | - register address |
val | - register value |
int max31827_remove | ( | struct max31827_device * | dev | ) |
Free resources allocated by the init function.
Free resources allocated by the init function
dev | - MAX31827 descriptor |
int max31827_shutdown_write | ( | struct max31827_device * | dev, |
uint8_t | reg, | ||
uint16_t | mask, | ||
uint16_t | val | ||
) |
Shutdown then write register value.
Shutdown then write register value
dev | - MAX31827 descriptor |
reg | - register address |
mask | - Mask for specific register bits to be updated |
val | - register value (requires prior bit shifting) |
Before the Temperature Threshold Alarm, Alarm Hysteresis Threshold and Resolution bits from Configuration register are changed over I2C, the part must be in shutdown mode.
int max31827_write_alarm_val | ( | struct max31827_device * | dev, |
unsigned int | reg, | ||
int32_t | val | ||
) |
Write the alarm value to the specified register.
Write the alarm value to the specified register
dev | - MAX31827 descriptor |
reg | - register address |
val | - temperature value |
const int max31827_conv_times[4] |
MAX31827 temperature conversion times in us.
const uint16_t max31827_conversions[8] |
MAX31827 conversion period in ms.
const uint16_t max31827_resolutions[4] |
MAX31827 temperature resolution.