mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
hbx: Fix LTC freq lookup logic
Previously the logic for the LTC5594 configuration was wrong. We sometimes fell back into the default case which then didn't choose the default but the first row in our lookup table. The default value was now moved into an own constant and the lookup logic is now inverted to be correct.
This commit is contained in:
parent
c4ae50a9cb
commit
eab0f7fe89
@ -102,11 +102,14 @@ static const std::vector<ltc5594_lo_matching_t> lo_matching_table = {
|
||||
{ 1242e6, 1411e6, 1, 21, 3, 28 },
|
||||
{ 1411e6, 1696e6, 1, 17, 2, 26 },
|
||||
{ 1696e6, 2070e6, 1, 15, 1, 31 },
|
||||
{ 0, 0, 1, 8, 3, 3 }, // Default
|
||||
{ 2070e6, 2470e6, 1, 8, 1, 21 },
|
||||
{ 2470e6, 2980e6, 1, 2, 1, 10 },
|
||||
{ 2980e6, 3500e6, 1, 1, 0, 19 },
|
||||
{ 3500e6, 9000e6, 1, 0, 0, 0 }
|
||||
};
|
||||
|
||||
static const ltc5594_lo_matching_t default_lo_matching = {
|
||||
0, 0, 1, 8, 3, 3
|
||||
};
|
||||
// Turn clang-format back on
|
||||
// clang-format on
|
||||
|
||||
@ -165,20 +165,14 @@ private:
|
||||
{
|
||||
auto settings = lo_matching_table.begin();
|
||||
auto settings_end = lo_matching_table.end();
|
||||
// Check if the frequency is within the range of the settings, else return the
|
||||
// default settings saved at min=0, max=0:
|
||||
if ((*settings).min_band_freq <= lo_freq
|
||||
&& (*settings_end).max_band_freq >= lo_freq) {
|
||||
lo_freq = 0.0;
|
||||
}
|
||||
for (; settings != settings_end; ++settings) {
|
||||
if (settings->max_band_freq >= lo_freq) {
|
||||
if (settings->min_band_freq <= lo_freq
|
||||
&& settings->max_band_freq >= lo_freq) {
|
||||
return *settings;
|
||||
}
|
||||
}
|
||||
// If no matching setting is found, throw an exception
|
||||
throw std::runtime_error(
|
||||
"No matching LO settings found for the given frequency.");
|
||||
// If no matching setting is found, return default settings
|
||||
return default_lo_matching;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user