Skip to content
Snippets Groups Projects
Commit 2f66842d authored by Sergey Musikhin's avatar Sergey Musikhin
Browse files

dc_calibration

parent e950c208
Branches
No related tags found
No related merge requests found
......@@ -149,6 +149,14 @@ parameters:
option_labels: ['Disabled', 'Bypassed']
hide: part
- id: dc_calibration
label: 'DC calibration'
category: x40/x115
dtype: enum
default: 'LPF_TUNING'
options: ['LPF_TUNING', 'TX_LPF', 'RX_LPF', 'RXVGA2']
hide: part
......@@ -207,6 +215,7 @@ templates:
+ ",tamer=" + '${'$'}{tamer}'
+ ",sampling=" + '${'$'}{sampling}'
+ ",lpf_mode="+'${'$'}{lpf_mode}'
+ ",dc_calibration="+'${'$'}{dc_calibration}'
+ ",trigger0="+'${'$'}{trigger0}'
+ ",trigger_role0="+'${'$'}{trigger_role0}'
+ ",trigger_signal0="+'${'$'}{trigger_signal0}'
......
......@@ -130,9 +130,21 @@ size_t num_streams(bladerf_channel_layout layout)
#endif
}
template<typename T>
T get_enum_value(const std::vector<std::pair<std::string, T>> & values,
const std::string& name)
{
for(const auto & v: values)
{
if(v.first == name)
return v.second;
}
return T(-1);
}
bladerf_trigger_signal get_signal(const std::string & name)
{
const std::vector<std::pair<std::string, bladerf_trigger_signal>> signals
return get_enum_value<bladerf_trigger_signal>(
{
{"J71_4",BLADERF_TRIGGER_J71_4},
{"J51_1",BLADERF_TRIGGER_J51_1},
......@@ -145,15 +157,21 @@ bladerf_trigger_signal get_signal(const std::string & name)
{"USER_5",BLADERF_TRIGGER_USER_5},
{"USER_6",BLADERF_TRIGGER_USER_6},
{"USER_7",BLADERF_TRIGGER_USER_7},
};
for(const auto & s: signals)
{
if(s.first == name)
return s.second;
}, name);
}
return BLADERF_TRIGGER_INVALID;
bladerf_cal_module get_calibrate_module(const std::string & module)
{
return get_enum_value<bladerf_cal_module>(
{
{"LPF_TUNING",BLADERF_DC_CAL_LPF_TUNING},
{"TX_LPF",BLADERF_DC_CAL_TX_LPF},
{"RX_LP",BLADERF_DC_CAL_RX_LPF},
{"RXVGA2",BLADERF_DC_CAL_RXVGA2},
},module);
}
/******************************************************************************
* Public methods
******************************************************************************/
......@@ -428,6 +446,15 @@ void bladerf_common::init_bladerf1(const dict_t &dict, bladerf_direction directi
}
}
if (dict.count("dc_calibration")) {
bladerf_cal_module module = get_calibrate_module( _get(dict, "dc_calibration"));
auto status = bladerf_calibrate_dc(_dev.get(), module);
if(status != 0)
{
BLADERF_THROW_STATUS(status, "Failed to calibrate");
}
}
bladerf_channel ch = (direction == BLADERF_RX) ? BLADERF_CHANNEL_RX(0)
: BLADERF_CHANNEL_TX(0);
if (dict.count("lpf_mode")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment