-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock_sync.cpp
63 lines (48 loc) · 1.44 KB
/
clock_sync.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <cstdlib>
#include "lime/LimeSuite.h"
#include <iostream>
#include "math.h"
#include <thread>
#include <memory.h>
using namespace std;
#define N_RADIOS 4
static lms_device_t* m_lms_device;
static int m_n_devices;
static int error()
{
//print last error message
cout << "ERROR:" << LMS_GetLastErrorMessage();
if (m_lms_device != NULL)
LMS_Close(m_lms_device);
exit(-1);
}
void lime_terminate(void)
{
//Close device
LMS_Close(m_lms_device);
}
int main( void )
{
// This blocks
// Set all device handles to NULL
m_lms_device = NULL;
//Find devices
int n;
lms_info_str_t list[N_RADIOS]; //should be large enough to hold all detected devices
if ((m_n_devices = LMS_GetDeviceList(list)) < 0) error();//NULL can be passed to only get number of devices
cout << "Devices found: " << m_n_devices << endl; //print number of devices
if (m_n_devices < 1) return -1;
for(int i = 0; i<N_RADIOS; i++){
//open the first device
if (LMS_Open(&m_lms_device, list[i], NULL)) error();
//Initialize device with default configuration
//Do not use if you want to keep existing configuration
if (LMS_Init(m_lms_device) != 0) error();
//if (LMS_Reset(m_lms_device) != 0) error();
// just set EXTREF
if (LMS_SetClockFreq(m_lms_device, LMS_CLOCK_EXTREF, 10000000) != 0) error();
cout << "EXTREF set" << endl;
lime_terminate();
}
return 0;
}