43#define CHIP_NAME "Maxim Integrated MAX31865"
44#define MANUFACTURER_NAME "Maxim Integrated"
45#define SUPPLY_VOLTAGE_MIN 3.0f
46#define SUPPLY_VOLTAGE_MAX 3.6f
47#define MAX_CURRENT 5.75f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 2000
55#define MAX31865_REG_CONFIG 0x00
56#define MAX31865_REG_RTD_MSB 0x01
57#define MAX31865_REG_RTD_LSB 0x02
58#define MAX31865_REG_HIGH_FAULT_MSB 0x03
59#define MAX31865_REG_HIGH_FAULT_LSB 0x04
60#define MAX31865_REG_LOW_FAULT_MSB 0x05
61#define MAX31865_REG_LOW_FAULT_LSB 0x06
62#define MAX31865_REG_FAULT_STATUS 0x07
67#define WRITE_ADDRESS_MASK 0x80
68#define RTD_A 3.9083e-3f
69#define RTD_B -5.775e-7f
79static float a_max31865_temperature_conversion(
float rt,
float rtd_nominal,
float ref_resistor)
81 float z1, z2, z3, z4, temp;
88 z3 = (4 *
RTD_B) / rtd_nominal;
90 temp = z2 + (z3 * rt);
91 temp = (sqrtf(temp) + z1) / z4;
100 temp += 2.2228f * rpoly;
102 temp += 2.5859e-3f * rpoly;
104 temp -= 4.8260e-6f * rpoly;
106 temp -= 2.8183e-8f * rpoly;
108 temp += 1.5243e-10f * rpoly;
135 handle->
debug_print(
"max31865: spi_init is null.\n");
141 handle->
debug_print(
"max31865: spi_deinit is null.\n");
147 handle->
debug_print(
"max31865: spi_read is null.\n");
153 handle->
debug_print(
"max31865: spi_write is null.\n");
159 handle->
debug_print(
"max31865: delay_ms is null.\n");
166 handle->
debug_print(
"max31865: spi init failed.\n");
216 handle->
debug_print(
"max31865: spi deinit failed.\n");
446 handle->
resistor = (uint8_t)resistor;
636 threshold = threshold << 1;
637 buf[0] = (uint8_t)((threshold >> 8) & 0xFF);
638 buf[1] = (uint8_t)(threshold & 0xFF);
675 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
676 *threshold = (*threshold) >> 1;
705 threshold = threshold << 1;
706 buf[0] = (uint8_t)((threshold >> 8) & 0xFF);
707 buf[1] = (uint8_t)(threshold & 0xFF);
744 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
745 *threshold = (*threshold) >> 1;
782 prev |= control << 2;
872 while (((prev & (1 << 5)) != 0) && (times != 0))
890 memset(buf, 0,
sizeof(uint8_t) * 2);
898 *raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
899 if (((*raw) & 0x01) != 0)
901 handle->
debug_print(
"max31865: find rtd fault.\n");
907 (*raw) = (*raw) >> 1;
917 *temp = a_max31865_temperature_conversion((
float)(*raw), resistor, handle->
ref_resistor);
1027 memset(buf, 0,
sizeof(uint8_t) * 2);
1035 *raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1036 if (((*raw) & 0x01) != 0)
1038 handle->
debug_print(
"max31865: find rtd fault.\n");
1044 (*raw) = (*raw) >> 1;
1054 *temp = a_max31865_temperature_conversion((
float)(*raw), resistor, handle->
ref_resistor);
1108 return handle->
spi_read(reg, (uint8_t *)value, 1);
#define MAX31865_REG_FAULT_STATUS
#define SUPPLY_VOLTAGE_MAX
#define WRITE_ADDRESS_MASK
calculate definition
#define MAX31865_REG_LOW_FAULT_MSB
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define MAX31865_REG_HIGH_FAULT_MSB
#define MAX31865_REG_CONFIG
chip register definition
#define MAX31865_REG_RTD_MSB
#define CHIP_NAME
chip information definition
driver max31865 header file
uint8_t max31865_set_low_fault_threshold(max31865_handle_t *handle, uint16_t threshold)
set the low fault threshold
uint8_t max31865_get_wire(max31865_handle_t *handle, max31865_wire_t *wire)
get the pt resistor wire
max31865_bool_t
max31865 bool enumeration definition
uint8_t max31865_set_vbias(max31865_handle_t *handle, max31865_bool_t enable)
set the chip vbias
uint8_t max31865_set_wire(max31865_handle_t *handle, max31865_wire_t wire)
set the pt resistor wire
uint8_t max31865_get_reference_resistor(max31865_handle_t *handle, float *value)
get the reference resistor
struct max31865_info_s max31865_info_t
max31865 information structure definition
uint8_t max31865_continuous_read(max31865_handle_t *handle, uint16_t *raw, float *temp)
read data continuously
max31865_resistor_t
max31865 resistor type enumeration definition
uint8_t max31865_single_read(max31865_handle_t *handle, uint16_t *raw, float *temp)
read data once
uint8_t max31865_init(max31865_handle_t *handle)
initialize the chip
uint8_t max31865_set_resistor(max31865_handle_t *handle, max31865_resistor_t resistor)
set the pt resistor
max31865_fault_detection_cycle_control_t
max31865 fault detection cycle control enumeration definition
max31865_wire_t
max31865 wire type enumeration definition
uint8_t max31865_get_resistor(max31865_handle_t *handle, max31865_resistor_t *resistor)
get the pt resistor
uint8_t max31865_set_reference_resistor(max31865_handle_t *handle, float value)
set the reference resistor
uint8_t max31865_set_fault_detection_cycle_control(max31865_handle_t *handle, max31865_fault_detection_cycle_control_t control)
set the fault detection cycle control
uint8_t max31865_get_fault_status(max31865_handle_t *handle, uint8_t *status)
get the fault status
uint8_t max31865_set_filter_select(max31865_handle_t *handle, max31865_filter_select_t filter)
set the filter type
uint8_t max31865_get_filter_select(max31865_handle_t *handle, max31865_filter_select_t *filter)
get the filter type
max31865_fault_detection_cycle_control_status_t
max31865 fault detection cycle control status enumeration definition
uint8_t max31865_get_low_fault_threshold(max31865_handle_t *handle, uint16_t *threshold)
get the low fault threshold
uint8_t max31865_get_fault_detection_cycle_control(max31865_handle_t *handle, max31865_fault_detection_cycle_control_status_t *status)
get the fault detection cycle control
uint8_t max31865_clear_fault_status(max31865_handle_t *handle)
clear all fault status
uint8_t max31865_stop_continuous_read(max31865_handle_t *handle)
stop reading
uint8_t max31865_get_vbias(max31865_handle_t *handle, max31865_bool_t *enable)
get the chip vbias
struct max31865_handle_s max31865_handle_t
max31865 handle structure definition
uint8_t max31865_info(max31865_info_t *info)
get chip's information
uint8_t max31865_set_high_fault_threshold(max31865_handle_t *handle, uint16_t threshold)
set the high fault threshold
uint8_t max31865_get_high_fault_threshold(max31865_handle_t *handle, uint16_t *threshold)
get the high fault threshold
max31865_filter_select_t
max31865 filter select enumeration definition
uint8_t max31865_start_continuous_read(max31865_handle_t *handle)
start reading
uint8_t max31865_deinit(max31865_handle_t *handle)
close the chip
@ MAX31865_RESISTOR_100PT
uint8_t max31865_get_reg(max31865_handle_t *handle, uint8_t reg, uint8_t *value)
get the chip register
uint8_t max31865_set_reg(max31865_handle_t *handle, uint8_t reg, uint8_t value)
set the chip register
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v