no-OS
Classes | Macros | Functions
max31865.h File Reference

Header File of MAX31865 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_util.h"
Include dependency graph for max31865.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  max31865_dev
 Structure holding max31865 descriptor. More...
 
struct  max31865_init_param
 Structure holding the parameters for max31865 initialization. More...
 

Macros

#define MAX31865_READ_MASK   0x7F
 
#define MAX31865_WRITE_MASK   0x80
 
#define MAX31865_CONFIG_BIAS   0x80
 
#define MAX31865_CONFIG_MODEAUTO   0x40
 
#define MAX31865_CONFIG_MODEOFF   0xBF
 
#define MAX31865_CONFIG_1SHOT   0x20
 
#define MAX31865_CONFIG_3WIRE   0x10
 
#define MAX31865_CONFIG_2_4WIRE   0xEF
 
#define MAX31865_CONFIG_CLRFAULT_MASK   0xD3
 
#define MAX31865_CONFIG_FAULTSTAT   0x02
 
#define MAX31865_CONFIG_FILT50HZ   0x01
 
#define MAX31865_CONFIG_FILT60HZ   0xFE
 
#define MAX31865_CONFIG_REG   0x00
 
#define MAX31865_RTDMSB_REG   0x01
 
#define MAX31865_RTDLSB_REG   0x02
 
#define MAX31865_HFAULTMSB_REG   0x03
 
#define MAX31865_HFAULTLSB_REG   0x04
 
#define MAX31865_LFAULTMSB_REG   0x05
 
#define MAX31865_LFAULTLSB_REG   0x06
 
#define MAX31865_FAULTSTAT_REG   0x07
 

Functions

int max31865_init (struct max31865_dev **, struct max31865_init_param *)
 Device and comm init function. More...
 
int max31865_remove (struct max31865_dev *)
 Remove resources allocated by the init function. More...
 
int max31865_reg_update (struct max31865_dev *, uint8_t, uint8_t, bool)
 update register contents More...
 
int max31865_read (struct max31865_dev *, uint8_t, uint8_t *)
 Read raw register value. More...
 
int max31865_write (struct max31865_dev *, uint8_t, uint8_t)
 Write raw register value. More...
 
int max31865_read_fault (struct max31865_dev *, uint8_t *)
 
int max31865_clear_fault (struct max31865_dev *)
 Clear all faults in FAULTSTAT. More...
 
int max31865_enable_bias (struct max31865_dev *, bool)
 Enable the bias voltage on the RTD sensor. More...
 
int max31865_auto_convert (struct max31865_dev *, bool)
 Option for continuous conversions between 50/60 Hz. More...
 
int max31865_enable_50Hz (struct max31865_dev *, bool)
 Option for 50Hz or 60Hz noise filters. More...
 
int max31865_set_threshold (struct max31865_dev *, uint16_t, uint16_t)
 Update the contents of the HIGH and LOW FAULT registers of max31865. More...
 
int max31865_get_lower_threshold (struct max31865_dev *, uint16_t *)
 Read the raw 16-bit lower threshold value. More...
 
int max31865_get_upper_threshold (struct max31865_dev *, uint16_t *)
 Read the raw 16-bit upper threshold value. More...
 
int max31865_set_wires (struct max31865_dev *, bool)
 N-wire option for RTD measurement setup. More...
 
int max31865_read_rtd (struct max31865_dev *, uint16_t *)
 Read the raw 16-bit value from the RTD_REG in one shot mode. More...
 

Detailed Description

Header File of MAX31865 Driver.

Author
JSanBuen (jose..nosp@m.sanb.nosp@m.uenav.nosp@m.entu.nosp@m.ra@an.nosp@m.alog.nosp@m..com)
MSosa (marcp.nosp@m.aolo.nosp@m..sosa.nosp@m.@ana.nosp@m.log.c.nosp@m.om)

Copyright 2023(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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Macro Definition Documentation

◆ MAX31865_CONFIG_1SHOT

#define MAX31865_CONFIG_1SHOT   0x20

◆ MAX31865_CONFIG_2_4WIRE

#define MAX31865_CONFIG_2_4WIRE   0xEF

◆ MAX31865_CONFIG_3WIRE

#define MAX31865_CONFIG_3WIRE   0x10

◆ MAX31865_CONFIG_BIAS

#define MAX31865_CONFIG_BIAS   0x80

◆ MAX31865_CONFIG_CLRFAULT_MASK

#define MAX31865_CONFIG_CLRFAULT_MASK   0xD3

◆ MAX31865_CONFIG_FAULTSTAT

#define MAX31865_CONFIG_FAULTSTAT   0x02

◆ MAX31865_CONFIG_FILT50HZ

#define MAX31865_CONFIG_FILT50HZ   0x01

◆ MAX31865_CONFIG_FILT60HZ

#define MAX31865_CONFIG_FILT60HZ   0xFE

◆ MAX31865_CONFIG_MODEAUTO

#define MAX31865_CONFIG_MODEAUTO   0x40

◆ MAX31865_CONFIG_MODEOFF

#define MAX31865_CONFIG_MODEOFF   0xBF

◆ MAX31865_CONFIG_REG

#define MAX31865_CONFIG_REG   0x00

◆ MAX31865_FAULTSTAT_REG

#define MAX31865_FAULTSTAT_REG   0x07

◆ MAX31865_HFAULTLSB_REG

#define MAX31865_HFAULTLSB_REG   0x04

◆ MAX31865_HFAULTMSB_REG

#define MAX31865_HFAULTMSB_REG   0x03

◆ MAX31865_LFAULTLSB_REG

#define MAX31865_LFAULTLSB_REG   0x06

◆ MAX31865_LFAULTMSB_REG

#define MAX31865_LFAULTMSB_REG   0x05

◆ MAX31865_READ_MASK

#define MAX31865_READ_MASK   0x7F

◆ MAX31865_RTDLSB_REG

#define MAX31865_RTDLSB_REG   0x02

◆ MAX31865_RTDMSB_REG

#define MAX31865_RTDMSB_REG   0x01

◆ MAX31865_WRITE_MASK

#define MAX31865_WRITE_MASK   0x80

Function Documentation

◆ max31865_auto_convert()

int max31865_auto_convert ( struct max31865_dev device,
bool  auto_conv_en 
)

Option for continuous conversions between 50/60 Hz.

Enable auto-convert

Parameters
deviceMAX31865 descriptor
auto_conv_enIf true, auto conversion is enabled
Returns
0 in case of success, negative error code otherwise

◆ max31865_clear_fault()

int max31865_clear_fault ( struct max31865_dev device)

Clear all faults in FAULTSTAT.

Clear all faults

Parameters
deviceMAX31865 descriptor
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max31865_enable_50Hz()

int max31865_enable_50Hz ( struct max31865_dev device,
bool  filt_en 
)

Option for 50Hz or 60Hz noise filters.

Enable 50Hz filter, default is 60Hz

Parameters
deviceMAX31865 descriptor
filt_enIf true, 50Hz noise is filtered, else 60Hz(default)
Returns
0 in case of success, negative error code otherwise

◆ max31865_enable_bias()

int max31865_enable_bias ( struct max31865_dev device,
bool  bias_en 
)

Enable the bias voltage on the RTD sensor.

Enable bias

Parameters
deviceMAX31865 descriptor
bias_enIf true bias is enabled, else disabled
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ 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.

Get Lower threshold

Parameters
deviceMAX31865 descriptor
low_thresholdpointer to hold the 16-bit lower threshold value
Returns
0 in case of success, negative error code otherwise

◆ 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.

Get Upper threshold

Parameters
deviceMAX31865 descriptor
up_thresholdpointer to hold the 16-bit upper threshold value
Returns
0 in case of success, negative error code otherwise

◆ max31865_init()

int max31865_init ( struct max31865_dev **  device,
struct max31865_init_param init_param 
)

Device and comm init function.

Device and comm init function

Parameters
device- MAX31865 descriptor to be initialized
init_param- Init parameters for descriptor
Returns
0 in case of success, errno errors otherwise

◆ max31865_read()

int max31865_read ( struct max31865_dev device,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

Read raw register value.

Read raw register value

Parameters
device- MAX31865 descriptor
reg_addr- register value to read from
reg_data- pointer for register value read
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max31865_read_fault()

int max31865_read_fault ( struct max31865_dev ,
uint8_t *   
)

Read fault register value

◆ 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.

Read RTD

Parameters
deviceMAX31865 descriptor
rtd_regpointer to hold the 16-bit raw RTD_REG value
Returns
0 in case of success, negative error code otherwise

◆ 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

Update Register using given update value

Parameters
device- MAX31865 descriptor
reg_addr- register value to read from
reg_update- mask to update the value of selected register
or_mask- set to true for OR, false for AND masking
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max31865_remove()

int max31865_remove ( struct max31865_dev device)

Remove resources allocated by the init function.

Free resources allocated by the init function

Parameters
device- max31865 descriptor
Returns
0 in case of success, errno errors otherwise

◆ 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.

Set threshold

Parameters
deviceMAX31865 descriptor
lowerraw lower threshold
upperraw upper threshold
Returns
0 in case of success, negative error code otherwise

◆ max31865_set_wires()

int max31865_set_wires ( struct max31865_dev device,
bool  is_odd_wire 
)

N-wire option for RTD measurement setup.

Set Wires

Parameters
deviceMAX31865 descriptor
is_odd_wireIf true, uses 3-wire setup. Else, uses 2/4-wire setup.
Returns
0 in case of success, negative error code otherwise

◆ max31865_write()

int max31865_write ( struct max31865_dev device,
uint8_t  reg_addr,
uint8_t  reg_data 
)

Write raw register value.

Write raw register value

Parameters
device- MAX31865 descriptor
reg_addr- register value to write to
reg_data- data to write in register
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function: