Since LLVM v15, llvm-objcopy seems to produce broken (misaligned?)
binaries, which when combined with some difficult to debug timing issues
caused by the calibrate_dac_feedback routine, would cause the
independent watchdog to kick in, and bootloop the Thermostat.
As NixOS 23.11 ships LLVM v16, upgrading to it breaks builds. Using
rust-objcopy from cargo-binutils does not help either since the pinned
version of Rust uses LLVM v15.
arm-none-eabi-objcopy doesn't have this problem, so use it instead.
See https://github.com/llvm/llvm-project/issues/58407 and
https://github.com/rust-lang/rust/issues/102983.
Put SocketState initialisation logic in new. This avoids using an unsafe
and unnerving MaybeUninit::uninit().assume_init() to initialise an
array, which the compiler yells at since it causes undefined behavior.
Since VREF is an implementation detail, there shouldn't be a need to
include it in reports.
The ChannelState vref is removed along with it as its only use was to
save VREF measurements for later reporting.
Change the behaviour of LED L3 to turn off only when all channels have
PID disengaged, as opposed to when any channel disengages PID.
Otherwise, when disengaging PID on a Thermostat that has had both
channels engaged in PID, the LED would turn off, even when PID is still
engaged on the other channel.
This lets the LED better reflect the status of the Thermostat as a
whole, as it would stay on as long as PID is engaged on at least one
channel.
Rewrite of PID according to https://hackmd.io/IACbwcOTSt6Adj3_F9bKuw PID implementation.
To migrate:
- TEC+/- pin polarity has to be reversed.
- Some saved settings might be wiped upon flashing of new firmware, back up settings before upgrade
- Min / Max integral parameters no longer exist
- kp, ki, kd will likely need to be retuned
The software has been tested on hardware with good temperature control stability.
Reviewed-on: #68
Co-authored-by: topquark12 <aw@m-labs.hk>
Co-committed-by: topquark12 <aw@m-labs.hk>