Skip to content

Commit

Permalink
Merge pull request #114 from Mu2e/rrivera/fixCFOreset
Browse files Browse the repository at this point in the history
Rrivera/fix cfo reset
  • Loading branch information
rrivera747 authored Jul 11, 2024
2 parents 875e307 + 5f111a9 commit 2733aa9
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 71 deletions.
1 change: 1 addition & 0 deletions otsdaq-mu2e/FEInterfaces/CFOFrontEndInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class CFOFrontEndInterface : public CFOandDTCCoreVInterface

void CFOReset (__ARGS__);
void CFOHalt (__ARGS__);
void EnableOrDisableClockMarkers (__ARGS__);

void WriteCFO (__ARGS__);
void ReadCFO (__ARGS__);
Expand Down
64 changes: 52 additions & 12 deletions otsdaq-mu2e/FEInterfaces/CFOFrontEndInterfaceImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ void CFOFrontEndInterface::registerFEMacros(void)
"Executes a soft reset of the CFO by setting the reset bit (31) to true on the <b>CFO Control Register</b> (0x9100)."
);

registerFEMacroFunction(
"Clock Marker Enable/Disable",
static_cast<FEVInterface::frontEndMacroFunction_t>(
&CFOFrontEndInterface::EnableOrDisableClockMarkers),
std::vector<std::string>{"Enable Clock Markers (Default := false)"}, // namesOfInputArgs
std::vector<std::string>{}, // namesOfOutput
1, // requiredUserPermissions
"*", // allowedCallingFEs
"Enable or Disable the Mu2e Clock Marker broadcast over the CFO timing links."
);

registerFEMacroFunction(
"CFO Halt",
static_cast<FEVInterface::frontEndMacroFunction_t>(
Expand Down Expand Up @@ -124,17 +135,17 @@ void CFOFrontEndInterface::registerFEMacros(void)
"\t-Loopback must be less than 10,000.\n"
);

registerFEMacroFunction(
"Test Loopback marker", // feMacroName
static_cast<FEVInterface::frontEndMacroFunction_t>(
&CFOFrontEndInterface::TestMarker), // feMacroFunction
std::vector<std::string>{"DTC-chain link index (0-7)"},
std::vector<std::string>{"Response"}, // namesOfOutput
1,
"*",
"This FE Macro measures the delay of a marker from ROCs. "
"Optionally, the delay can be measured over mutliple iterations with the <b>Loopback Test</B> Macro."
);
// registerFEMacroFunction(
// "Test Loopback marker", // feMacroName
// static_cast<FEVInterface::frontEndMacroFunction_t>(
// &CFOFrontEndInterface::TestMarker), // feMacroFunction
// std::vector<std::string>{"DTC-chain link index (0-7)"},
// std::vector<std::string>{"Response"}, // namesOfOutput
// 1,
// "*",
// "This FE Macro measures the delay of a marker from ROCs. "
// "Optionally, the delay can be measured over mutliple iterations with the <b>Loopback Test</B> Macro."
// );

registerFEMacroFunction(
"CFO Read",
Expand Down Expand Up @@ -1695,6 +1706,17 @@ std::string CFOFrontEndInterface::CompileSetAndLaunchTemplateSuperCycleRunPlan(b
return outSs.str();
} //end CompileSetAndLaunchTemplateSuperCycleRunPlan()

//========================================================================
void CFOFrontEndInterface::EnableOrDisableClockMarkers(__ARGS__)
{
bool enableClockMarkers = __GET_ARG_IN__("Enable Clock Markers (Default := false)",bool,false);
__FE_COUTV__(enableClockMarkers);
if(enableClockMarkers)
thisCFO_->EnableEmbeddedClockMarker();
else
thisCFO_->DisableEmbeddedClockMarker();
} //end EnableOrDisableClockMarkers()

//========================================================================
void CFOFrontEndInterface::CompileSetAndLaunchTemplateFixedWidthRunPlan(__ARGS__)
{
Expand Down Expand Up @@ -2232,7 +2254,25 @@ catch(...)
} //end detechedBufferTestThread() exception handling

//========================================================================
void CFOFrontEndInterface::CFOReset(__ARGS__) { thisCFO_->SoftReset(); }
void CFOFrontEndInterface::CFOReset(__ARGS__)
{
__FE_COUT_INFO__ << "Setting up CFO for RTF, Reset and Buffer Release!" << __E__;

halt();
getCFOandDTCRegisters()->SetJitterAttenuatorSelect(1 /* select RJ45 */, false /* alsoResetJA */);
sleep(1);
__FE_COUT_INFO__ << "JA Status = " << getCFOandDTCRegisters()->FormatJitterAttenuatorCSR() << __E__;

thisCFO_->CFOandDTC_Registers::ResetSERDES();
thisCFO_->ResetSERDES(CFOLib::CFO_Link_ID::CFO_Link_ALL);

thisCFO_->SoftReset();
thisCFO_->ReleaseAllBuffers(DTC_DMA_Engine_DAQ);

thisCFO_->EnableEmbeddedClockMarker();

__FE_COUT_INFO__ << "Reset and ReleaseAllBuffers called!" << __E__;
} //end CFOReset()

//========================================================================
void CFOFrontEndInterface::CFOHalt(__ARGS__) { halt(); }
Expand Down
15 changes: 10 additions & 5 deletions otsdaq-mu2e/FEInterfaces/DTCFrontEndInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class DTCFrontEndInterface : public CFOandDTCCoreVInterface
bool saveBinaryData_ = false;
bool saveSubeventsToBinaryData_ = false;
bool doNotResetCounters_ = false;
bool skipBy32_ = false;

std::atomic<uint64_t> eventsCount_;
std::atomic<uint64_t> subeventsCount_;
Expand All @@ -93,6 +94,7 @@ class DTCFrontEndInterface : public CFOandDTCCoreVInterface
FILE* fp_ = nullptr;

std::string error_;
std::string saveBinaryDataFilename_;

}; // end DetachedBufferTestThreadStruct declaration

Expand All @@ -102,7 +104,8 @@ class DTCFrontEndInterface : public CFOandDTCCoreVInterface
std::shared_ptr<DTCFrontEndInterface::DetachedBufferTestThreadStruct> threadStruct);

void initDetachedBufferTest (uint64_t initialEventWindowTag, bool saveBinaryDataToFile,
bool saveSubeventHeadersToDataFile, bool doNotResetCounters);
const std::string& filename,
bool saveSubeventHeadersToDataFile, bool doNotResetCounters, bool skipBy32);

std::shared_ptr<DTCFrontEndInterface::DetachedBufferTestThreadStruct> bufferTestThreadStruct_;

Expand Down Expand Up @@ -175,13 +178,15 @@ class DTCFrontEndInterface : public CFOandDTCCoreVInterface
void SetCFOEmulatorOnOffSpillEmulation (__ARGS__);
std::string SetCFOEmulatorOnOffSpillEmulation (bool enable,
bool useDetachedBufferTest, uint32_t numberOfSuperCycles, uint64_t initialEventWindowTag,
bool enableClockMarkers, bool enableAutogenDRP, bool saveBinaryDataToFile, bool saveSubeventHeadersToDataFile,
bool doNotResetCounters);
bool enableClockMarkers, bool enableAutogenDRP, bool saveBinaryDataToFile,
const std::string& filename,
bool saveSubeventHeadersToDataFile, bool doNotResetCounters, bool skipBy32);
void SetCFOEmulatorFixedWidthEmulation (__ARGS__);
std::string SetCFOEmulatorFixedWidthEmulation (bool enable, bool useDetachedBufferTest,
std::string eventDuration, uint32_t numberOfEventWindowMarkers, uint64_t initialEventWindowTag,
const std::string& eventDuration, uint32_t numberOfEventWindowMarkers, uint64_t initialEventWindowTag,
uint64_t eventWindowMode, bool enableClockMarkers, bool enableAutogenDRP, bool saveBinaryDataToFile,
bool saveSubeventHeadersToDataFile, bool doNotResetCounters);
const std::string& filename,
bool saveSubeventHeadersToDataFile, bool doNotResetCounters, bool skipBy32);

void BufferTest (__ARGS__);
void PatternTest (__ARGS__);
Expand Down
Loading

0 comments on commit 2733aa9

Please sign in to comment.