LibDriver MAX31855
Loading...
Searching...
No Matches
driver_max31855.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MAX31855_H
38#define DRIVER_MAX31855_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{
65 MAX31855_FAULT_OC = (1 << 0),
66 MAX31855_FAULT_SCG = (1 << 1),
67 MAX31855_FAULT_SCV = (1 << 2),
69
73typedef struct max31855_handle_s
74{
75 uint8_t (*spi_init)(void);
76 uint8_t (*spi_deinit)(void);
77 uint8_t (*spi_read_cmd)(uint8_t *buf, uint16_t len);
78 void (*delay_ms)(uint32_t ms);
79 void (*debug_print)(const char *const fmt, ...);
80 uint8_t inited;
81 uint8_t fault;
83
99
103
110
117#define DRIVER_MAX31855_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
118
125#define DRIVER_MAX31855_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
126
133#define DRIVER_MAX31855_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
134
141#define DRIVER_MAX31855_LINK_SPI_READ_COMMAND(HANDLE, FUC) (HANDLE)->spi_read_cmd = FUC
142
149#define DRIVER_MAX31855_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
150
157#define DRIVER_MAX31855_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
158
162
169
178uint8_t max31855_info(max31855_info_t *info);
179
190uint8_t max31855_init(max31855_handle_t *handle);
191
202uint8_t max31855_deinit(max31855_handle_t *handle);
203
219uint8_t max31855_read(max31855_handle_t *handle, int16_t *thermocouple_raw, float *thermocouple_temp,
220 int16_t *reference_junction_raw, float *reference_junction_temp);
221
233
237
244
256uint8_t max31855_get_reg(max31855_handle_t *handle, uint32_t *data);
257
261
265
266#ifdef __cplusplus
267}
268#endif
269
270#endif
max31855_fault_t
max31855 fault enumeration definition
uint8_t max31855_deinit(max31855_handle_t *handle)
close the chip
uint8_t max31855_get_last_fault(max31855_handle_t *handle, max31855_fault_t *fault)
get the last fault
uint8_t max31855_info(max31855_info_t *info)
get chip's information
uint8_t max31855_read(max31855_handle_t *handle, int16_t *thermocouple_raw, float *thermocouple_temp, int16_t *reference_junction_raw, float *reference_junction_temp)
read the temperature
struct max31855_info_s max31855_info_t
max31855 information structure definition
struct max31855_handle_s max31855_handle_t
max31855 handle structure definition
uint8_t max31855_init(max31855_handle_t *handle)
initialize the chip
@ MAX31855_FAULT_SCG
@ MAX31855_FAULT_NONE
@ MAX31855_FAULT_OC
@ MAX31855_FAULT_SCV
uint8_t max31855_get_reg(max31855_handle_t *handle, uint32_t *data)
get the chip register
max31855 handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read_cmd)(uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
max31855 information structure definition
uint32_t driver_version
char manufacturer_name[32]