diff --git a/apps/fm_receiver.grc b/apps/fm_receiver.grc index 1fcd7066d93289bf620ffb6e5f01f5d0c5a317bb..555253f444674cda37800140eccc6c57cc89db7b 100644 --- a/apps/fm_receiver.grc +++ b/apps/fm_receiver.grc @@ -179,7 +179,7 @@ blocks: comment: '' corr0: '0' corr1: '0' - dac: '10000' + dac: '8000' dc_offset_mode0: '0' dc_offset_mode1: '0' device_id: '0' @@ -201,11 +201,17 @@ blocks: nchan: '1' out_clk: 'False' power_monitoring: Enable - ref_clk: '1000000' + ref_clk: '0' sample_rate: samp_rate + trigger0: 'False' + trigger1: 'False' + trigger_role0: master + trigger_role1: master + trigger_signal0: J51_1 + trigger_signal1: J51_1 type: fc32 verbosity: warning - xb200: auto3db + xb200: none states: bus_sink: false bus_source: false diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index 9dd91c3981e5d704f54c2267a0d1b1242503d1b9..46d86f961b15a8aa8d1056597f6f6cdae5e908af 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -247,7 +247,6 @@ void bladerf_common::init(dict_t const &dict, bladerf_direction direction) "fpga=/path/to/the/bitstream.rbf to load it."); } - /* XB-200 Transverter Board */ if (dict.count("xb200") && _get(dict, "xb200") != "none") { init_xb200(_get(dict, "xb200"), direction); @@ -262,6 +261,19 @@ void bladerf_common::init(dict_t const &dict, bladerf_direction direction) } } + if (dict.count("in_clk")) { + init_input_clock(_get(dict, "in_clk")); + } + + if (dict.count("out_clk")) { + init_output_clock(_get(dict, "out_clk") == "True"); + } + + if (dict.count("dac")) { + init_dac(boost::lexical_cast<uint16_t>(_get(dict, "dac"))); + } + + /* Show some info about the device we've opened */ print_device_info(); @@ -465,6 +477,51 @@ void bladerf_common::init_refclk(int freq) } } +void bladerf_common::init_input_clock(const std::string &clock_selection) +{ + bladerf_clock_select sel; + if(clock_selection == "ONBOARD") + sel = CLOCK_SELECT_ONBOARD; + if(clock_selection == "EXTERNAL") + sel = CLOCK_SELECT_EXTERNAL; + + auto status = bladerf_set_clock_select(_dev.get(),sel); + if (status != 0) { + BLADERF_WARNING("bladerf_set_clock_select: " + << bladerf_strerror(status)); + } +} + +void bladerf_common::init_output_clock(bool enable) +{ + auto status = bladerf_set_clock_output(_dev.get(), enable); + if (status != 0) { + BLADERF_WARNING("bladerf_set_clock_output: " + << bladerf_strerror(status)); + } +} + +void bladerf_common::init_dac(uint16_t dac) +{ + auto status = bladerf_trim_dac_write(_dev.get(), dac); + if (status != 0) { + BLADERF_WARNING("bladerf_trim_dac_write: " + << bladerf_strerror(status)); + } + else + { + status = bladerf_trim_dac_read(_dev.get(), &dac); + if (status != 0) { + BLADERF_WARNING("bladerf_trim_dac_read: " + << bladerf_strerror(status)); + } + else + { + BLADERF_INFO("trim dac value: " << dac); + } + } +} + void bladerf_common::set_channel_enable(bladerf_channel ch, bool enable) { _enables[ch] = enable; diff --git a/lib/bladerf/bladerf_common.h b/lib/bladerf/bladerf_common.h index 51fa26228b2affa7175d719ba22b9ae1423cb683..ac6878abf71d536f0cb6accf55ad9b3e78e159b3 100644 --- a/lib/bladerf/bladerf_common.h +++ b/lib/bladerf/bladerf_common.h @@ -165,7 +165,9 @@ protected: void init_xb200(const std::string & filter, bladerf_direction direction); void init_refclk(int freq); - + void init_input_clock(const std::string & clock_selection); + void init_output_clock(bool enable); + void init_dac(uint16_t dac); void set_channel_enable(bladerf_channel ch, bool enable); bool get_channel_enable(bladerf_channel ch);