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