DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DACNode.cpp
Go to the documentation of this file.
1
9#include "timing/DACNode.hpp"
10
11namespace dunedaq {
12namespace timing {
13
14// uHAL Node registation
15UHAL_REGISTER_DERIVED_NODE(DACNode)
16
17//-----------------------------------------------------------------------------
18DACSlave::DACSlave(const I2CMasterNode* i2c_master, uint8_t address) // NOLINT(build/unsigned)
19 : I2CSlave(i2c_master, address)
20{}
21//-----------------------------------------------------------------------------
22
23//-----------------------------------------------------------------------------
24void
25DACSlave::set_interal_ref(bool internal_ref) const
26{
27 this->write_i2cArray(0x38, { 0x0, internal_ref });
28}
29//-----------------------------------------------------------------------------
30
31//-----------------------------------------------------------------------------
32void
33DACSlave::set_dac(uint8_t channel, uint32_t code) const // NOLINT(build/unsigned)
34{
35
36 if (channel > 7) {
37 throw DACChannelOutOfRange(ERS_HERE, std::to_string(channel));
38 }
39
40 if (code > 0xffff) {
41 throw DACValueOutOfRange(ERS_HERE, std::to_string(code));
42 }
43
44 uint32_t address = 0x18 + (channel & 0x7); // NOLINT(build/unsigned)
45
46 this->write_i2cArray(address, { (uint8_t)((code >> 8) & 0xff), (uint8_t)(code & 0xff) }); // NOLINT(build/unsigned)
47}
48//-----------------------------------------------------------------------------
49
50//-----------------------------------------------------------------------------
51DACNode::DACNode(const uhal::Node& node)
52 : I2CMasterNode(node)
53 , DACSlave(this, this->get_slave_address("i2caddr"))
54{}
55//-----------------------------------------------------------------------------
56
57//-----------------------------------------------------------------------------
59 : I2CMasterNode(node)
60 , DACSlave(this, this->get_slave_address("i2caddr"))
61{}
62//-----------------------------------------------------------------------------
63
64//-----------------------------------------------------------------------------
66//-----------------------------------------------------------------------------
67
68} // namespace timing
69} // namespace dunedaq
#define ERS_HERE
uhal::Node implementing single I2C Master Slave connection to control SFP expander chips.
Definition DACNode.hpp:69
DACNode(const uhal::Node &node)
Definition DACNode.cpp:51
Class for dac node.
Definition DACNode.hpp:42
void set_interal_ref(bool internal_ref) const
Use DAC internal reference.
Definition DACNode.cpp:25
void set_dac(uint8_t channel, uint32_t code) const
Configure DAC channel.
Definition DACNode.cpp:33
void write_i2cArray(uint32_t i2c_device_address, uint32_t i2c_reg_address, std::vector< uint8_t > data, bool send_stop=true) const
Definition I2CSlave.cpp:99
Including Qt Headers.
DACValueOutOfRange
< Namespace
Definition DACNode.hpp:31