Skip to content

Commit 406df24

Browse files
committed
[sc] Only change channel when necessary
1 parent f233984 commit 406df24

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/Ic.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static constexpr roc::Register IC_RD_DATA(IC_BASE.address + 0x30);
5454

5555
Ic::Ic(AlfLink link) : mBar2(link.bar), mLink(link)
5656
{
57-
setChannel(mLink.linkId);
5857
reset();
5958

6059
// Set CFG to 0x3 by default
@@ -88,9 +87,6 @@ void Ic::init(const roc::Parameters::CardIdType& cardId, int linkId)
8887

8988
mLlaSession = std::make_unique<LlaSession>("DDT", card.sequenceId);
9089

91-
if (mLink.linkId != -1) {
92-
setChannel(mLink.linkId);
93-
}
9490
reset();
9591

9692
// Set CFG to 0x3 by default
@@ -108,6 +104,12 @@ void Ic::checkChannelSet()
108104
if (mLink.linkId == -1) {
109105
BOOST_THROW_EXCEPTION(IcException() << ErrorInfo::Message("No IC channel selected"));
110106
}
107+
108+
uint32_t channel = (barRead(sc_regs::SWT_MON.index) >> 8) & 0xff;
109+
110+
if (channel != mLink.linkId) {
111+
setChannel(mLink.linkId);
112+
}
111113
}
112114

113115
void Ic::reset()
@@ -211,7 +213,6 @@ std::vector<std::pair<Ic::Operation, Ic::Data>> Ic::executeSequence(std::vector<
211213
} catch (const IcException& e) {
212214
return { { Operation::Error, e.what() } };
213215
}
214-
setChannel(mLink.linkId);
215216

216217
std::vector<std::pair<Ic::Operation, Ic::Data>> ret;
217218
for (const auto& it : ops) {

src/Sca.cxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ void Sca::checkChannelSet()
9292
if (mLink.linkId == -1) {
9393
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message("No SCA channel selected"));
9494
}
95+
96+
uint32_t channel = (barRead(sc_regs::SWT_MON.index) >> 8) & 0xff;
97+
98+
if (channel != mLink.linkId) {
99+
setChannel(mLink.linkId);
100+
}
95101
}
96102

97103
Sca::CommandData Sca::executeCommand(uint32_t command, uint32_t data, bool lock)
@@ -253,14 +259,11 @@ std::vector<std::pair<Sca::Operation, Sca::Data>> Sca::executeSequence(const std
253259
mLlaSession->start();
254260
}
255261

256-
// force set the channel within the atomic part of the sequence
257-
// to be changed as soon as FW provides set channel
258262
try {
259263
checkChannelSet();
260264
} catch (const ScaException& e) {
261265
return { { Operation::Error, e.what() } };
262266
}
263-
setChannel(mLink.linkId);
264267

265268
std::vector<std::pair<Sca::Operation, Sca::Data>> ret;
266269
for (const auto& it : operations) {

src/Swt.cxx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace sc_regs = AliceO2::roc::Cru::ScRegisters;
4444

4545
Swt::Swt(AlfLink link) : mBar2(link.bar), mLink(link)
4646
{
47-
setChannel(mLink.linkId); // TODO: Decouple this from the class?
4847
mLlaSession = std::make_unique<LlaSession>("DDT", link.cardSequence);
4948
}
5049

@@ -73,10 +72,6 @@ void Swt::init(const roc::Parameters::CardIdType& cardId, int linkId)
7372
};
7473

7574
mLlaSession = std::make_unique<LlaSession>("DDT", card.sequenceId);
76-
77-
if (mLink.linkId != -1) {
78-
setChannel(mLink.linkId);
79-
}
8075
}
8176

8277
void Swt::setChannel(int gbtChannel)
@@ -97,6 +92,12 @@ void Swt::checkChannelSet()
9792
if (mLink.linkId == -1) {
9893
BOOST_THROW_EXCEPTION(SwtException() << ErrorInfo::Message("No SWT channel selected"));
9994
}
95+
96+
uint32_t channel = (barRead(sc_regs::SWT_MON.index) >> 8) & 0xff;
97+
98+
if (channel != mLink.linkId) {
99+
setChannel(mLink.linkId);
100+
}
100101
}
101102

102103
std::vector<SwtWord> Swt::read(SwtWord::Size wordSize, TimeOut msTimeOut)
@@ -189,14 +190,11 @@ std::vector<std::pair<Swt::Operation, Swt::Data>> Swt::executeSequence(std::vect
189190
mLlaSession->start();
190191
}
191192

192-
// force set the channel within the atomic part of the sequence
193-
// to be changed as soon as FW provides set channel
194193
try {
195194
checkChannelSet();
196195
} catch (const SwtException& e) {
197196
return { { Operation::Error, e.what() } };
198197
}
199-
setChannel(mLink.linkId);
200198

201199
std::vector<std::pair<Operation, Data>> ret;
202200

0 commit comments

Comments
 (0)