diff --git a/SoapyHifiBerrySettings.cpp b/SoapyHifiBerrySettings.cpp index 39b4ad7..9105134 100644 --- a/SoapyHifiBerrySettings.cpp +++ b/SoapyHifiBerrySettings.cpp @@ -5,7 +5,7 @@ * Device interface **********************************************************************/ const cfg::File::ConfigMap defaultOptions = { - {"si5351", {{"correction", cfg::makeOption("0")}, {"mode", cfg::makeOption("single")} , {"rxdrive", cfg::makeOption("2")}, {"t.xdrive", cfg::makeOption("2")}}}, + {"si5351", {{"correction", cfg::makeOption("0")}, {"mode", cfg::makeOption("single")} , {"rxdrive", cfg::makeOption("8")}, {"t.xdrive", cfg::makeOption("8")}}}, {"sound", {{"device", cfg::makeOption("snd_rpi_hifiberry_dacplusadcpro")}, {"samplerate", cfg::makeOption("192000")}, {"input", cfg::makeOption("DIFF")}}}}; int SoapyHifiBerry::get_int(string section, string key) @@ -39,7 +39,7 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args) SoapySDR_setLogLevel(SOAPY_SDR_INFO); SoapySDR_log(SOAPY_SDR_INFO, "SoapyHifiBerry::SoapyHifiBerry constructor called"); no_channels = 1; - txDrive = rxDrive = SI5351_DRIVE_2MA; + txDrive = rxDrive = SI5351_DRIVE_8MA; modeIQ = false; uptr_cfg = make_unique(); @@ -63,7 +63,7 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args) rxDrive = SI5351_DRIVE_8MA; break; default: - rxDrive = SI5351_DRIVE_2MA; + rxDrive = SI5351_DRIVE_8MA; break; } @@ -80,7 +80,7 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args) txDrive = SI5351_DRIVE_8MA; break; default: - txDrive = SI5351_DRIVE_2MA; + txDrive = SI5351_DRIVE_8MA; break; } @@ -145,7 +145,7 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args) { pTCA9548 = std::make_unique("/dev/i2c-1", 0x70); pTCA9548->begin(1); - pSI5351 = make_unique("/dev/i2c-1", SI5351_BUS_BASE_ADDR); + pSI5351 = make_unique("/dev/i2c-1", SI5351_BUS_BASE_ADDR, CLK_VFO_I, CLK_VFO_Q); if (pSI5351->init(SI5351_CRYSTAL_LOAD_8PF, 0, 0)) { pSI5351->drive_strength(CLK_VFO_I, rxDrive); @@ -156,8 +156,8 @@ SoapyHifiBerry::SoapyHifiBerry(const SoapySDR::Kwargs &args) pSI5351->update_status(); } pTCA9548->setChannelMask(2); - pSI5351tx = make_unique("/dev/i2c-1", SI5351_BUS_BASE_ADDR); - if (pSI5351tx->init(SI5351_CRYSTAL_LOAD_8PF, 0, 0)) + pSI5351tx = make_unique("/dev/i2c-1", SI5351_BUS_BASE_ADDR, CLK_VFO_I, CLK_VFO_Q); + if (pSI5351tx->init(SI5351_CRYSTAL_LOAD_8PF, 0, 0, pSI5351->getFileHandle())) { pSI5351tx->drive_strength(CLK_VFO_I, rxDrive); pSI5351tx->drive_strength(CLK_VFO_Q, rxDrive); diff --git a/si5351.cpp b/si5351.cpp index 2f52d75..fd12c86 100644 --- a/si5351.cpp +++ b/si5351.cpp @@ -77,20 +77,27 @@ Si5351::~Si5351() * I2C address. * */ -bool Si5351::init(uint8_t xtal_load_c, uint32_t xo_freq, int32_t corr) +bool Si5351::init(uint8_t xtal_load_c, uint32_t xo_freq, int32_t corr, int fileHandle) { //Open i2c device - int file; - if((file = open(i2c_filepath.data(), O_RDWR)) < 0) { - return false; - } - i2c_file = file; + if (fileHandle) + i2c_file = fileHandle; + else + { + int file; + if ((file = open(i2c_filepath.data(), O_RDWR)) < 0) + { + return false; + } + i2c_file = file; - //Set address - if(ioctl(file, I2C_SLAVE_FORCE, i2c_bus_addr) < 0) { - return false; - } - // Wait for SYS_INIT flag to be clear, indicating that device is ready + //Set address + if (ioctl(file, I2C_SLAVE_FORCE, i2c_bus_addr) < 0) + { + return false; + } + } + // Wait for SYS_INIT flag to be clear, indicating that device is ready uint8_t status_reg = 0; do{ status_reg = si5351_read(SI5351_DEVICE_STATUS); @@ -1829,7 +1836,7 @@ uint8_t Si5351::select_r_div_ms67(uint64_t *freq) return r_div; } -void Si5351::setIQFrequency(long freq) +void Si5351::setIQFrequency(int freq) { int mult = 0; diff --git a/si5351.h b/si5351.h index ecb3223..476bebb 100644 --- a/si5351.h +++ b/si5351.h @@ -318,11 +318,11 @@ class Si5351 public: Si5351(const char *i2c_device_filepath, uint8_t i2c_addr = SI5351_BUS_BASE_ADDR, si5351_clock iclock = SI5351_CLK0, si5351_clock qclock = SI5351_CLK1); ~Si5351(); - bool init(uint8_t, uint32_t, int32_t); + bool init(uint8_t, uint32_t, int32_t, int fileHandle = 0); void reset(void); uint8_t set_freq(uint64_t, enum si5351_clock); uint8_t set_freq_manual(uint64_t, uint64_t, enum si5351_clock); - void setIQFrequency(long freq); + void setIQFrequency(int freq); void set_pll(uint64_t, enum si5351_pll); void set_ms(enum si5351_clock, struct Si5351RegSet, uint8_t, uint8_t, uint8_t); void output_enable(enum si5351_clock, uint8_t); @@ -354,6 +354,7 @@ class Si5351 enum si5351_pll_input plla_ref_osc; enum si5351_pll_input pllb_ref_osc; uint32_t xtal_freq[2]; + int getFileHandle() { return i2c_file; } private: uint64_t pll_calc(enum si5351_pll, uint64_t, struct Si5351RegSet *, int32_t, uint8_t);