DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
LM75Node.cpp
Go to the documentation of this file.
1
9#include "timing/LM75Node.hpp"
10
11// PDT headers
12#include "ers/ers.hpp"
13#include "timing/toolbox.hpp"
14
15#include <vector>
16// #include <fstream>
17// #include <sstream>
18
19namespace dunedaq {
20namespace timing {
21
22//-----------------------------------------------------------------------------
23LM75Node::LM75Node(const I2CMasterNode* i2c_master, uint8_t address) // NOLINT(build/unsigned)
24 : I2CSlave(i2c_master, address)
25{}
26//-----------------------------------------------------------------------------
27
28//-----------------------------------------------------------------------------
30//-----------------------------------------------------------------------------
31
32//-----------------------------------------------------------------------------
33float
35{
36 std::vector<uint8_t> temp_bytes = this->read_i2cPrimitive(2); // NOLINT(build/unsigned)
37 uint16_t temp_raw = (temp_bytes[1] & 0x80) >> 7;
38 temp_raw = temp_raw | (temp_bytes[0] << 1);
39
40 // 1s padding for negative values
41 if (temp_raw & 0x0100)
42 {
43 temp_raw = temp_raw | 0xfe00;
44 }
45 int16_t temp = static_cast<int16_t>(temp_raw);
46
47 TLOG_DEBUG(13) << "LM75 temp data - "
48 << "raw bytes: 0x" << std::hex << (uint)temp_bytes[0] << ", 0x" << (uint)temp_bytes[1] // NOLINT(build/unsigned)
49 << ", combined word: 0x" << temp_raw
50 << ", temp [C]: " << temp*0.5;
51 return temp*0.5;
52}
53//-----------------------------------------------------------------------------
54
55} // namespace timing
56} // namespace dunedaq
std::vector< uint8_t > read_i2cPrimitive(uint32_t number_of_bytes) const
Definition I2CSlave.cpp:155
float read_temperature() const
Read temperature [C].
Definition LM75Node.cpp:34
LM75Node(const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
Definition LM75Node.cpp:23
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
The DUNE-DAQ namespace.
Definition DataStore.hpp:57