LibDriver MAX31856
Loading...
Searching...
No Matches
driver_max31856.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MAX31856_H
38#define DRIVER_MAX31856_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
78
87
96
108
125
138
153
157typedef struct max31856_handle_s
158{
159 uint8_t (*spi_init)(void);
160 uint8_t (*spi_deinit)(void);
161 uint8_t (*spi_read)(uint8_t reg, uint8_t *buf, uint16_t len);
162 uint8_t (*spi_write)(uint8_t reg, uint8_t *buf, uint16_t len);
163 void (*delay_ms)(uint32_t ms);
164 void (*debug_print)(const char *const fmt, ...);
165 void (*receive_callback)(uint8_t type);
166 uint8_t inited;
168
184
188
195
202#define DRIVER_MAX31856_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
203
210#define DRIVER_MAX31856_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
211
218#define DRIVER_MAX31856_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
219
226#define DRIVER_MAX31856_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
227
234#define DRIVER_MAX31856_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
235
242#define DRIVER_MAX31856_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
243
250#define DRIVER_MAX31856_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
251
258#define DRIVER_MAX31856_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
259
263
270
279uint8_t max31856_info(max31856_info_t *info);
280
292
303uint8_t max31856_init(max31856_handle_t *handle);
304
316uint8_t max31856_deinit(max31856_handle_t *handle);
317
335uint8_t max31856_single_read(max31856_handle_t *handle, int32_t *raw, double *deg);
336
354uint8_t max31856_continuous_read(max31856_handle_t *handle, int32_t *raw, double *deg);
355
367
379
392uint8_t max31856_read_cold_junction_temperature(max31856_handle_t *handle, int16_t *raw, double *deg);
393
406
419
432
445
458
471
483
496
509
522
535
548
561
575
589
602
615
628
640uint8_t max31856_get_cold_junction_low_fault_threshold(max31856_handle_t *handle, int8_t *threshold);
641
653uint8_t max31856_set_temperature_high_fault_threshold(max31856_handle_t *handle, int16_t threshold);
654
666uint8_t max31856_get_temperature_high_fault_threshold(max31856_handle_t *handle, int16_t *threshold);
667
679uint8_t max31856_set_temperature_low_fault_threshold(max31856_handle_t *handle, int16_t threshold);
680
692uint8_t max31856_get_temperature_low_fault_threshold(max31856_handle_t *handle, int16_t *threshold);
693
706
719
731uint8_t max31856_set_cold_junction_temperature(max31856_handle_t *handle, int16_t temperature);
732
744uint8_t max31856_get_cold_junction_temperature(max31856_handle_t *handle, int16_t *temperature);
745
757uint8_t max31856_get_fault_status(max31856_handle_t *handle, uint8_t *status);
758
771
784
797
809uint8_t max31856_temperature_fault_threshold_convert_to_data(max31856_handle_t *handle, int16_t reg, float *deg);
810
823
836
848uint8_t max31856_cold_junction_temperature_convert_to_register(max31856_handle_t *handle, float deg, int16_t *reg);
849
861uint8_t max31856_cold_junction_temperature_convert_to_data(max31856_handle_t *handle, int16_t reg, float *deg);
862
866
873
887uint8_t max31856_set_reg(max31856_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
888
902uint8_t max31856_get_reg(max31856_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
903
907
911
912#ifdef __cplusplus
913}
914#endif
915
916#endif
uint8_t max31856_stop_continuous_read(max31856_handle_t *handle)
stop the chip reading
struct max31856_info_s max31856_info_t
max31856 information structure definition
uint8_t max31856_set_cold_junction_high_fault_threshold(max31856_handle_t *handle, int8_t threshold)
set cold junction high fault threshold
uint8_t max31856_get_fault_status(max31856_handle_t *handle, uint8_t *status)
get fault status
uint8_t max31856_set_cold_junction_sensor(max31856_handle_t *handle, max31856_bool_t enable)
enable or disable cold junction sensor
uint8_t max31856_set_thermocouple_type(max31856_handle_t *handle, max31856_thermocouple_type_t type)
set thermocouple type
max31856_fault_status_t
max31856 fault status enumeration definition
max31856_bool_t
max31856 bool enumeration definition
uint8_t max31856_info(max31856_info_t *info)
get chip's information
uint8_t max31856_clear_fault(max31856_handle_t *handle)
clear fault
uint8_t max31856_get_cold_junction_sensor(max31856_handle_t *handle, max31856_bool_t *enable)
get cold junction sensor status
uint8_t max31856_get_fault_mode(max31856_handle_t *handle, max31856_fault_mode_t *mode)
get fault mode
uint8_t max31856_single_read(max31856_handle_t *handle, int32_t *raw, double *deg)
read data from the chip once
uint8_t max31856_start_continuous_read(max31856_handle_t *handle)
start the chip reading
uint8_t max31856_cold_junction_temperature_convert_to_data(max31856_handle_t *handle, int16_t reg, float *deg)
convert the register raw data to the cold junction temperature
uint8_t max31856_set_fault_mask(max31856_handle_t *handle, max31856_fault_mask_t mask, max31856_bool_t enable)
set fault mask
uint8_t max31856_set_open_circuit_detection(max31856_handle_t *handle, max31856_open_circuit_detection_t detection)
set open circuit detection
uint8_t max31856_get_temperature_low_fault_threshold(max31856_handle_t *handle, int16_t *threshold)
get temperature low fault threshold
max31856_open_circuit_detection_t
max31856 open circuit detection enumeration definition
uint8_t max31856_get_temperature_high_fault_threshold(max31856_handle_t *handle, int16_t *threshold)
get temperature high fault threshold
uint8_t max31856_get_thermocouple_type(max31856_handle_t *handle, max31856_thermocouple_type_t *type)
get thermocouple type
max31856_sample_average_t
max31856 sample average enumeration definition
uint8_t max31856_get_cold_junction_high_fault_threshold(max31856_handle_t *handle, int8_t *threshold)
get cold junction high fault threshold
uint8_t max31856_set_temperature_low_fault_threshold(max31856_handle_t *handle, int16_t threshold)
set temperature low fault threshold
uint8_t max31856_get_sample_average(max31856_handle_t *handle, max31856_sample_average_t *average)
get sample average
uint8_t max31856_get_cold_junction_temperature(max31856_handle_t *handle, int16_t *temperature)
get cold junction temperature
uint8_t max31856_get_cold_junction_low_fault_threshold(max31856_handle_t *handle, int8_t *threshold)
get cold junction low fault threshold
max31856_noise_rejection_filter_t
max31856 noise rejection filter enumeration definition
uint8_t max31856_continuous_read(max31856_handle_t *handle, int32_t *raw, double *deg)
read data from the chip continuously
uint8_t max31856_get_fault_mask(max31856_handle_t *handle, max31856_fault_mask_t mask, max31856_bool_t *enable)
get fault mask
uint8_t max31856_temperature_fault_threshold_convert_to_register(max31856_handle_t *handle, float deg, int16_t *reg)
convert the temperature fault threshold to the register raw data
max31856_fault_mode_t
max31856 fault mode enumeration definition
uint8_t max31856_read_cold_junction_temperature(max31856_handle_t *handle, int16_t *raw, double *deg)
read cold junction temperature
uint8_t max31856_deinit(max31856_handle_t *handle)
close the chip
uint8_t max31856_set_noise_rejection_filter(max31856_handle_t *handle, max31856_noise_rejection_filter_t filter)
set noise rejection filter
max31856_thermocouple_type_t
max31856 thermocouple type enumeration definition
uint8_t max31856_get_open_circuit_detection(max31856_handle_t *handle, max31856_open_circuit_detection_t *detection)
get open circuit detection
uint8_t max31856_init(max31856_handle_t *handle)
initialize the chip
uint8_t max31856_set_cold_junction_low_fault_threshold(max31856_handle_t *handle, int8_t threshold)
set cold junction low fault threshold
uint8_t max31856_set_cold_junction_temperature(max31856_handle_t *handle, int16_t temperature)
set cold junction temperature
uint8_t max31856_temperature_fault_threshold_convert_to_data(max31856_handle_t *handle, int16_t reg, float *deg)
convert the register raw data to the temperature fault threshold
struct max31856_handle_s max31856_handle_t
max31856 handle structure definition
uint8_t max31856_get_cold_junction_temperature_offset(max31856_handle_t *handle, int8_t *offset)
get cold junction temperature offset
uint8_t max31856_cold_junction_temperature_convert_to_register(max31856_handle_t *handle, float deg, int16_t *reg)
convert the cold junction temperature to the register raw data
uint8_t max31856_cold_junction_fault_threshold_convert_to_register(max31856_handle_t *handle, float deg, int8_t *reg)
convert the cold junction fault threshold to the register raw data
uint8_t max31856_set_sample_average(max31856_handle_t *handle, max31856_sample_average_t average)
set sample average
uint8_t max31856_cold_junction_temperature_offset_convert_to_register(max31856_handle_t *handle, float deg, int8_t *reg)
convert the cold junction temperature offset to the register raw data
uint8_t max31856_cold_junction_fault_threshold_convert_to_data(max31856_handle_t *handle, int8_t reg, float *deg)
convert the register raw data to the cold junction fault threshold
uint8_t max31856_cold_junction_temperature_offset_convert_to_data(max31856_handle_t *handle, int8_t reg, float *deg)
convert the register raw data to the cold junction temperature offset
uint8_t max31856_set_fault_mode(max31856_handle_t *handle, max31856_fault_mode_t mode)
set fault mode
uint8_t max31856_irq_handler(max31856_handle_t *handle)
irq handler
uint8_t max31856_set_cold_junction_temperature_offset(max31856_handle_t *handle, int8_t offset)
set cold junction temperature offset
uint8_t max31856_set_temperature_high_fault_threshold(max31856_handle_t *handle, int16_t threshold)
set temperature high fault threshold
uint8_t max31856_get_noise_rejection_filter(max31856_handle_t *handle, max31856_noise_rejection_filter_t *filter)
get noise rejection filter
max31856_fault_mask_t
max31856 fault mask enumeration definition
@ MAX31856_FAULT_STATUS_TCHIGH
@ MAX31856_FAULT_STATUS_CJHIGH
@ MAX31856_FAULT_STATUS_TCLOW
@ MAX31856_FAULT_STATUS_OVUV
@ MAX31856_FAULT_STATUS_TCRANGE
@ MAX31856_FAULT_STATUS_OPEN
@ MAX31856_FAULT_STATUS_CJLOW
@ MAX31856_FAULT_STATUS_CJRANGE
@ MAX31856_BOOL_TRUE
@ MAX31856_BOOL_FALSE
@ MAX31856_OPEN_CIRCUIT_DETECTION_MODE2
@ MAX31856_OPEN_CIRCUIT_DETECTION_MODE3
@ MAX31856_OPEN_CIRCUIT_DETECTION_DISABLE
@ MAX31856_OPEN_CIRCUIT_DETECTION_MODE1
@ MAX31856_SAMPLE_AVERAGE_16
@ MAX31856_SAMPLE_AVERAGE_8
@ MAX31856_SAMPLE_AVERAGE_2
@ MAX31856_SAMPLE_AVERAGE_1
@ MAX31856_SAMPLE_AVERAGE_4
@ MAX31856_NOISE_REJECTION_FILTER_50HZ
@ MAX31856_NOISE_REJECTION_FILTER_60HZ
@ MAX31856_FAULT_MODE_INTERRUPT
@ MAX31856_FAULT_MODE_COMPARATOR
@ MAX31856_THERMOCOUPLE_TYPE_K
@ MAX31856_THERMOCOUPLE_TYPE_E
@ MAX31856_THERMOCOUPLE_TYPE_T
@ MAX31856_THERMOCOUPLE_TYPE_J
@ MAX31856_THERMOCOUPLE_TYPE_N
@ MAX31856_THERMOCOUPLE_TYPE_R
@ MAX31856_THERMOCOUPLE_TYPE_B
@ MAX31856_THERMOCOUPLE_TYPE_S
@ MAX31856_THERMOCOUPLE_TYPE_VOLTAGE_GAIN_8
@ MAX31856_THERMOCOUPLE_TYPE_VOLTAGE_GAIN_32
@ MAX31856_FAULT_MASK_OPEN
@ MAX31856_FAULT_MASK_TCLOW
@ MAX31856_FAULT_MASK_CJHIGH
@ MAX31856_FAULT_MASK_TCHIGH
@ MAX31856_FAULT_MASK_OVUV
@ MAX31856_FAULT_MASK_CJLOW
uint8_t max31856_set_reg(max31856_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t max31856_get_reg(max31856_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
max31856 handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
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)
max31856 information structure definition
char manufacturer_name[32]