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
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
use embedded_interfaces::codegen::interface_objects;
pub type MAX31865I2cCodec = embedded_interfaces::registers::i2c::codecs::unsupported_codec::UnsupportedCodec<()>;
pub type MAX31865SpiCodec =
embedded_interfaces::registers::spi::codecs::standard_codec::StandardCodec<1, 6, 0, 7, false, 0>;
interface_objects! {
register_defaults {
codec_error = (),
i2c_codec = MAX31865I2cCodec,
spi_codec = MAX31865SpiCodec,
}
register_devices [ super::MAX31865 ]
/// Conversion mode.
enum ConversionMode: u8{1} {
/// No automatic conversions, 1-shot conversions may be initiated from this mode.
0 NormallyOff,
/// Automatic conversion mode, conversions occur continuously at a 50/60Hz rate.
1 Automatic,
}
/// Wiring mode.
enum WiringMode: u8{1} {
/// 2- or 4-wire RTD.
0 TwoOrFourWire,
/// 3-wire RTD connected to `FORCE+`, `RTDIN+`, `RTDIN-`.
1 ThreeWire,
}
/// Fault detection cycle.
enum FaultDetectionCycle: u8{2} {
/// Fault detection has finished.
0 Finished,
/// Run fault detection with automatic delay.
1 Automatic,
/// Run fault detection with manual delay (cycle 1).
2 RunManual,
/// Finish fault detection with manual delay (cycle 2).
3 FinishManual,
}
/// Filter mode.
#[allow(non_camel_case_types)]
enum FilterMode: u8{1} {
/// 60Hz filter
0 F_60Hz,
/// 50Hz filter
1 F_50Hz,
}
/// The device configuration register.
register Configuration(addr = 0b0000, mode = rw, size = 1) {
/// When no conversions are being performed, VBIAS may be disabled to reduce power
/// dissipation. Set this bit to `true` to enable VBIAS before beginning a single (1-Shot)
/// conversion. When automatic (continuous) conversion mode is selected,
/// VBIAS remains on continuously.
enable_bias_voltage: bool = false,
/// Conversion mode (operating mode).
conversion_mode: ConversionMode = ConversionMode::NormallyOff,
/// When the conversion mode is set to [`ConversionMode::NormallyOff`],
/// set this flag to start a conversion. You must enable VBIAS before
/// starting a conversion. Note any filter capacitors at the RTDIN inputs
/// need to charge before an accurate conversion can be performed.
/// Therefore, enable VBIAS and wait at least 10.5 time constants of the input RC
/// network plus an additional 1ms before initiating the conversion. Note that a single
/// conversion requires approximately 52ms in 60Hz filter mode or 62.5ms in 50Hz
/// filter mode to complete. This flag will auto-clear after the conversion.
oneshot: bool = false,
/// The wiring mode of the RTD.
wiring_mode: WiringMode = WiringMode::TwoOrFourWire,
/// Used to initiate fault detection. This is reset to [`FaultDetectionCycle::Finished`]
/// when fault detection is done. When writing this register to initiate fault detection,
/// the bias voltage must be enabled, conversion mode must be [`ConversionMode::NormallyOff`]
/// and the `clear_fault_status` flag must be off.
///
/// If the external RTD interface circuitry includes an input filter with a time constant
/// greater than 100µs, the fault detection cycle timing should be controlled in the manual
/// mode operation. For more information, refer to the datasheet.
fault_detection_cycle: FaultDetectionCycle = FaultDetectionCycle::Finished,
/// Set this flag while `oneshot` is off and writing [`FaultDetectionCycle::Finished`] to
/// `fault_detection_cycle` to clear the fault status register. This bit will auto-clear.
clear_fault_status: bool = false,
/// The filter mode of the RTD.
filter_mode: FilterMode = FilterMode::F_60Hz,
}
/// The RTD resistance data.
register Resistance(addr = 0b0001, mode = r, size = 2) {
/// The ratio of RTD resistance to reference resistance.
/// The decimal value is obtained by dividing this value by `2^15`.
resistance_ratio: u16{15} = 0,
/// Whether a fault was detected.
fault: bool = false,
}
/// The High Fault Threshold register selects the high trip threshold for RTD fault detection.
///
/// The RTD High bit in the Fault Status Register is set if the
/// RTD resistance register value is greater than or equal to
/// the value in the High Fault Threshold register.
/// The POR value of the High Fault Threshold register is FFFFh.
register FaultThresholdHigh(addr = 0b0011, mode = rw, size = 2) {
/// The ratio of RTD resistance to reference resistance.
/// The decimal value is obtained by dividing this value by `2^15`.
resistance_ratio: u16{15} = 0x7fff,
/// Reserved bit
_: u8{1},
}
/// The Low Fault Threshold register selects the low trip threshold for RTD fault detection.
///
/// The RTD Low bit in the Fault Status Register is set if the
/// RTD resistance value is less than or equal to the value in
/// the Low Fault Threshold register. The POR value of the
/// Low Fault Threshold register is 0000h.
register FaultThresholdLow(addr = 0b0101, mode = rw, size = 2) {
/// The ratio of RTD resistance to reference resistance.
/// The decimal value is obtained by dividing this value by `2^15`.
resistance_ratio: u16{15} = 0x0000,
/// Reserved bit
_: u8{1},
}
/// The fault status register.
///
/// Depending on whether 2-, 3- or 4-wire mode is used,
/// these status bits can have different possible causes.
/// Refer to the datasheet for a table of possible causes.
register FaultStatus(addr = 0b0111, mode = r, size = 1) {
/// Measured resistance greater than High Fault Threshold value.
high_threshold: bool = false,
/// Measured resistance less than Low Fault Threshold value
low_threshold: bool = false,
/// `V_REFIN-` > 0.85 * `V_BIAS`.
/// Detected on demand by initiating fault detection.
v_refin_minus_exceeds_85_percent_of_v_bias: bool = false,
/// `V_REFIN-` < 0.85 * `V_BIAS`, FORCE- open.
/// Detected on demand by initiating fault detection.
v_refin_minus_below_85_percent_of_v_bias_with_force_minus_open: bool = false,
/// `V_RTDIN-` < 0.85 * `V_BIAS`, FORCE- open.
/// Detected on demand by initiating fault detection.
v_rtdin_minus_below_85_percent_of_v_bias_with_force_minus_open: bool = false,
/// Over/undervoltage, some protected input voltage exceeds VDD or below GND1
over_or_undervoltage: bool = false,
/// Reserved bits
_: u8{2},
}
}