-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaxim_max6675.h
97 lines (80 loc) · 3.03 KB
/
maxim_max6675.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*!
*******************************************************************************
* @file maxim_max6675.h
*
* @brief
*
* @author Raúl Gotor ([email protected])
* @date 27.02.22
*
* @par
* COPYRIGHT NOTICE: (c) 2022 Raúl Gotor
* All rights reserved.
*******************************************************************************
*/
#ifndef MAXIM_MAX6675_H
#define MAXIM_MAX6675_H
/*
*******************************************************************************
* Public Macros *
*******************************************************************************
*/
/*
*******************************************************************************
* Public Data Types *
*******************************************************************************
*/
/*!
* @brief SPI Transfer function
*
* Function should write the specified number of bytes in the provided buffer
*
* @param[out] p_rx_buffer Pointer to a buffer where to read
* the data to
* @param[in] size Number of bytes to read
*
* @return bool Operation result
*/
typedef bool (*pf_read_func_t)(uint8_t * const p_rx_buffer, size_t const size);
//! @brief max6675 module error types
typedef enum
{
MAX6675_ERROR_SUCCESS = 0,
MAX6675_ERROR_GENERAL_ERROR,
MAX6675_ERROR_BAD_PARAMETER,
MAX6675_ERROR_ALREADY_INITIALIZED,
MAX6675_ERROR_NOT_INITIALIZED,
MAX6675_ERROR_COUNT,
} max6675_error_t;
//! @brief Sensor handle with specific transfer function
typedef struct {
//! @brief Whether the instance is initialized or not
bool is_initialized;
//! @brief Pointer to transfer function
pf_read_func_t read_function;
} max6675_handle_t;
/*
*******************************************************************************
* Public Constants *
*******************************************************************************
*/
/*
*******************************************************************************
* Public Function Prototypes *
*******************************************************************************
*/
//! @brief Initialize instance
max6675_error_t max6675_init(
max6675_handle_t * const p_handle,
pf_read_func_t const pf_read_func);
//! @brief Deinitialize instance
max6675_error_t max6675_deinit(max6675_handle_t * const p_handle);
//! @brief Get whether thermocouple is connected
max6675_error_t max6675_is_sensor_connected(
max6675_handle_t * const p_handle,
bool * const p_connected);
//! @brief Read sensor temperature
max6675_error_t max6675_read_temperature(
max6675_handle_t * const p_handle,
uint16_t * const p_temperature);
#endif //MAXIM_MAX6675_H