Newer
Older
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
#pragma once
// C++ system level
// #include <functional>
// ESP32 specific
// #include "esp_log.h"
// project specific
#include <SpiderLib.hpp>
// qthing stuff
// #include <qthing>
// misc
// #include ""
namespace MAX31856 {
enum PowerlineFrequencyRejection : u8 {
F60Hz = 0,
F50Hz = 1
};
enum ThermocoupleType : u8 {
B_Type = 0x00,
E_TYPE = 0x01,
J_TYPE = 0x02,
K_TYPE = 0x03,
N_TYPE = 0x04,
R_TYPE = 0x05,
S_TYPE = 0x06,
T_TYPE = 0x07
};
// #################################
// ### ###
// ### Register Declarations ###
// ### ###
// #################################
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
union CR0 {
struct __attribute__((packed)) {
u8 PWRLNRJ : 1; // Power Line Rejection Mode (0 = 60Hz; 1 = 50Hz)
u8 FAULTCLR : 1;
u8 FAULT : 1;
u8 CJ : 1;
u8 OCFAULT : 2;
u8 ONESHOT : 1;
u8 CMODE : 1;
};
u8 value = 0x00;
static constexpr u8 addr = 0x00;
};
union CR1 {
struct __attribute__((packed)) {
u8 TCTYPE : 4; // see enum: ThermocoupleType
u8 AVGSEL : 3;
u8 _reserved_ : 1;
};
u8 value = 0x00;
static constexpr u8 addr = 0x01;
};
union MASK {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x02;
};
union CJHF {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x03;
};
union CJLF {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x04;
};
union LTHFTH {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x05;
};
union LTHFTL {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x06;
};
union LTLFTH {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x07;
};
union LTLFTL {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x08;
};
union CJTO {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x09;
};
union CJTH {
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x0A;
};
union CJTL {
struct __attribute__((packed)) {
};
union SR {
// Info: Read only!
struct __attribute__((packed)) {
};
u8 value = 0x00;
static constexpr u8 addr = 0x0F;
};
// #################################
// #################################
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
class SoftSPI {
public:
SoftSPI(u8 miso, u8 mosi, u8 sclk, u8 cs);
void writeU8(u8 addr, u8 value);
u8 readU8(u8 addr);
const u8 cs;
const u8 mosi;
const u8 miso;
const u8 sclk;
protected:
void setMOSI(bool value);
void setSCLK(bool value);
void setCS(bool value);
bool getMISO();
SpiderLib::ManagedMutex mutex;
};
class MAX31856 {
public:
MAX31856(u8 miso, u8 mosi, u8 sclk, u8 cs);
// Methods below are semi-public: From a hidden-box model perspective they should be protected
// but from my POV they can be public as the user CANNOT misuse them in any way
// TODO: elaborate on this…
u8 readAddr ();
u8 writeAddr();
void setPwrLnRjFrq(PowerlineFrequencyRejection pfr); // TODO: Better Name…?!
PowerlineFrequencyRejection getPwrLnRjFrq(); // TODO: Better Name…?!
void setThermocoupleType(ThermocoupleType tc);
ThermocoupleType getThermocoupleType();
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
void mainLoop();
const u8 cs;
const u8 mosi;
const u8 miso;
const u8 sclk;
protected:
SoftSPI* spi;
// bool getIRQState();
//void mainLoop();
SpiderLib::ManagedMutex mutex;
SpiderLib::Util::LambdaTask* loopTask = NULL;
};
}