1 /** 2 @file Si5351C.h 3 @brief Header for Si5351C.cpp 4 @author Lime Microsystems 5 */ 6 7 #ifndef SI5351C_MODULE 8 #define SI5351C_MODULE 9 10 #include <stdio.h> 11 #include <string> 12 #include "LimeSuiteConfig.h" 13 //--------------------------------------------------------------------------- 14 namespace lime{ 15 16 enum eSi_CLOCK_INPUT 17 { 18 Si_CLKIN, 19 Si_XTAL, 20 Si_CMOS 21 }; 22 23 struct Si5351_Channel 24 { Si5351_ChannelSi5351_Channel25 Si5351_Channel() : outputDivider(1), outputFreqHz(1), multisynthDivider(1), pllSource(0), 26 phaseOffset(0), powered(true), inverted(false), int_mode(false) {}; 27 int outputDivider; 28 unsigned long outputFreqHz; 29 float multisynthDivider; 30 int pllSource; 31 float phaseOffset; 32 bool powered; 33 bool inverted; 34 bool int_mode; 35 }; 36 37 struct Si5351_PLL 38 { Si5351_PLLSi5351_PLL39 Si5351_PLL() : inputFreqHz(0), VCO_Hz(0), feedbackDivider(0), CLKIN_DIV(1), CLK_SRC(1) {} 40 unsigned long inputFreqHz; 41 float VCO_Hz; 42 float feedbackDivider; 43 int CLKIN_DIV; 44 int CLK_SRC; //0-XTAL, 1-CLKIN 45 }; 46 47 class IConnection; 48 class LIME_API Si5351C 49 { 50 public: 51 enum Status 52 { 53 SUCCESS, 54 FAILED, 55 }; 56 57 struct StatusBits 58 { StatusBitsStatusBits59 StatusBits() : sys_init(0), sys_init_stky(0), lol_b(0), lol_b_stky(0), lol_a(0), lol_a_stky(0), los(0), los_stky(0) 60 { 61 62 } 63 int sys_init; 64 int sys_init_stky; 65 int lol_b; 66 int lol_b_stky; 67 int lol_a; 68 int lol_a_stky; 69 int los; 70 int los_stky; 71 }; 72 73 StatusBits GetStatusBits(); 74 Status ClearStatus(); 75 76 Si5351C(); 77 ~Si5351C(); 78 void Initialize(IConnection *mng); 79 bool LoadRegValuesFromFile(std::string FName); 80 81 void SetPLL(unsigned char id, unsigned long CLKIN_Hz, int CLK_SRC); 82 void SetClock(unsigned char id, unsigned long fOut_Hz, bool enabled = true, bool inverted = false); 83 84 Status UploadConfiguration(); 85 Status ConfigureClocks(); 86 void Reset(); 87 88 private: 89 void FindVCO(Si5351_Channel *clocks, Si5351_PLL *plls, const unsigned long Fmin, const unsigned long Fmax); 90 IConnection *device; 91 int addrSi5351; 92 93 Si5351_PLL PLL[2]; 94 Si5351_Channel CLK[8]; 95 96 static const unsigned char m_defaultConfiguration[]; 97 unsigned char m_newConfiguration[255]; 98 99 100 }; 101 102 } 103 #endif // SI5351C_MODULE 104