DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
src
LM75Node.cpp
Go to the documentation of this file.
1
8
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
19
namespace
dunedaq
{
20
namespace
timing
{
21
22
//-----------------------------------------------------------------------------
23
LM75Node::LM75Node
(
const
I2CMasterNode
* i2c_master, uint8_t
address
)
// NOLINT(build/unsigned)
24
:
I2CSlave
(i2c_master,
address
)
25
{}
26
//-----------------------------------------------------------------------------
27
28
//-----------------------------------------------------------------------------
29
LM75Node::~LM75Node
() {}
30
//-----------------------------------------------------------------------------
31
32
//-----------------------------------------------------------------------------
33
float
34
LM75Node::read_temperature
()
const
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
LM75Node.hpp
dunedaq::timing::I2CSlave::read_i2cPrimitive
std::vector< uint8_t > read_i2cPrimitive(uint32_t number_of_bytes) const
Definition
I2CSlave.cpp:155
dunedaq::timing::I2CSlave::I2CMasterNode
friend class I2CMasterNode
Definition
I2CSlave.hpp:97
dunedaq::timing::I2CSlave::I2CSlave
I2CSlave(const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
Definition
I2CSlave.cpp:33
dunedaq::timing::LM75Node::read_temperature
float read_temperature() const
Read temperature [C].
Definition
LM75Node.cpp:34
dunedaq::timing::LM75Node::~LM75Node
virtual ~LM75Node()
Definition
LM75Node.cpp:29
dunedaq::timing::LM75Node::LM75Node
LM75Node(const I2CMasterNode *i2c_master, uint8_t i2c_device_address)
Definition
LM75Node.cpp:23
ers.hpp
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
dunedaq::timing
< Message parameters
Definition
BoreasDesign.hpp:29
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::address
Invalid address
Definition
CommonIssues.hpp:29
toolbox.hpp
Generated on
for DUNE-DAQ by
1.17.0