Go to the documentation of this file.
34 #ifndef __MAX31827_H__
35 #define __MAX31827_H__
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
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)
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)
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
72 #define MAX31827_M_DGR_TO_16_BIT(x) (((x) << 4) / 1000)
73 #define MAX31827_DEVICE_ENABLE(x) ((x) ? 0xA : 0x0)
151 uint16_t mask, uint16_t val);
172 uint16_t mask, uint16_t val);
const int max31827_conv_times[4]
MAX31827 temperature conversion times in us.
Definition: max31827.c:77
#define MILLI
Definition: no_os_units.h:48
MAX31827 init param.
Definition: max31827.h:130
bool alarm_pol
Definition: max31827.h:136
@ MAX31827_RES_12_BIT
Definition: max31827.h:95
@ MAX31827_RES_10_BIT
Definition: max31827.h:94
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
int max31827_remove(struct max31827_device *dev)
Free resources allocated by the init function.
Definition: max31827.c:200
struct no_os_i2c_init_param i2c_init_param
Definition: max31827.h:132
unsigned int resolution
Definition: max31827.h:122
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:317
int max31827_init_client(struct max31827_device *dev, struct max31827_init_param *init_param)
Initialize MAX31827 device setup.
Definition: max31827.c:222
unsigned int update_interval
Definition: max31827.h:124
@ MAX31827_RES_9_BIT
Definition: max31827.h:93
int max31827_reg_write(struct max31827_device *dev, uint8_t addr, uint16_t val)
Write a register value.
Definition: max31827.c:121
int max31827_reg_read(struct max31827_device *dev, uint8_t addr, uint16_t *val)
Read a register value.
Definition: max31827.c:96
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
int max31827_reg_write(struct max31827_device *dev, uint8_t addr, uint16_t val)
Write a register value.
Definition: max31827.c:121
int max31827_read_temp_input(struct max31827_device *dev, int32_t *val)
Read input temperature.
Definition: max31827.c:284
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:88
Header file of Delay functions.
#define MAX31827_DEVICE_ENABLE(x)
Definition: max31827.h:73
bool comp_int
Definition: max31827.h:134
#define MAX31827_CONF_1SHOT_MASK
Definition: max31827.h:47
const int max31827_conv_times[]
MAX31827 temperature conversion times in us.
Definition: max31827.c:77
const uint16_t max31827_conversions[8]
MAX31827 conversion period in ms.
Definition: max31827.c:54
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
int max31827_remove(struct max31827_device *dev)
Free resources allocated by the init function.
Definition: max31827.c:200
#define MAX31827_CONF_FLT_Q_MASK
Definition: max31827.h:54
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:317
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:136
Implementation of MAX31827 Driver.
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:136
@ MAX31827_CNV_1_DIV_16_HZ
Definition: max31827.h:81
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
#define MAX31827_CONF_CNV_RATE_MASK
Definition: max31827.h:48
#define MAX31827_CONF_COMP_INT_MASK
Definition: max31827.h:53
@ MAX31827_CNV_1_DIV_64_HZ
Definition: max31827.h:79
int max31827_init_client(struct max31827_device *dev, struct max31827_init_param *init_param)
Initialize MAX31827 device setup.
Definition: max31827.c:222
int max31827_read_temp(struct max31827_device *dev, uint8_t addr, int32_t *val)
Read a temperature from a register.
Definition: max31827.c:261
#define MAX31827_CONF_RESO_MASK
Definition: max31827.h:51
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:364
int max31827_reg_read(struct max31827_device *dev, uint8_t addr, uint16_t *val)
Read a register value.
Definition: max31827.c:96
@ MAX31827_CNV_1_HZ
Definition: max31827.h:83
@ MAX31827_CNV_4_HZ
Definition: max31827.h:84
int max31827_read_temp_input(struct max31827_device *dev, int32_t *val)
Read input temperature.
Definition: max31827.c:284
@ MAX31827_RES_8_BIT
Definition: max31827.h:92
bool enable
Definition: max31827.h:120
#define MAX31827_CONF_ALRM_POL_MASK
Definition: max31827.h:52
@ MAX31827_CNV_1_DIV_32_HZ
Definition: max31827.h:80
max31827_resolution
MAX31827 temperature resolution.
Definition: max31827.h:91
int max31827_init(struct max31827_device **dev, struct max31827_init_param *init_param)
Device and comm init function.
Definition: max31827.c:158
const uint16_t max31827_conversions[]
MAX31827 conversion period in ms.
Definition: max31827.c:54
#define MAX31827_CONF_TIMEOUT_MASK
Definition: max31827.h:50
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
const uint16_t max31827_resolutions[4]
MAX31827 temperature resolution.
Definition: max31827.c:67
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
Header file of I2C Interface.
struct no_os_i2c_desc * i2c_desc
Definition: max31827.h:118
MAX31827 descriptor.
Definition: max31827.h:116
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
bool timeout_enable
Definition: max31827.h:140
@ MAX31827_CNV_8_HZ
Definition: max31827.h:85
int max31827_init(struct max31827_device **dev, struct max31827_init_param *init_param)
Device and comm init function.
Definition: max31827.c:158
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int max31827_read_temp(struct max31827_device *dev, uint8_t addr, int32_t *val)
Read a temperature from a register.
Definition: max31827.c:261
#define MAX31827_CONF_REG
Definition: max31827.h:41
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
@ MAX31827_CNV_1_DIV_4_HZ
Definition: max31827.h:82
Header file of utility functions.
uint32_t no_os_find_first_set_bit(uint32_t word)
unsigned int no_os_hweight32(uint32_t word)
int32_t no_os_sign_extend32(uint32_t value, int index)
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:364
#define MAX31827_T_REG
Definition: max31827.h:40
uint8_t fault_q
Definition: max31827.h:138
max31827_cnv
MAX31827 conversion rate.
Definition: max31827.h:78
const uint16_t max31827_resolutions[]
MAX31827 temperature resolution.
Definition: max31827.c:67