otsdaq_components  v2_04_02
FSSRPurdueFirmware.cc
1 #include "otsdaq-components/DAQHardware/FSSRPurdueFirmware.h"
2 
3 //#include "otsdaq-components/DAQHardware/FSSRFirmwareDefinitions.h"
4 //#include "otsdaq/BitManipulator/BitManipulator.h"
5 //#include "otsdaq-components/DetectorHardware/FSSRROCDefinitions.h"
6 
7 #include "otsdaq-components/DAQHardware/FrontEndFirmwareBase.h"
8 #include "otsdaq-components/DAQHardware/OtsUDPFirmwareCore.h"
9 #include "otsdaq-components/DAQHardware/PurdueFirmwareCore.h"
10 
11 #include <arpa/inet.h>
12 #include <netinet/in.h>
13 #include <sys/socket.h>
14 #include "otsdaq/Macros/CoutMacros.h"
15 #include "otsdaq/MessageFacility/MessageFacility.h"
16 
17 #include <cstdlib>
18 #include <iostream>
19 
20 using namespace ots;
21 
22 //========================================================================================================================
23 FSSRPurdueFirmware::FSSRPurdueFirmware(std::string communicationFirmwareType,
24  unsigned int communicationFirmwareVersion,
25  unsigned int applicationFirmwareVersion)
26  : FSSRFirmwareBase(communicationFirmwareType,
27  communicationFirmwareVersion,
28  applicationFirmwareVersion)
29 {
30 }
31 // //choose: OtsUDPFirmwareCore or PurdueFirmwareCore
32 // if(communicationFirmwareType == FrontEndFirmwareBase::PURDUE_CORE_FIRMWARE_NAME)
33 // communicationFirmwareInstance_ = new
34 // PurdueFirmwareCore(communicationFirmwareVersion); if(communicationFirmwareType ==
35 // FrontEndFirmwareBase::OTS_CORE_FIRMWARE_NAME) communicationFirmwareInstance_ =
36 // new OtsUDPFirmwareCore(communicationFirmwareVersion); else
37 // {
38 // __SS__ << "Unknown firmware type choice: " << choice << std::endl;
39 // __COUT_ERR__ << ss.str();
40 // __SS_THROW__;
41 // }
42 //
43 //
44 // //make protocol a class member
45 // //protocolInstance_ = new OtsFirmwareCore(version);//AUG-17-2017 RAR dissociated
46 // because function calls are entirely independent from PURDUE firmware calls //
48 // //assert(protocolInstance_ != NULL);
49 // //returns either new OtsUDPFirmware or new PurdueFirmwareCore,
50 // //now we can call write/read etc with protocol->write, protocol->read, etc
51 //}
52 
53 //========================================================================================================================
54 FSSRPurdueFirmware::~FSSRPurdueFirmware(void)
55 {
56  // delete protocolInstance_;
57  // protocolInstance_ = NULL;
58 }
59 
60 //========================================================================================================================
61 void FSSRPurdueFirmware::init(void) {}
62 /*
63 //========================================================================================================================
64 std::string FSSRPurdueFirmware::configureClocks(std::string source, double frequency)
65 {
66  std::cout << __COUT_HDR_FL__ << "Writing Clock configuration!" << std::endl;
67 
68  std::string buffer;
69  //NoNeedNowwrite(buffer, ETHIO_DESTINATION_PORT, 0x0000b798); // Listen port for
70 ethio stuff
71 
72  setPacketSizeStripCSR(6);
73  setExternalBCOClockSourceStripCSR(source); //(source)
74  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Reset CSR -
75 reset trigger counter, external 27 MHz clock
76 
77  resetDCMStripCSR(true);
78  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Set reset to
79 DCM
80 
81  resetDCMStripCSR(false);
82  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_); // Clear reset
83 to DCM
84 
85  ;
86  //FIXME? Does Nothing RAR Aug 2017// OtsUDPFirmwareCore::waitClear(buffer, STRIP_CSR,
87 waitDCMResetStripCSR()); // Wait for DCM to lock
88 
89  OtsUDPFirmwareCore::write(buffer, STRIP_TRIM_CSR, 0x00002000); // MCLKB edge for
90 channel 5 // was 0x00002000
91 
92  setFrequencyFromClockState(buffer, frequency);
93  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
94 
95  resetDCMStripCSR(true);
96  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
97 
98  resetDCMStripCSR(false);
99  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
100 
101  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer, STRIP_CSR,
102 waitDCMResetStripCSR()); // Wait for DCM to lock std::cout << __COUT_HDR_FL__ <<
103 "stripCSRRegisterValue :" << std::hex << stripCSRRegisterValue_ << std::dec << std::endl;
104 
105  return buffer;
106 }
107 
108 //========================================================================================================================
109 std::string FSSRPurdueFirmware::resetDetector(int channel)
110 {
111  std::cout << __COUT_HDR_FL__ << "Resetting detector!" << std::endl;
112  std::string buffer;
113  if (channel == -1)//reset all channels
114  {
115  //write(buffer,STRIP_RESET,0xd000003f); // Issue reset
116  OtsUDPFirmwareCore::write(buffer, STRIP_RESET, 0xf000003f); // Issue reset // was
117 0xf000003f
118  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
119 STRIP_RESET, 0xf0000000); // Wait for reset to complete // was 0xf0000000 } else
120  {
121  OtsUDPFirmwareCore::write(buffer, STRIP_RESET, 0xf000003f); // Issue reset
122  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
123 STRIP_RESET, 0xf0000000); // Wait for reset to complete
124  }
125 
126  return buffer;
127 }
128 
129 //========================================================================================================================
130 std::string FSSRPurdueFirmware::enableTrigger(void)
131 {
132  std::string buffer;
133  std::cout << __COUT_HDR_FL__ << "Enabling Trigger!!!" << std::endl;
134  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in :" << std::hex <<
135 stripCSRRegisterValue_ << std::dec << std::endl;
136 
137  setHaltStripCSR(1);//WARNING THIS IS CLEARED BY THE MASTER BUT IF THERE IS NO MASTER
138 NOTHING WORKS UNLESS THE BIT IS UNSET
139  //setHaltStripCSR(0);//WARNING THIS IS CLEARED BY THE MASTER BUT IF THERE IS NO MASTER
140 NOTHING WORKS UNLESS THE BIT IS UNSET sendTriggerDataStripCSR(true);
141  sendTriggerNumberStripCSR(true);
142  sendBCOStripCSR(true);
143  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
144 
145  stripTriggerCSRRegisterValue_ = 0;
146  BCOOffset(4);
147  OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_CSR, stripTriggerCSRRegisterValue_); //
148 BCO offset // was 0x00000004
149 
150  // write(buffer,STRIP_TRIG_INPUT_0,0x1f060040); // FSSR GOTHIT trigger input -
151 timed in for the 27 MHz external clock
152  // write(buffer,STRIP_TRIG_INPUT_3,0x3f874040); // Unbiased trigger input +
153 external trigger
154 
155  configureStripTriggerUnbiased(buffer);
156 
157  configureTriggerInputs(buffer);
158 
159  //FIXME for IP .36 the number to set is 0x20401000
160 
161  if (OtsUDPFirmwareCore::version_ == 1)
162  OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_3, 0x20401000); // Turn on
163 streaming hits along with BCO data else if (OtsUDPFirmwareCore::version_ == 2)
164  OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_3, 0x20301000); // Turn on
165 streaming hits along with BCO data else
166  {
167  __SS__ << "what version is this?" <<
168  OtsUDPFirmwareCore::version_ << std::endl;
169  __COUT_ERR__ << "\n" << ss.str();
170  __SS_THROW__;
171  }
172  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex <<
173 stripCSRRegisterValue_ << std::dec << std::endl; std::cout << __COUT_HDR_FL__ << "Done
174 enabling Trigger!!!" << std::endl;
175 
176  return buffer;
177 }
178 
179 //========================================================================================================================
180 void FSSRPurdueFirmware::readBurstDestinationIP(std::string& buffer)
181 {
182  OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000006);
183 }
184 
185 //========================================================================================================================
186 void FSSRPurdueFirmware::readBurstDestinationMAC(std::string& buffer)
187 {
188  OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000007);
189 }
190 
191 //========================================================================================================================
192 void FSSRPurdueFirmware::readBurstDestinationPort(std::string& buffer)
193 {
194  OtsUDPFirmwareCore::read(buffer, (uint64_t)0x0000000100000008);
195 }
196 
197 //========================================================================================================================
198 void FSSRPurdueFirmware::writeBurstDestinationIP(std::string& buffer, const uint64_t
199 value)
200 {
201  OtsUDPFirmwareCore::write(buffer, (uint64_t)0x0000000100000006, value);
202 }
203 
204 //========================================================================================================================
205 void FSSRPurdueFirmware::writeBurstDestinationMAC(std::string& buffer, const uint64_t
206 value)
207 {
208  OtsUDPFirmwareCore::write(buffer, (uint64_t)0x0000000100000007, value);
209 }
210 
211 //========================================================================================================================
212 void FSSRPurdueFirmware::writeBurstDestinationPort(std::string& buffer, const uint64_t
213 value)
214 {
215  OtsUDPFirmwareCore::write(buffer, 0x0000000100000008, value);
216 }
217 
218 //========================================================================================================================
219 std::string FSSRPurdueFirmware::resetBCO(void)
220 {
221  std::cout << __COUT_HDR_FL__ << "Reset BCO!!!" << std::endl;
222  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in :" << std::hex <<
223 stripCSRRegisterValue_ << std::dec << std::endl; std::string buffer;
224 
225  resetTriggerCounterStripCSR(buffer);
226  //write(buffer, STRIP_CSR, stripCSRRegisterValue_);//the write is done in the reset
227  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue :" << std::hex <<
228 stripCSRRegisterValue_ << std::dec << std::endl;
229 
230  //msg->Write(STRIP_SC_CSR,0x90000b95|(chmask<<16));
231  //write(buffer,STRIP_SC_CSR,0x900f0b95);// This is the <SCR,set> command with the bit
232 set to sync SHIFT with BCO=0.
233 
234 
235  enableBCOStripCSR(true);
236  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
237  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex <<
238 stripCSRRegisterValue_ << std::dec << std::endl; std::cout << __COUT_HDR_FL__ << "Done
239 reset BCO!!!" << std::endl;
240 
241  return buffer;
242 }
243 
244 //========================================================================================================================
245 std::string FSSRPurdueFirmware::startStream(bool channel0, bool channel1, bool channel2,
246 bool channel3, bool channel4, bool channel5)
247 {
248  std::cout << __COUT_HDR_FL__ << "Start Stream!" << std::endl;
249  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue in:" << std::hex <<
250 stripCSRRegisterValue_ << std::dec << std::endl; std::string buffer;
251 
252  std::cout << __COUT_HDR_FL__ << " channel0 " << channel0 << " channel1 " << channel1
253 << " channel2 " << channel2 << " channel3 " << channel3 << " channel4 " << channel4 << "
254 channel5 " << channel5 << std::endl;
255 
256  enableChannelsStripCSR(channel0, channel1, channel2, channel3, channel4, channel5);
257  // if (version_ == 1)
258  // enableChannelsStripCSR(true, true, true, true, false, false);
259  // else if (version_ == 2)
260  // enableChannelsStripCSR(true, true, true, true, true, true);
261 
262  enableStreamStripCSR(true); // Turn on streaming hits along with BCO data // was
263 0x0f000f30 OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
264 
265  std::cout << __COUT_HDR_FL__ << "stripCSRRegisterValue out:" << std::hex <<
266 stripCSRRegisterValue_ << std::dec << std::endl; std::cout << __COUT_HDR_FL__ << "Done
267 start Stream!" << std::endl;
268 
269  return buffer;
270 }
271 
272 //========================================================================================================================
273 std::string FSSRPurdueFirmware::stopStream(void)
274 {
275  std::string buffer;
276  enableChannelsStripCSR(false, false, false, false, false, false);
277  enableStreamStripCSR(false);
278  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
279  return buffer;
280 }
281 
282 //========================================================================================================================
283 void FSSRPurdueFirmware::makeDACSequence(FirmwareSequence<uint64_t>& sequence,
284  unsigned int channel, const ROCStream& rocStream)
285 {
286  const ROCDACs& rocDACs = rocStream.getROCDACs();
287  for (DACList::const_iterator it = rocDACs.getDACList().begin(); it
288  != rocDACs.getDACList().end(); it++)
289  {
290  //if(it->first != "SendData" && it->first != "RejectHits") continue;
291  uint64_t data = FSSRROCDefinitions::makeDACWriteCommand(
292  rocStream.getFEWROCAddress(), it->first, it->second.second);
293  sequence.pushBack(ChannelFIFOAddress[channel], data);
294  sequence.pushBack(ChannelFIFOAddress[channel],
295  BitManipulator::insertBits(data, (uint64_t) 0x48, 56, 8));
296  //set WRITE
297  sequence.pushBack(ChannelFIFOAddress[channel],
298  BitManipulator::insertBits(data, (uint64_t) 1, 60, 1));
299  //clr WRITE
300  sequence.pushBack(ChannelFIFOAddress[channel],
301  BitManipulator::insertBits(data, (uint64_t) 0, 60, 1));
302  //clr TALK
303  sequence.pushBack(ChannelFIFOAddress[channel],
304  BitManipulator::insertBits(data, (uint64_t) 0, 62, 1));
305  sequence.pushBack(ChannelFIFOAddress[channel],
306  BitManipulator::insertBits(data, (uint64_t) 0x40, 56, 8));
307  //break;
308  }
309 }
310 
311 //========================================================================================================================
312 void FSSRPurdueFirmware::makeDACSequence(FirmwareSequence<uint32_t>& sequence,
313  unsigned int channel, const ROCStream& rocStream)
314 {
315  const ROCDACs& rocDACs = rocStream.getROCDACs();
316  for (DACList::const_iterator it = rocDACs.getDACList().begin(); it
317  != rocDACs.getDACList().end(); it++)
318  {
319  //RYAN
320  //if(it->first != "SendData" && it->first != "RejectHits") continue;
321  uint64_t data =
322 FSSRROCDefinitions::makeDACWriteCommand(rocStream.getFEWROCAddress(), it->first,
323 it->second.second);
324  //sequence.pushBack(ChannelFIFOAddress[channel], data);
325  //sequence.pushBack(ChannelFIFOAddress[channel],
326 BitManipulator::insertBits(data,(uint32_t)0x48,56,8));
327  //set WRITE
328  //sequence.pushBack(ChannelFIFOAddress[channel],
329 BitManipulator::insertBits(data,(uint32_t)1,60,1));
330  //clr WRITE
331  //sequence.pushBack(ChannelFIFOAddress[channel],
332 BitManipulator::insertBits(data,(uint32_t)0,60,1));
333  //clr TALK
334  //sequence.pushBack(ChannelFIFOAddress[channel],
335 BitManipulator::insertBits(data,(uint32_t)0,62,1));
336  //sequence.pushBack(ChannelFIFOAddress[channel],
337 BitManipulator::insertBits(data,(uint32_t)0x40,56,8));
338 
339 
340  //if(it->first != "SendData" && it->first != "RejectHits") continue;
341  uint32_t data = FSSRROCDefinitions::makeDACWriteHeader(
342  rocStream.getFEWROCAddress(), it->first);
343  //Insert channel
344  BitManipulator::insertBits(data, 1, 16 + channel, 1);
345  sequence.pushBack(ChannelFIFOAddress[channel], it->second.second);
346  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first
347 << " value: "
348  << it->second.second << std::hex << " -> Data: " << data << std::dec
349  << std::endl;
350  sequence.pushBack(STRIP_SC_CSR, data);
351  }
352 }
353 
354 //========================================================================================================================
355 void FSSRPurdueFirmware::makeDACBuffer(std::string& buffer,
356  unsigned int channel, const ROCStream& rocStream)
357 {
358  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Channel: " << channel <<
359 std::endl; const ROCDACs& rocDACs = rocStream.getROCDACs(); for (DACList::const_iterator
360 it = rocDACs.getDACList().begin(); it != rocDACs.getDACList().end(); it++)
361  {
362  std::string bufferElement;
363  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement,
364 STRIP_SC_CSR, 0x80000000); uint32_t registerHeader = 0;
365  //FIXME This must go in the FSSRROCDefinitions stuff
366  if (it->first != "RejectHits" && it->first != "SendData")
367  {
368  OtsUDPFirmwareCore::write(bufferElement, ChannelFIFOAddress[channel],
369 it->second.second); registerHeader = FSSRROCDefinitions::makeDACWriteHeader(
370  rocStream.getFEWROCAddress(), it->first);
371  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " <<
372 it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader
373 << std::dec << std::endl;
374  //Insert channel
375  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
376  }
377  else
378  {
379  if (it->second.second == 1 || it->second.second == 2)
380  {
381  registerHeader = FSSRROCDefinitions::makeDACSetHeader(
382  rocStream.getFEWROCAddress(), it->first);
383  //Insert channel
384  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
385  }
386  else if (it->second.second == 0 || it->second.second == 5)
387  {
388  registerHeader = FSSRROCDefinitions::makeDACResetHeader(
389  rocStream.getFEWROCAddress(), it->first);
390  //Insert channel
391  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
392  }
393  else
394  std::cout << __COUT_HDR_FL__ << "Register value for : " << it->first
395  << " doesn't have a value I expect -> value = "
396  << it->second.second << std::endl;
397 
398  }
399  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first
400 << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader <<
401 std::dec << std::endl; OtsUDPFirmwareCore::write(bufferElement, STRIP_SC_CSR,
402 registerHeader);
403  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement,
404 STRIP_SC_CSR, 0x80000000);
405 
406  //buffer.push_back(bufferElement);
407  buffer += bufferElement;
408  //break;
409  }
410 }
411 
412 //========================================================================================================================
413 void FSSRPurdueFirmware:: makeDACBuffer(std::vector<std::string>& buffer, unsigned int
414 channel, const ROCStream& rocStream)
415 {
416 
417  std::cout << __COUT_HDR_FL__ << "\tMaking DAC Buffer" << std::endl;
418 
419  int limitCount = 0;
420  unsigned int singleVectorCount = 0;
421 
422  std::string alternateBuffer;
423 
424  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Channel: " << channel <<
425 std::endl; const ROCDACs& rocDACs = rocStream.getROCDACs();
426  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Number of DACs: " <<
427 rocDACs.getDACList().size() << std::endl; std::string bufferElement; for
428 (DACList::const_iterator it = rocDACs.getDACList().begin(); it !=
429 rocDACs.getDACList().end(); it++)
430  {
431  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement,
432 STRIP_SC_CSR, 0x80000000); uint32_t registerHeader = 0;
433  //FIXME This must go in the FSSRROCDefinitions stuff
434  if (it->first != "RejectHits" && it->first != "SendData")
435  {
436  OtsUDPFirmwareCore::write(bufferElement, ChannelFIFOAddress[channel],
437 it->second.second); registerHeader = FSSRROCDefinitions::makeDACWriteHeader(
438  rocStream.getFEWROCAddress(), it->first);
439  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " <<
440 it->first << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader
441 << std::dec << std::endl;
442  //Insert channel
443  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
444  }
445  else
446  {
447  if (it->second.second == 1 || it->second.second == 2)
448  {
449  registerHeader = FSSRROCDefinitions::makeDACSetHeader(
450  rocStream.getFEWROCAddress(), it->first);
451  //Insert channel
452  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
453  }
454  else if (it->second.second == 0 || it->second.second == 5)
455  {
456  registerHeader = FSSRROCDefinitions::makeDACResetHeader(
457  rocStream.getFEWROCAddress(), it->first);
458  //Insert channel
459  BitManipulator::insertBits(registerHeader, 1, 16 + channel, 1);
460  }
461  else
462  std::cout << __COUT_HDR_FL__ << "Register value for : " << it->first
463  << " doesn't have a value I expect -> value = "
464  << it->second.second << std::endl;
465 
466  }
467  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "Register: " << it->first
468 << " value: " << it->second.second << std::hex << " -> Data: " << registerHeader <<
469 std::dec << std::endl; OtsUDPFirmwareCore::write(bufferElement, STRIP_SC_CSR,
470 registerHeader);
471  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(bufferElement,
472 STRIP_SC_CSR, 0x80000000);
473 
474  //alternateBuffer += bufferElement;
475  limitCount++;
476  singleVectorCount++;
477 
478  if (limitCount == STIB_DAC_WRITE_MAX)
479  {
480  std::cout << __COUT_HDR_FL__ << "\tBuffer lenght:" << bufferElement.size() <<
481 std::endl; buffer.push_back(bufferElement); limitCount = 0; bufferElement.clear();
482  }
483  else if (singleVectorCount == rocDACs.getDACList().size()) //case for imcomplete
484 packet
485  {
486  buffer.push_back(bufferElement);
487  }
488 
489  //buffer.push_back(bufferElement);
490  //break;
491  }
492  std::cout << __COUT_HDR_FL__ << "\tDone making DAC Buffer" << std::endl;
493 
494 }
495 
496 //========================================================================================================================
497 void FSSRPurdueFirmware::makeMaskBuffer(std::string& buffer, unsigned int channel,
498  const ROCStream& rocStream)
499 {
500  std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl;
501  makeMaskBuffer(buffer, channel, rocStream, "Kill");
502  // makeMaskSequence(buffer, channel, rocStream, "Inject");
503 }
504 
505 //========================================================================================================================
506 void FSSRPurdueFirmware::makeMaskBuffer(std::string& buffer, unsigned int channel, const
507 ROCStream& rocStream, const std::string& registerName)
508 {
509  std::cout << __COUT_HDR_FL__ << "\tMaking mask! " << std::endl;
510  int chipId = rocStream.getFEWROCAddress();
511  std::string mask = rocStream.getROCMask();
512  std::cout << __COUT_HDR_FL__ << "\tMask length: " << mask.length() << std::endl;
513 
514  unsigned int data[4] = { 0, 0, 0, 0 };
515 
516  char val;
517  //int j = 0;
518  for (unsigned int d = 0; d < 4; d++)
519  { //d goes from 0 to 4. 4 bytes
520  //std::cout << __COUT_HDR_FL__ << "---------------------" << d <<
521 "-------------------" << std::endl; for (unsigned int m = 0; m < 8 * 4; m++) { //m goes
522 from 0 to 31, since each byte has 8 bits, there are 32 bits val = mask[(8 * 4 * d) + m];
523 //assigns to val the value of the corresponding bit. 0-31, 32-63, 64-95, 96-127. it goes
524 through each of the 128 bits
525  //std::cout << __COUT_HDR_FL__ << "---------------------" << j++ << std::endl;
526  //std::cout << __COUT_HDR_FL__ << "data[" << d << "] before: " << std::hex <<
527 data[d] << std::dec << std::endl; data[d] |= (unsigned int) atoi(&val) << (8 * 4 - 1 - m);
528  //std::cout << __COUT_HDR_FL__ << "(unsigned int) atoi(&val): " << (unsigned
529 int) atoi(&val) << std::endl;
530  //std::cout << __COUT_HDR_FL__ << "data[" << d << "] after: " << std::hex <<
531 data[d] << std::dec << std::endl;
532  //std::cout << __COUT_HDR_FL__ << std::hex << "D: " << data[d] << " Val: " <<
533 (unsigned int)atoi(&val) << " index: " << std::dec << (8*4-1-m) << " bit: " <<
534 mask[(8*4*d)+m] << std::dec << std::endl;
535  }
536  //
537  }
538 
539  int i, ierr;
540  unsigned int w;
541  unsigned char len = 4;
542  unsigned char addr = 17;//Kill
543  unsigned char bitMask = 1 << channel;
544  unsigned char inst = WRITE;
545 
546  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
547 STRIP_SC_CSR, 0x80000000);
548 
549  for (i = 0; i < 4; i++)
550  //write(buffer, STRIP_SCI + 4 * i, data[i]);
551  OtsUDPFirmwareCore::write(buffer, STRIP_SCI + 4 * (4 - i - 1), data[i]);
552 
553  w = 0x80000000 | (len << 24) | (bitMask << 16) | (inst << 10) | (addr << 5) | chipId;
554 
555  //ierr = OtsUDPFirmwareCore::write(buffer, STRIP_SC_CSR, w);
556  OtsUDPFirmwareCore::write(buffer, STRIP_SC_CSR, w);
557 
558  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
559 STRIP_SC_CSR, 0x80000000);
560 }
561 
562 //========================================================================================================================
563 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint64_t>& sequence,
564  unsigned int channel, const ROCStream& rocStream)
565 {
566  std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl;
567  makeMaskSequence(sequence, channel, rocStream, "Kill");
568  // makeMaskSequence(sequence, channel, rocStream, "Inject");
569 }
570 
571 //========================================================================================================================
572 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint32_t>& sequence,
573  unsigned int channel, const ROCStream& rocStream)
574 {
575  std::cout << __COUT_HDR_FL__ << "Making mask! " << std::endl;
576  makeMaskSequence(sequence, channel, rocStream, "Kill");
577  // makeMaskSequence(channel,rocStream,sequence,"Inject");
578 }
579 
580 //========================================================================================================================
581 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint64_t>& sequence,
582  unsigned int channel, const ROCStream& rocStream,
583  const std::string& registerName)
584 {
585  int chipId = rocStream.getFEWROCAddress();//9, 14 or 21 bcast
586  std::string mask = rocStream.getROCMask();
587  std::cout << __COUT_HDR_FL__ << "Mask length: " << mask.length() << std::endl;
588 
589  uint64_t uInt64Data = 0;
590  std::string stringData = "";
591 
592  //have to manually set every bit for mask writes.
593  //reset fifo
594  //download every bit (shift_in and shift_ctrl) to fifo (setup muxes and control lines)
595  //configure muxes for readout
596  //commence readout
597 
598  //FIFO Controls - byte 5 (7:0)
599  //7 - FIFO Clock
600  //6 - Shift Ctrl bit
601  //MASK_CELL_H - Shift In bit
602  //MUX Controls - byte 0 (7:0)
603  //7 - Read En/Output MUX sel (1 for masks)
604  //1 - Write En for mux
605  //0 - Reset Fifo
606 
607  //reset fifo
608  BitManipulator::insertBits(uInt64Data, 0x1, 56, 8);
609  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
610 
611  //configure fifo for write
612  BitManipulator::insertBits(uInt64Data, 0x2, 56, 8);
613  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
614 
615  //Download every bit (shift_in and shift_control) to fifo (setup muxes and control
616 lines)
617  //Bit 7 of data is FIFO clock, bit 6 is shift_control, bit 5 is shift_in
618  //start bits (ctrl 0, data 0 => ctrl 1, data 0)
619 
620  BitManipulator::insertBits(uInt64Data, 0x40, 16, 8);//(0<<7) | (1<<6) | (0<<5)
621  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
622  BitManipulator::insertBits(uInt64Data, 0xc0, 16, 8);//(1<<7) | (1<<6) | (0<<5) ->
623 clock the data in the fifo sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
624 
625  stringData = FSSRROCDefinitions::makeMaskWriteCommand(chipId,
626  registerName, mask);
627 
628  uint8_t data;
629  for (unsigned int s = 0; s < stringData.length(); s++)
630  for (int b = 8 - 1; b >= 0 && (s * 8 + 8 - b < 13 + 128); b--)
631  {
632  //std::cout << __COUT_HDR_FL__ << "S: " << s << " val: " <<
633 stringData.data()[s] << " b: " << b << " bit: " << ((stringData.data()[s]>>b)&1) <<
634 std::endl; data = 0x40 | (((stringData.data()[s] >> b) & 1) << 5);
635  BitManipulator::insertBits(uInt64Data, (uint64_t) data, 16, 8);
636  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
637  data |= 0x80;
638  BitManipulator::insertBits(uInt64Data, (uint64_t) data, 16, 8);
639  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
640  }
641 
642  //reset Shift Control
643  BitManipulator::insertBits(uInt64Data, 0x0, 16, 8);
644  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
645  BitManipulator::insertBits(uInt64Data, 0x80, 16, 8);
646  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
647 
648  //configure muxes for readout
649  BitManipulator::insertBits(uInt64Data, 0x0, 56, 8);
650  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
651 
652  //commence readout
653  BitManipulator::insertBits(uInt64Data, 0x80, 56, 8);
654  sequence.pushBack(ChannelFIFOAddress[channel], uInt64Data);
655 
656 }
657 
658 //========================================================================================================================
659 void FSSRPurdueFirmware::makeMaskSequence(FirmwareSequence<uint32_t>& sequence,
660  unsigned int channel, const ROCStream& rocStream,
661  const std::string& registerName)
662 {}
663 
664 //========================================================================================================================
665 std::string FSSRPurdueFirmware::readCSRRegister()
666 {
667  std::string buffer;
668  OtsUDPFirmwareCore::read(buffer,STRIP_CSR);
669  return buffer;
670 }
671 
672 //========================================================================================================================
673 void FSSRPurdueFirmware::setFrequencyFromClockState(std::string& buffer, double frequency)
674 {
675  std::cout << __COUT_HDR_FL__ << "Setting up clock frequency!!!" << std::endl;
676 
677  int quotient;
678  int numerator;
679  int denominator;
680  double realClockFrequency;
681 
682  if (BitManipulator::readBits(stripCSRRegisterValue_, 17, 1) == 1) //if fastBCO is
683 enabled quotient = 4; else //normal cases quotient = 8;
684 
685  if (isClockStateExternal()) //base freq: 54MHz
686  {
687  realClockFrequency = EXTERNAL_CLOCK_FREQUENCY / quotient; //this is the REAL
688 frequency being used
689  }
690  else //base freq: 66.667MHz
691  {
692  realClockFrequency = INTERNAL_CLOCK_FREQUENCY / quotient; //this is the REAL
693 frequency being used
694  }
695 
696  double factor = frequency / realClockFrequency;
697 
698  //The device needs the denominator and the denominator to be load into a 5 bit
699 register
700  //It will take two initial numerator and denominator bigger than necessary (to do not
701 loose precision)
702  //and divide them for their gcd. If they still do not fit in 5 bit, they are trunked
703 (divided by 2)
704  //untill they are less than 32
705  numerator = factor * 100; //we will work with 2 digits precision after the decimal
706 point denominator = 100;
707 
708  do
709  {
710  //We will need the GCD at some point in order to simplify fractions //taken from
711 other sources int gcd = numerator; int rest = denominator; int tmp;
712 
713  while (rest != 0)
714  {
715  tmp = rest;
716  rest = gcd % tmp;
717  gcd = tmp;
718  }
719  //Done finding the GCD
720 
721  if (gcd == 1) //if there's no GCD, just divide by 2 to find the nearest
722 approssimation with less bits
723  {
724  numerator /= 2;
725  denominator /= 2;
726  }
727  else
728  {
729  numerator /= gcd;
730  denominator /= gcd;
731  }
732 
733  }
734  while (denominator >= 32 || numerator >= 32);
735  std::cout << __COUT_HDR_FL__ << "Numerator: " << numerator << std::endl;
736  std::cout << __COUT_HDR_FL__ << "Denominator: " << denominator << std::endl;
737  setFrequencyRatio(buffer, numerator, denominator);
738  std::cout << __COUT_HDR_FL__ << "Done with clock frequency setup!!!" << std::endl;
739 }
740 //========================================================================================================================
741 bool FSSRPurdueFirmware::isClockStateExternal() //returns true if the clock state is
742 External
743 {
744  if (BitManipulator::readBits(stripCSRRegisterValue_, 16, 1) == 1)
745  return true;
746  else
747  return false;
748 }
749 
750 //========================================================================================================================
751 void FSSRPurdueFirmware::setCSRRegister(uint32_t total)
752 {
753  stripCSRRegisterValue_ = total;
754 }
755 
756 //========================================================================================================================
757 void FSSRPurdueFirmware::writeCSRRegister(std::string& buffer)
758 {
759  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
760 }
761 
762 //========================================================================================================================
763 void FSSRPurdueFirmware::setPacketSizeStripCSR(uint32_t size)
764 {
765  if (size > 31)
766  std::cout << __COUT_HDR_FL__
767  << "ERROR: Maximum packet size is 31 while here you are trying to set "
768  << size << " packets!" << std::endl;
769  BitManipulator::insertBits(stripCSRRegisterValue_, size, 3, 5);
770  //write(buffer,STRIP_CSR, stripSCRRegisterValue_);
771 }
772 
773 //========================================================================================================================
774 void FSSRPurdueFirmware::enableChannelsStripCSR(bool channel0, bool channel1,
775  bool channel2, bool channel3, bool channel4, bool channel5)
776 {
777  BitManipulator::insertBits(stripCSRRegisterValue_, ((uint32_t) channel0)
778  + ((uint32_t) channel1 << 1) + ((uint32_t) channel2 << 2)
779  + ((uint32_t) channel3 << 3) + ((uint32_t) channel4 << 4)
780  + ((uint32_t) channel5 << 5), 8, 6);
781 }
782 
783 //========================================================================================================================
784 void FSSRPurdueFirmware::setExternalBCOClockSourceStripCSR(std::string clockSource)
785 {
786  if (clockSource == "External")
787  BitManipulator::insertBits(stripCSRRegisterValue_, 1, 16, 1);
788  else if (clockSource == "Internal")
789  BitManipulator::insertBits(stripCSRRegisterValue_, 0, 16, 1);
790 }
791 
792 //========================================================================================================================
793 void FSSRPurdueFirmware::setHaltStripCSR(bool set)
794 {
795  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) set, 17, 1);
796 }
797 
798 //========================================================================================================================
799 void FSSRPurdueFirmware::enableBCOStripCSR(bool enable)
800 {
801  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 19, 1);
802 }
803 
804 //========================================================================================================================
805 void FSSRPurdueFirmware::flushBuffersStripCSR(void)
806 {
807  BitManipulator::insertBits(stripCSRRegisterValue_, 1, 20, 1);
808 }
809 
810 //========================================================================================================================
811 void FSSRPurdueFirmware::resetTriggerCounterStripCSR(std::string& buffer)
812 {
813  BitManipulator::insertBits(stripCSRRegisterValue_, 1, 21, 1);
814  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
815 
816  BitManipulator::insertBits(stripCSRRegisterValue_, 0, 21, 1);
817  OtsUDPFirmwareCore::write(buffer, STRIP_CSR, stripCSRRegisterValue_);
818 }
819 
820 //========================================================================================================================
821 void FSSRPurdueFirmware::resetBCOCounterStripCSR(void)
822 {
823  BitManipulator::insertBits(stripCSRRegisterValue_, 1, 22, 1);
824 }
825 
826 //========================================================================================================================
827 void FSSRPurdueFirmware::enableTriggerStripCSR(bool enable)
828 {
829  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 23, 1);
830 }
831 
832 //========================================================================================================================
833 void FSSRPurdueFirmware::sendTriggerDataStripCSR(bool send)
834 {
835  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 24, 1);
836 }
837 
838 //========================================================================================================================
839 void FSSRPurdueFirmware::sendTriggerNumberStripCSR(bool send)
840 {
841  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 25, 1);
842 }
843 
844 //========================================================================================================================
845 void FSSRPurdueFirmware::sendBCOStripCSR(bool send)
846 {
847  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) send, 26, 1);
848 }
849 
850 //========================================================================================================================
851 void FSSRPurdueFirmware::enableStreamStripCSR(bool enable)
852 {
853  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) enable, 27, 1);
854 }
855 
856 //========================================================================================================================
857 void FSSRPurdueFirmware::resetDCMStripCSR(bool clear)
858 {
859  BitManipulator::insertBits(stripCSRRegisterValue_, (uint32_t) clear, 31, 1);
860 }
861 
862 //========================================================================================================================
863 uint32_t FSSRPurdueFirmware::waitDCMResetStripCSR(void)
864 {
865  uint32_t bitToCheck = 0;
866  BitManipulator::insertBits(bitToCheck, 1, 31, 2);
867  return bitToCheck;
868 }
869 
870 //========================================================================================================================
871 void FSSRPurdueFirmware::resetDAC(void)
872 {
873  BitManipulator::insertBits(stripResetRegisterValue_, 1, 27, 1);
874 }
875 
876 //========================================================================================================================
877 void FSSRPurdueFirmware::resetLink(bool channel0, bool channel1, bool channel2,
878  bool channel3, bool channel4, bool channel5)
879 {
880  stripResetRegisterValue_ = 0;
881  BitManipulator::insertBits(stripResetRegisterValue_,
882  ((uint32_t) channel0) + ((uint32_t) channel1 << 1)
883  + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3)
884  + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5),
885  0, 6);
886  BitManipulator::insertBits(stripResetRegisterValue_, 1, 29, 1);
887 
888  // write(buffer, STRIP_RESET, (1<<28) +
889  // ((uint32_t)channel0) +
890  // ((uint32_t)channel1<<1) +
891  // ((uint32_t)channel2<<2) +
892  // ((uint32_t)channel3<<3) +
893  // ((uint32_t)channel4<<4) +
894  // ((uint32_t)channel5<<5)
895  );
896 
897 }
898 
899 //========================================================================================================================
900 void FSSRPurdueFirmware::clearErrors(bool channel0, bool channel1, bool channel2,
901  bool channel3, bool channel4, bool channel5)
902 {
903  stripResetRegisterValue_ = 0;
904  BitManipulator::insertBits(stripResetRegisterValue_,
905  ((uint32_t) channel0) + ((uint32_t) channel1 << 1)
906  + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3)
907  + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5),
908  0, 6);
909  BitManipulator::insertBits(stripResetRegisterValue_, 1, 29, 1);
910 }
911 
912 //========================================================================================================================
913 void FSSRPurdueFirmware::clearFIFO(bool channel0, bool channel1, bool channel2,
914  bool channel3, bool channel4, bool channel5)
915 {
916  stripResetRegisterValue_ = 0;
917  BitManipulator::insertBits(stripResetRegisterValue_,
918  ((uint32_t) channel0) + ((uint32_t) channel1 << 1)
919  + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3)
920  + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5),
921  0, 6);
922  BitManipulator::insertBits(stripResetRegisterValue_, 1, 30, 1);
923 }
924 
925 //========================================================================================================================
926 void FSSRPurdueFirmware::resetChip(bool channel0, bool channel1, bool channel2,
927  bool channel3, bool channel4, bool channel5)
928 {
929  stripResetRegisterValue_ = 0;
930  BitManipulator::insertBits(stripResetRegisterValue_,
931  ((uint32_t) channel0) + ((uint32_t) channel1 << 1)
932  + ((uint32_t) channel2 << 2) + ((uint32_t) channel3 << 3)
933  + ((uint32_t) channel4 << 4) + ((uint32_t) channel5 << 5),
934  0, 6);
935  BitManipulator::insertBits(stripResetRegisterValue_, 1, 31, 1);
936 }
937 
938 //========================================================================================================================
939 void FSSRPurdueFirmware::setFrequencyRatio(std::string& buffer, int numerator, int
940 denominator)
941 {
942  //The device need to load numerator minus one and denominator minus one, with an
943 internal address of 0x50 and 052 respectively OtsUDPFirmwareCore::write(buffer,
944 STRIP_BCO_DCM, 0x80500000 + (numerator - 1)); // Set BCOCLK numerator // was 0x80500003
945  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
946 STRIP_BCO_DCM, 0xf0000000); // Wait DCM write to finish // was 0x80000000
947 
948  OtsUDPFirmwareCore::write(buffer, STRIP_BCO_DCM, 0x80520000 + (denominator - 1)); //
949 Set BCOCLK denominator // was 0x80520001
950  //FIXME? Does Nothing RAR Aug 2017//OtsUDPFirmwareCore::waitClear(buffer,
951 STRIP_BCO_DCM, 0xf0000000); // Wait DCM write to finish - BCO frequency should be 13.513
952 MHz // was 0x80000000
953 }
954 
955 //========================================================================================================================
956 void FSSRPurdueFirmware::BCOOffset(uint32_t offset)
957 {
958  BitManipulator::insertBits(stripTriggerCSRRegisterValue_, offset, 0, 4);
959 }
960 
961 //========================================================================================================================
962 void FSSRPurdueFirmware::selectSpyFIFO(uint32_t input)
963 {
964  BitManipulator::insertBits(stripTriggerCSRRegisterValue_, input, 4, 3);
965 }
966 
967 //========================================================================================================================
968 void FSSRPurdueFirmware::halt(bool halt)
969 {
970  BitManipulator::insertBits(stripTriggerCSRRegisterValue_, (uint32_t) halt, 7, 1);
971 }
972 
973 //========================================================================================================================
974 void FSSRPurdueFirmware::configureStripTriggerUnbiased(std::string& buffer)
975 {
976  OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_UNBIASED, 0x002805c); // Configure
977 unbiased trigger
978 }
979 
980 //========================================================================================================================
981 void FSSRPurdueFirmware::configureTriggerInputs(std::string& buffer)
982 {
983  OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_0, 0x3f440000); // FSSR GOTHIT
984 trigger input channel 0,1 OtsUDPFirmwareCore::write(buffer, STRIP_TRIG_INPUT_1,
985 0x3f440000); // FSSR GOTHIT trigger input channel 2,3 OtsUDPFirmwareCore::write(buffer,
986 STRIP_TRIG_INPUT_2, 0x0); // FSSR GOTHIT trigger input channel 4,5
987 }
988 
989 //========================================================================================================================
990 std::string FSSRPurdueFirmware::resetSlaveBCO(void)
991 {
992  std::string buffer;
993  OtsUDPFirmwareCore::write(buffer, (uint64_t)0xc5000000, (uint64_t)0x00000008);
994  return buffer;
995 }
996 
997  //========================================================================================================================
998  void FSSRPurdueFirmware::chipID(uint32_t size)
999  {
1000  BitManipulator::insertBits(stripSCRegisterValue_, size, 0, 5);
1001  }
1002 
1003  //========================================================================================================================
1004  void FSSRPurdueFirmware::addressSlowControls(uint32_t size)
1005  {
1006  BitManipulator::insertBits(stripSCRegisterValue_, size, 5, 5);
1007  }
1008 
1009  //========================================================================================================================
1010  void FSSRPurdueFirmware::instructionSlowControls(uint32_t size)
1011  {
1012  BitManipulator::insertBits(stripSCRegisterValue_, size, 10, 3);
1013  }
1014 
1015  //========================================================================================================================
1016  void FSSRPurdueFirmware::channelreadSelect(uint32_t size)
1017  {
1018  BitManipulator::insertBits(stripSCRegisterValue_, size, 13, 3);
1019  }
1020 
1021  //========================================================================================================================
1022  void FSSRPurdueFirmware::channelMask(uint32_t size)
1023  {
1024  BitManipulator::insertBits(stripSCRegisterValue_, size, 16, 8);
1025  }
1026 
1027  //========================================================================================================================
1028  void FSSRPurdueFirmware::bitsLength(uint32_t length)
1029  {
1030  BitManipulator::insertBits(stripSCRegisterValue_, length, 26, 3);
1031  }
1032 
1033 
1034  //========================================================================================================================
1035  void FSSRPurdueFirmware::syncFallingBCO(bool sync)
1036  {
1037  BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)sync, 28, 1);
1038  }
1039 
1040  //========================================================================================================================
1041  void FSSRPurdueFirmware::syncRisingBCO(bool sync)
1042  {
1043  BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)sync, 29, 1);
1044  }
1045 
1046  //========================================================================================================================
1047  void FSSRPurdueFirmware::setRaw(bool set)
1048  {
1049  BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)set, 30, 1);
1050  }
1051 
1052  //========================================================================================================================
1053  void FSSRPurdueFirmware::initSlowControls(bool init)
1054  {
1055  BitManipulator::insertBits(stripSCRegisterValue_, (uint32_t)init, 31, 1);
1056  }
1057 
1058  //========================================================================================================================
1059  void FSSRPurdueFirmware::resetCount(bool reset)
1060  {
1061  BitManipulator::insertBits(stripAnalysisCSRRegisterValue_, (uint32_t)reset, 30, 1);
1062  }
1063 
1064  //========================================================================================================================
1065  void FSSRPurdueFirmware::setBCO_0(uint32_t void FSSRPurdueFirmware::BCOOffset(uint32_t
1066 offset)
1067  {
1068  BitManipulator::insertBits(stripTrigCSRRegisterValue_, offset, 0, 4);
1069  }input)
1070  {
1071  BitManipulator::insertBits(trigInputRegisterValue_, input, 0, 8);
1072  }
1073 
1074  //========================================================================================================================
1075  void FSSRPurdueFirmware::setBCO_1(uint32_t input)
1076  {
1077  BitManipulator::insertBits(trigInputRegisterValue_, input, 8, 8);
1078  }
1079 
1080  //========================================================================================================================
1081  void FSSRPurdueFirmware::trimFracBCO_0(uint32_t input)
1082  {
1083  BitManipulator::insertBits(trigInputRegisterValue_, input, 16, 4);
1084  }
1085 
1086  //========================================================================================================================
1087  void FSSRPurdueFirmware::trimFracBCO_1(uint32_t input)
1088  {
1089  BitManipulator::insertBits(trigInputRegisterValue_, input, 20, 4);
1090  }
1091 
1092  //========================================================================================================================
1093  void FSSRPurdueFirmware::enable_0(bool enable)
1094  {
1095  BitManipulator::insertBits(trigInputRegisterValue_, (uint32_t)enable, 28, 1);
1096  }
1097 
1098  //========================================================================================================================
1099  void FSSRPurdueFirmware::enable_1(bool enable)
1100  {
1101  BitManipulator::insertBits(trigInputRegisterValue_, (uint32_t)enable, 29, 1);
1102  }
1103 
1104  */