no-OS
max31865.h
Go to the documentation of this file.
1 /***************************************************************************/
35 #ifndef __MAX31865_H__
36 #define __MAX31865_H__
37 
38 /******************************************************************************/
39 /***************************** Include Files **********************************/
40 /******************************************************************************/
41 #include <stdint.h>
42 #include <stdbool.h>
43 #include "no_os_spi.h"
44 #include "no_os_util.h"
45 
46 /******************************************************************************/
47 /********************** Macros and Constants Definitions **********************/
48 /******************************************************************************/
49 #define MAX31865_READ_MASK 0x7F
50 #define MAX31865_WRITE_MASK 0x80
51 
52 #define MAX31865_CONFIG_BIAS 0x80
53 #define MAX31865_CONFIG_MODEAUTO 0x40
54 #define MAX31865_CONFIG_MODEOFF 0xBF
55 #define MAX31865_CONFIG_1SHOT 0x20
56 #define MAX31865_CONFIG_3WIRE 0x10
57 #define MAX31865_CONFIG_2_4WIRE 0xEF
58 #define MAX31865_CONFIG_CLRFAULT_MASK 0xD3
59 #define MAX31865_CONFIG_FAULTSTAT 0x02
60 #define MAX31865_CONFIG_FILT50HZ 0x01
61 #define MAX31865_CONFIG_FILT60HZ 0xFE
62 
63 #define MAX31865_CONFIG_REG 0x00
64 #define MAX31865_RTDMSB_REG 0x01
65 #define MAX31865_RTDLSB_REG 0x02
66 #define MAX31865_HFAULTMSB_REG 0x03
67 #define MAX31865_HFAULTLSB_REG 0x04
68 #define MAX31865_LFAULTMSB_REG 0x05
69 #define MAX31865_LFAULTLSB_REG 0x06
70 #define MAX31865_FAULTSTAT_REG 0x07
71 
76 struct max31865_dev {
78  bool is_filt_50;
81 };
82 
89  float rtd_rc;
90 };
91 
93 int max31865_init(struct max31865_dev **, struct max31865_init_param *);
94 
96 int max31865_remove(struct max31865_dev *);
97 
99 int max31865_reg_update(struct max31865_dev *, uint8_t,uint8_t, bool);
100 
102 int max31865_read(struct max31865_dev *, uint8_t, uint8_t *);
103 
105 int max31865_write(struct max31865_dev *, uint8_t, uint8_t);
106 
108 int max31865_read_fault(struct max31865_dev *, uint8_t *);
109 
111 int max31865_clear_fault(struct max31865_dev *);
112 
114 int max31865_enable_bias(struct max31865_dev *, bool);
115 
117 int max31865_auto_convert(struct max31865_dev *, bool);
118 
120 int max31865_enable_50Hz(struct max31865_dev *, bool);
121 
123 int max31865_set_threshold(struct max31865_dev *, uint16_t, uint16_t);
124 
126 int max31865_get_lower_threshold(struct max31865_dev*, uint16_t *);
127 
129 int max31865_get_upper_threshold(struct max31865_dev*, uint16_t *);
130 
132 int max31865_set_wires(struct max31865_dev *, bool);
133 
135 int max31865_read_rtd(struct max31865_dev *, uint16_t *);
136 
137 #endif // __MAX31865_H__
max31865_read_fault
int max31865_read_fault(struct max31865_dev *, uint8_t *)
MAX31865_CONFIG_3WIRE
#define MAX31865_CONFIG_3WIRE
Definition: max31865.h:56
no_os_alloc.h
max31865_set_threshold
int max31865_set_threshold(struct max31865_dev *device, uint16_t lower, uint16_t upper)
Update the contents of the HIGH and LOW FAULT registers of max31865.
Definition: max31865.c:287
MAX31865_CONFIG_MODEAUTO
#define MAX31865_CONFIG_MODEAUTO
Definition: max31865.h:53
MAX31865_CONFIG_CLRFAULT_MASK
#define MAX31865_CONFIG_CLRFAULT_MASK
Definition: max31865.h:58
max31865_get_lower_threshold
int max31865_get_lower_threshold(struct max31865_dev *, uint16_t *)
Read the raw 16-bit lower threshold value.
Definition: max31865.c:321
max31865_clear_fault
int max31865_clear_fault(struct max31865_dev *device)
Clear all faults in FAULTSTAT.
Definition: max31865.c:217
no_os_spi.h
Header file of SPI Interface.
max31865_set_threshold
int max31865_set_threshold(struct max31865_dev *, uint16_t, uint16_t)
Update the contents of the HIGH and LOW FAULT registers of max31865.
Definition: max31865.c:287
max31865_enable_bias
int max31865_enable_bias(struct max31865_dev *device, bool bias_en)
Enable the bias voltage on the RTD sensor.
Definition: max31865.c:236
MAX31865_CONFIG_FILT50HZ
#define MAX31865_CONFIG_FILT50HZ
Definition: max31865.h:60
no_os_spi_msg
Definition: no_os_spi.h:85
max31865_init
int max31865_init(struct max31865_dev **device, struct max31865_init_param *init_param)
Device and comm init function.
Definition: max31865.c:59
no_os_delay.h
Header file of Delay functions.
max31865_dev
Structure holding max31865 descriptor.
Definition: max31865.h:76
max31865_enable_bias
int max31865_enable_bias(struct max31865_dev *, bool)
Enable the bias voltage on the RTD sensor.
Definition: max31865.c:236
max31865_dev::is_filt_50
bool is_filt_50
Definition: max31865.h:78
MAX31865_RTDLSB_REG
#define MAX31865_RTDLSB_REG
Definition: max31865.h:65
max31865_init_param::rtd_rc
float rtd_rc
Definition: max31865.h:89
MAX31865_CONFIG_BIAS
#define MAX31865_CONFIG_BIAS
Definition: max31865.h:52
device
Definition: ad9361_util.h:69
MAX31865_LFAULTMSB_REG
#define MAX31865_LFAULTMSB_REG
Definition: max31865.h:68
no_os_calloc
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
max31865_read
int max31865_read(struct max31865_dev *device, uint8_t reg_addr, uint8_t *reg_data)
Read raw register value.
Definition: max31865.c:149
MAX31865_READ_MASK
#define MAX31865_READ_MASK
Definition: max31865.h:49
MAX31865_CONFIG_FAULTSTAT
#define MAX31865_CONFIG_FAULTSTAT
Definition: max31865.h:59
MAX31865_CONFIG_MODEOFF
#define MAX31865_CONFIG_MODEOFF
Definition: max31865.h:54
max31865_remove
int max31865_remove(struct max31865_dev *)
Remove resources allocated by the init function.
Definition: max31865.c:100
max31865_read
int max31865_read(struct max31865_dev *, uint8_t, uint8_t *)
Read raw register value.
Definition: max31865.c:149
max31865_enable_50Hz
int max31865_enable_50Hz(struct max31865_dev *device, bool filt_en)
Option for 50Hz or 60Hz noise filters.
Definition: max31865.c:268
max31865_get_upper_threshold
int max31865_get_upper_threshold(struct max31865_dev *device, uint16_t *up_threshold)
Read the raw 16-bit upper threshold value.
Definition: max31865.c:347
no_os_spi_msg::rx_buff
uint8_t * rx_buff
Definition: no_os_spi.h:89
max31865_write
int max31865_write(struct max31865_dev *, uint8_t, uint8_t)
Write raw register value.
Definition: max31865.c:186
max31865_reg_update
int max31865_reg_update(struct max31865_dev *, uint8_t, uint8_t, bool)
update register contents
Definition: max31865.c:124
max31865_enable_50Hz
int max31865_enable_50Hz(struct max31865_dev *, bool)
Option for 50Hz or 60Hz noise filters.
Definition: max31865.c:268
max31865_auto_convert
int max31865_auto_convert(struct max31865_dev *device, bool auto_conv_en)
Option for continuous conversions between 50/60 Hz.
Definition: max31865.c:252
max31865_dev::comm_desc
struct no_os_spi_desc * comm_desc
Definition: max31865.h:77
MAX31865_CONFIG_2_4WIRE
#define MAX31865_CONFIG_2_4WIRE
Definition: max31865.h:57
max31865.h
Header File of MAX31865 Driver.
max31865_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: max31865.h:88
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:171
max31865_init_param
Structure holding the parameters for max31865 initialization.
Definition: max31865.h:87
max31865_clear_fault
int max31865_clear_fault(struct max31865_dev *)
Clear all faults in FAULTSTAT.
Definition: max31865.c:217
MAX31865_WRITE_MASK
#define MAX31865_WRITE_MASK
Definition: max31865.h:50
max31865_reg_update
int max31865_reg_update(struct max31865_dev *device, uint8_t reg_addr, uint8_t reg_update, bool or_mask)
update register contents
Definition: max31865.c:124
max31865_set_wires
int max31865_set_wires(struct max31865_dev *, bool)
N-wire option for RTD measurement setup.
Definition: max31865.c:373
no_os_spi_transfer
int32_t no_os_spi_transfer(struct no_os_spi_desc *desc, struct no_os_spi_msg *msgs, uint32_t len)
Iterate over head list and send all spi messages.
Definition: no_os_spi.c:185
max31865_remove
int max31865_remove(struct max31865_dev *device)
Remove resources allocated by the init function.
Definition: max31865.c:100
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
MAX31865_HFAULTMSB_REG
#define MAX31865_HFAULTMSB_REG
Definition: max31865.h:66
max31865_dev::is_odd_wire
bool is_odd_wire
Definition: max31865.h:79
no_os_free
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
MAX31865_CONFIG_REG
#define MAX31865_CONFIG_REG
Definition: max31865.h:63
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
MAX31865_FAULTSTAT_REG
#define MAX31865_FAULTSTAT_REG
Definition: max31865.h:70
max31865_init
int max31865_init(struct max31865_dev **, struct max31865_init_param *)
Device and comm init function.
Definition: max31865.c:59
max31865_set_wires
int max31865_set_wires(struct max31865_dev *device, bool is_odd_wire)
N-wire option for RTD measurement setup.
Definition: max31865.c:373
MAX31865_LFAULTLSB_REG
#define MAX31865_LFAULTLSB_REG
Definition: max31865.h:69
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
MAX31865_CONFIG_1SHOT
#define MAX31865_CONFIG_1SHOT
Definition: max31865.h:55
max31865_get_lower_threshold
int max31865_get_lower_threshold(struct max31865_dev *device, uint16_t *low_threshold)
Read the raw 16-bit lower threshold value.
Definition: max31865.c:321
MAX31865_CONFIG_FILT60HZ
#define MAX31865_CONFIG_FILT60HZ
Definition: max31865.h:61
max31865_read_rtd
int max31865_read_rtd(struct max31865_dev *device, uint16_t *rtd_reg)
Read the raw 16-bit value from the RTD_REG in one shot mode.
Definition: max31865.c:391
max31865_dev::t_rc_delay
int t_rc_delay
Definition: max31865.h:80
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
MAX31865_RTDMSB_REG
#define MAX31865_RTDMSB_REG
Definition: max31865.h:64
max31865_read_rtd
int max31865_read_rtd(struct max31865_dev *, uint16_t *)
Read the raw 16-bit value from the RTD_REG in one shot mode.
Definition: max31865.c:391
no_os_util.h
Header file of utility functions.
max31865_auto_convert
int max31865_auto_convert(struct max31865_dev *, bool)
Option for continuous conversions between 50/60 Hz.
Definition: max31865.c:252
max31865_write
int max31865_write(struct max31865_dev *device, uint8_t reg_addr, uint8_t reg_data)
Write raw register value.
Definition: max31865.c:186
max31865_get_upper_threshold
int max31865_get_upper_threshold(struct max31865_dev *, uint16_t *)
Read the raw 16-bit upper threshold value.
Definition: max31865.c:347
errno.h
Error macro definition for ARM Compiler.
MAX31865_HFAULTLSB_REG
#define MAX31865_HFAULTLSB_REG
Definition: max31865.h:67
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:125