Scope
FPGAIO5751.cpp
1 #include "stdafx.h"
2 #include "FPGAIO5751.h"
3 
4 namespace scope {
5 
6 FPGAIO5751::FPGAIO5751(const uint32_t& _configured)
7  : configured_indicator(_configured) {
8 
9 }
10 
11 void FPGAIO5751::SetClockSource(NiFpga_Session _session, const uint8_t& _clock_source) {
12  NiFpga_Bool configured = false;
13  uint32_t waitcounter = 0;
14 
15  // Wait until moduled has configured itself
16  do {
17  iostatus = NiFpga_ReadBool(_session, configured_indicator, &configured);
18  std::this_thread::sleep_for(std::chrono::milliseconds(20)); // Wait 20 milliseconds
19  waitcounter += 20;
20  } while ( !configured && (waitcounter < 2000) );
21  if ( waitcounter >= 5000 )
22  throw FPGAException(-1, "SetClockSource adapter module not configured");
23 
25  //if ( (_clock_source == 1) || (_clock_source == 3) ) {
26  // NiFpga_Bool locked = false;
27  // uint32_t waitcounter = 0;
28 
29  // do {
30  // iostatus = NiFpga_ReadBool(_session, pll_locked_indicator, &locked);
31  // std::this_thread::sleep_for(std::chrono::milliseconds(20)); // Wait 20 milliseconds
32  // waitcounter += 20;
33  // } while ( !locked && (waitcounter < 5000) );
34  // if ( waitcounter >= 5000 )
35  // throw FPGAException(-1, "SetClockSource PLL not locked");
36 
37  // // Wait 6 seconds for the lock to settle (! this is copied from NI's example Labview code...)
38  // std::this_thread::sleep_for(std::chrono::seconds(6));
39  //}
40 }
41 
42 bool FPGAIO5751::CheckIOModule(NiFpga_Session _session) {
43  return true;
44 }
45 
46 }
FPGAIO5751(const uint32_t &_configured)
Get the FPGA VI control/indicator ids.
Definition: FPGAIO5751.cpp:6
const uint32_t configured_indicator
the Configure? indicator on the FPGA
Definition: FPGAIO5751.h:15
An exception for FPGA stuff.
Definition: FPGAException.h:9
void SetClockSource(NiFpga_Session _session, const uint8_t &_clock_source=0)
Possible clock sources (see adapter modules help and Configure Clock.vi from NI 5751 Clock Select exa...
Definition: FPGAIO5751.cpp:11
bool CheckIOModule(NiFpga_Session _session)
Necessary calls at the moment not supported by NI FPGA API 12.0, see CheckIOModule.vi for what to do.
Definition: FPGAIO5751.cpp:42
This is the include file for standard system include files, or project specific include files that ar...
FPGAStatusSafe iostatus
Current status of the module.
Definition: FPGAIO5751.h:19