LibDriver MAX31865
Loading...
Searching...
No Matches
driver_max31865_basic.c
Go to the documentation of this file.
1
37
39
40static max31865_handle_t gs_handle;
41
52uint8_t max31865_basic_init(max31865_wire_t wire, max31865_resistor_t type, float ref_resistor)
53{
54 uint8_t res;
55
56 /* link function */
64
65 /* max31865 init */
66 res = max31865_init(&gs_handle);
67 if (res != 0)
68 {
69 max31865_interface_debug_print("max31865: init failed.\n");
70
71 return 1;
72 }
73
74 /* set filter */
76 if (res != 0)
77 {
78 max31865_interface_debug_print("max31865: set filter select failed.\n");
79 (void)max31865_deinit(&gs_handle);
80
81 return 1;
82 }
83
84 /* set wire type */
85 res = max31865_set_wire(&gs_handle, wire);
86 if (res != 0)
87 {
88 max31865_interface_debug_print("max31865: set wire failed.\n");
89 (void)max31865_deinit(&gs_handle);
90
91 return 1;
92 }
93
94 /* set PT resistor type */
95 res = max31865_set_resistor(&gs_handle, type);
96 if (res != 0)
97 {
98 max31865_interface_debug_print("max31865: set resistor type failed.\n");
99 (void)max31865_deinit(&gs_handle);
100
101 return 1;
102 }
103
104 /* set reference resistor */
105 res = max31865_set_reference_resistor(&gs_handle, ref_resistor);
106 if (res != 0)
107 {
108 max31865_interface_debug_print("max31865: set reference resistor failed.\n");
109 (void)max31865_deinit(&gs_handle);
110
111 return 1;
112 }
113
114 /* set fault detection cycle control */
116 if (res != 0)
117 {
118 max31865_interface_debug_print("max31865: set fault detection cycle control failed.\n");
119 (void)max31865_deinit(&gs_handle);
120
121 return 1;
122 }
123
124 /* set high fault threshold */
126 if (res != 0)
127 {
128 max31865_interface_debug_print("max31865: set high fault threshold failed.\n");
129 (void)max31865_deinit(&gs_handle);
130
131 return 1;
132 }
133
134 /* set low fault threshold */
136 if (res != 0)
137 {
138 max31865_interface_debug_print("max31865: set low fault threshold failed.\n");
139 (void)max31865_deinit(&gs_handle);
140
141 return 1;
142 }
143
144 /* start continuous read */
145 res = max31865_start_continuous_read(&gs_handle);
146 if (res != 0)
147 {
148 max31865_interface_debug_print("max31865: start continuous read failed.\n");
149 (void)max31865_deinit(&gs_handle);
150
151 return 1;
152 }
153
154 return 0;
155}
156
165uint8_t max31865_basic_read(float *temp)
166{
167 uint16_t raw;
168
169 /* continuous read */
170 if (max31865_continuous_read(&gs_handle, (uint16_t *)&raw, temp) != 0)
171 {
172 return 1;
173 }
174 else
175 {
176 return 0;
177 }
178}
179
188{
189 uint8_t res;
190
191 /* stop continuous read */
192 res = max31865_stop_continuous_read(&gs_handle);
193 if (res != 0)
194 {
195 return 1;
196 }
197
198 /* deinit */
199 if (max31865_deinit(&gs_handle) != 0)
200 {
201 return 1;
202 }
203 else
204 {
205 return 0;
206 }
207}
driver max31865 basic header file
uint8_t max31865_set_low_fault_threshold(max31865_handle_t *handle, uint16_t threshold)
set the low fault threshold
uint8_t max31865_set_wire(max31865_handle_t *handle, max31865_wire_t wire)
set the pt resistor wire
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_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_wire_t
max31865 wire type enumeration definition
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_set_filter_select(max31865_handle_t *handle, max31865_filter_select_t filter)
set the filter type
uint8_t max31865_stop_continuous_read(max31865_handle_t *handle)
stop reading
struct max31865_handle_s max31865_handle_t
max31865 handle structure definition
uint8_t max31865_set_high_fault_threshold(max31865_handle_t *handle, uint16_t threshold)
set the high fault threshold
uint8_t max31865_start_continuous_read(max31865_handle_t *handle)
start reading
uint8_t max31865_deinit(max31865_handle_t *handle)
close the chip
uint8_t max31865_basic_deinit(void)
basic example deinit
#define MAX31865_BASIC_DEFAULT_FILTER_SELECT
max31865 basic example default definition
#define MAX31865_BASIC_DEFAULT_HIGH_FAULT_THRESHOLD
#define MAX31865_BASIC_DEFAULT_FAULT_DETECTION_CYCLE_CONTROL
uint8_t max31865_basic_init(max31865_wire_t wire, max31865_resistor_t type, float ref_resistor)
basic example init
#define MAX31865_BASIC_DEFAULT_LOW_FAULT_THRESHOLD
uint8_t max31865_basic_read(float *temp)
basic example read the temperature
uint8_t max31865_interface_spi_init(void)
interface spi bus init
void max31865_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t max31865_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t max31865_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t max31865_interface_spi_deinit(void)
interface spi bus deinit
void max31865_interface_debug_print(const char *const fmt,...)
interface print format data