DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
src
I2C9546SwitchNode.cpp
Go to the documentation of this file.
1
8
9
#include "
timing/I2C9546SwitchNode.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
I2C9546SwitchSlave::I2C9546SwitchSlave(
const
I2CMasterNode
* i2c_master, uint8_t
address
)
// NOLINT(build/unsigned)
24
:
I2CSlave
(i2c_master,
address
)
25
{}
26
//-----------------------------------------------------------------------------
27
28
//-----------------------------------------------------------------------------
29
I2C9546SwitchSlave::~I2C9546SwitchSlave() {}
30
//-----------------------------------------------------------------------------
31
32
//-----------------------------------------------------------------------------
33
void
34
I2C9546SwitchSlave::ensure_valid_channel(uint8_t channel)
const
// NOLINT(build/unsigned)
35
{
36
if
(channel < 4)
37
return
;
38
39
throw
I2C9546SwitchSlaveChannelError(
ERS_HERE
, std::to_string(channel));
40
}
41
//-----------------------------------------------------------------------------
42
43
44
//-----------------------------------------------------------------------------
45
void
46
I2C9546SwitchSlave::enable_channel(uint8_t channel)
const
// NOLINT(build/unsigned)
47
{
48
this->ensure_valid_channel(channel);
49
std::vector<uint8_t> enable_byte = this->read_i2cPrimitive(1);
// NOLINT(build/unsigned)
50
uint8_t new_enable_byte = enable_byte.at(0) | (1UL <<
channel
);
// NOLINT(build/unsigned)
51
this->write_i2cPrimitive({new_enable_byte});
52
}
53
//-----------------------------------------------------------------------------
54
55
//-----------------------------------------------------------------------------
56
void
57
I2C9546SwitchSlave::disable_channel(uint8_t channel)
const
// NOLINT(build/unsigned)
58
{
59
this->ensure_valid_channel(channel);
60
std::vector<uint8_t> enable_byte = this->read_i2cPrimitive(1);
// NOLINT(build/unsigned)
61
uint8_t new_enable_byte = enable_byte.at(0) & ~(1UL <<
channel
);
// NOLINT(build/unsigned)
62
this->write_i2cPrimitive({new_enable_byte});
63
}
64
//-----------------------------------------------------------------------------
65
66
//-----------------------------------------------------------------------------
67
uint8_t
// NOLINT(build/unsigned)
68
I2C9546SwitchSlave::read_channels_states()
const
69
{
70
std::vector<uint8_t> enable_byte = this->read_i2cPrimitive(1);
// NOLINT(build/unsigned)
71
return
enable_byte.at(0);
72
}
73
//-----------------------------------------------------------------------------
74
75
//-----------------------------------------------------------------------------
76
void
// NOLINT(build/unsigned)
77
I2C9546SwitchSlave::set_channels_states(uint8_t channels)
const
// NOLINT(build/unsigned)
78
{
79
this->write_i2cPrimitive({channels});
80
}
81
//-----------------------------------------------------------------------------
82
83
}
// namespace timing
84
}
// namespace dunedaq
I2C9546SwitchNode.hpp
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
dunedaq::timing::I2CMasterNode
Definition
I2CMasterNode.hpp:41
dunedaq::timing::I2CSlave
Definition
I2CSlave.hpp:42
ers.hpp
dunedaq::timing
< Message parameters
Definition
BoreasDesign.hpp:29
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::address
Invalid address
Definition
CommonIssues.hpp:29
plot_trigprim_output_data.channel
channel
Definition
plot_trigprim_output_data.py:21
toolbox.hpp
Generated on
for DUNE-DAQ by
1.17.0