Skip to content

Commit

Permalink
[driver] Max31865 class temporary variable for data
Browse files Browse the repository at this point in the history
  • Loading branch information
hshose committed Apr 12, 2023
1 parent 422e765 commit 6110dca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/modm/driver/temperature/max31865.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,10 @@ struct max31865
};
using Rejection_t = Configuration<Config_t, Rejection, 0b1>; // Bit 8..10

struct FaultThreshold
{
using RtdResistance_t = uint16_t;
};

static constexpr uint16_t
rtdfaultthresh(const FaultThreshold::RtdResistance_t res)
rtdfaultthresh(const uint16_t res)
{
return static_cast<uint16_t>(res << 1);
return res << 1;
};

enum class Register : uint8_t
Expand Down Expand Up @@ -160,8 +155,8 @@ struct max31865
for (int i = 0; i < 10; i++)
{
const double R = double{pt.R0} * (1 + (pt.a * T) + (pt.b * T * T) +
(c0 * (T - 100) * T * T * T)) -
res;
(c0 * (T - 100) * T * T * T)) -
res;
const double Rdash =
double{pt.R0} * (pt.a + (2 * pt.b * T) + c0 * (((4 * T) - 300) * T * T));
T -= R / Rdash;
Expand Down Expand Up @@ -214,6 +209,7 @@ class Max31865 : public max31865,
Data &data;
std::array<uint8_t, 2> buffer;
Config_t config;
uint16_t d;

modm::ShortTimeout timeout;

Expand Down
6 changes: 4 additions & 2 deletions src/modm/driver/temperature/max31865_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Max31865<SpiMaster, Cs, pt>::readout()
timeout.restart(65ms);
RF_WAIT_UNTIL(timeout.isExpired());

data.data = RF_CALL(readTwoRegisters(Register::ReadRtdMsb));
// data.data = RF_CALL(readTwoRegisters(Register::ReadRtdMsb));
d = RF_CALL(readTwoRegisters(Register::ReadRtdMsb));
data.data = d;

config.reset(Config::VBias);
RF_CALL(writeSingleRegister(Register::WriteConfiguration, config.value));
Expand Down Expand Up @@ -112,4 +114,4 @@ Max31865<SpiMaster, Cs, pt>::writeSingleRegister(Register address, uint8_t data)
RF_END();
}

} // namespace modm
} // namespace modm

0 comments on commit 6110dca

Please sign in to comment.