no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max31827.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef __MAX31827_H__
35#define __MAX31827_H__
36
37#include "no_os_i2c.h"
38#include "no_os_util.h"
39
40#define MAX31827_T_REG 0x0
41#define MAX31827_CONF_REG 0x2
42#define MAX31827_TH_REG 0x4
43#define MAX31827_TL_REG 0x6
44#define MAX31827_TH_HYST_REG 0x8
45#define MAX31827_TL_HYST_REG 0xA
46
47#define MAX31827_CONF_1SHOT_MASK NO_OS_BIT(0)
48#define MAX31827_CONF_CNV_RATE_MASK NO_OS_GENMASK(3, 1)
49#define MAX31827_CONF_PEC_EN_MASK NO_OS_BIT(4)
50#define MAX31827_CONF_TIMEOUT_MASK NO_OS_BIT(5)
51#define MAX31827_CONF_RESO_MASK NO_OS_GENMASK(7, 6)
52#define MAX31827_CONF_ALRM_POL_MASK NO_OS_BIT(8)
53#define MAX31827_CONF_COMP_INT_MASK NO_OS_BIT(9)
54#define MAX31827_CONF_FLT_Q_MASK NO_OS_GENMASK(11, 10)
55#define MAX31827_CONF_U_TEMP_STAT_MASK NO_OS_BIT(14)
56#define MAX31827_CONF_O_TEMP_STAT_MASK NO_OS_BIT(15)
57
58#define MAX31827_CONF_CNV_RATE(x) \
59 no_os_field_get(MAX31827_CONF_CNV_RATE_MASK, x)
60#define MAX31827_CONF_RESO(x) \
61 no_os_field_get(MAX31827_CONF_RESO_MASK, x)
62#define MAX31827_CONF_U_TEMP_STAT(x) \
63 no_os_field_get(MAX31827_CONF_U_TEMP_STAT_MASK, x)
64#define MAX31827_CONF_O_TEMP_STAT(x) \
65 no_os_field_get(MAX31827_CONF_O_TEMP_STAT_MASK, x)
66
67#define MAX31827_ALRM_POL_LOW 0x0
68#define MAX31827_ALRM_POL_HIGH 0x1
69#define MAX31827_FLT_Q_1 0x0
70#define MAX31827_FLT_Q_4 0x2
71
72#define MAX31827_M_DGR_TO_16_BIT(x) (((x) << 4) / 1000)
73#define MAX31827_DEVICE_ENABLE(x) ((x) ? 0xA : 0x0)
74
87
97
101extern const uint16_t max31827_conversions[8];
102
106extern const uint16_t max31827_resolutions[4];
107
111extern const int max31827_conv_times[4];
112
120 bool enable;
122 unsigned int resolution;
124 unsigned int update_interval;
125};
126
142
144int max31827_reg_read(struct max31827_device *dev, uint8_t addr, uint16_t *val);
145
147int max31827_reg_write(struct max31827_device *dev, uint8_t addr, uint16_t val);
148
150int max31827_reg_update_bits(struct max31827_device *dev, uint8_t addr,
151 uint16_t mask, uint16_t val);
152
154int max31827_init(struct max31827_device **dev,
156
158int max31827_remove(struct max31827_device *dev);
159
163
165int max31827_read_temp(struct max31827_device *dev, uint8_t addr, int32_t *val);
166
168int max31827_read_temp_input(struct max31827_device *dev, int32_t *val);
169
171int max31827_shutdown_write(struct max31827_device *dev, uint8_t reg,
172 uint16_t mask, uint16_t val);
173
175int max31827_write_alarm_val(struct max31827_device *dev, unsigned int reg,
176 int32_t val);
177
178#endif /* __MAX31827_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
const int max31827_conv_times[]
MAX31827 temperature conversion times in us.
Definition max31827.c:69
const uint16_t max31827_resolutions[]
MAX31827 temperature resolution.
Definition max31827.c:59
const uint16_t max31827_conversions[]
MAX31827 conversion period in ms.
Definition max31827.c:46
int max31827_shutdown_write(struct max31827_device *dev, uint8_t reg, uint16_t mask, uint16_t val)
Shutdown then write register value.
Definition max31827.c:306
int max31827_remove(struct max31827_device *dev)
Free resources allocated by the init function.
Definition max31827.c:189
max31827_cnv
MAX31827 conversion rate.
Definition max31827.h:78
@ MAX31827_CNV_1_DIV_16_HZ
Definition max31827.h:81
@ MAX31827_CNV_1_HZ
Definition max31827.h:83
@ MAX31827_CNV_1_DIV_4_HZ
Definition max31827.h:82
@ MAX31827_CNV_1_DIV_32_HZ
Definition max31827.h:80
@ MAX31827_CNV_4_HZ
Definition max31827.h:84
@ MAX31827_CNV_8_HZ
Definition max31827.h:85
@ MAX31827_CNV_1_DIV_64_HZ
Definition max31827.h:79
int max31827_read_temp(struct max31827_device *dev, uint8_t addr, int32_t *val)
Read a temperature from a register.
Definition max31827.c:250
int max31827_reg_write(struct max31827_device *dev, uint8_t addr, uint16_t val)
Write a register value.
Definition max31827.c:110
int max31827_read_temp_input(struct max31827_device *dev, int32_t *val)
Read input temperature.
Definition max31827.c:273
int max31827_reg_read(struct max31827_device *dev, uint8_t addr, uint16_t *val)
Read a register value.
Definition max31827.c:85
int max31827_init_client(struct max31827_device *dev, struct max31827_init_param *init_param)
Initialize MAX31827 device setup.
Definition max31827.c:211
int max31827_reg_update_bits(struct max31827_device *dev, uint8_t addr, uint16_t mask, uint16_t val)
Read-modify-write operation.
Definition max31827.c:125
max31827_resolution
MAX31827 temperature resolution.
Definition max31827.h:91
@ MAX31827_RES_9_BIT
Definition max31827.h:93
@ MAX31827_RES_10_BIT
Definition max31827.h:94
@ MAX31827_RES_8_BIT
Definition max31827.h:92
@ MAX31827_RES_12_BIT
Definition max31827.h:95
int max31827_init(struct max31827_device **dev, struct max31827_init_param *init_param)
Device and comm init function.
Definition max31827.c:147
int max31827_write_alarm_val(struct max31827_device *dev, unsigned int reg, int32_t val)
Write the alarm value to the specified register.
Definition max31827.c:353
Header file of I2C Interface.
Header file of utility functions.
MAX31827 descriptor.
Definition max31827.h:116
unsigned int resolution
Definition max31827.h:122
bool enable
Definition max31827.h:120
struct no_os_i2c_desc * i2c_desc
Definition max31827.h:118
unsigned int update_interval
Definition max31827.h:124
MAX31827 init param.
Definition max31827.h:130
struct no_os_i2c_init_param i2c_init_param
Definition max31827.h:132
bool timeout_enable
Definition max31827.h:140
uint8_t fault_q
Definition max31827.h:138
bool comp_int
Definition max31827.h:134
bool alarm_pol
Definition max31827.h:136
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52