aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/e3xx
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2022-01-12 14:47:54 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2022-02-04 13:16:00 -0600
commit42ff4fb7f5a3e37714f025473f95089bf1ff8c98 (patch)
tree6d70a54cd704c95149f4b2c03bf32505fe26014a /host/lib/usrp/dboard/e3xx
parent3e496cbda1d809d2ca15f69cfa231424bf47179f (diff)
downloaduhd-42ff4fb7f5a3e37714f025473f95089bf1ff8c98.tar.gz
uhd-42ff4fb7f5a3e37714f025473f95089bf1ff8c98.tar.bz2
uhd-42ff4fb7f5a3e37714f025473f95089bf1ff8c98.zip
uhd: Harmonize fuzzy frequency comparisons
Throughout UHD, we often do floating-point comparisons for frequency ranges that require resilience to floating point rounding errors. Most of the time the checks look like this: ```cpp if (fp_compare_epsilon<double>(freq) > boundary) { // ... } ``` The exception is the N320 daughterboard control, which uses a custom epsilon: ```cpp if (fp_compare_epsilon<double>(freq, RHODIUM_FREQ_COMPARE_EPSILON) > boundary) { // ... } ``` This was, for the most part, not by design, but because authors simply didn't think about which epsilon value was appropriate for the frequency comparison. This was complicated by the fact that fp_compare_epsilon previously had some issues. This patch introduces FREQ_COMPARE_EPSILON, which is a sensible default value for fp_compare_epsilon when doing frequency comparisons (note that fp_compare_delta already had such a value). Also, it introduces freq_compare_epsilon(x), which is a shorthand for fp_compare_epsilon<double>(x, FREQ_COMPARE_EPSILON). We then replace all occurrences of fp_compare_epsilon<double> which are specific to frequency checks with freq_compare_epsilon.
Diffstat (limited to 'host/lib/usrp/dboard/e3xx')
-rw-r--r--host/lib/usrp/dboard/e3xx/e3xx_bands.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/host/lib/usrp/dboard/e3xx/e3xx_bands.cpp b/host/lib/usrp/dboard/e3xx/e3xx_bands.cpp
index e28acf3b9..e9226216b 100644
--- a/host/lib/usrp/dboard/e3xx/e3xx_bands.cpp
+++ b/host/lib/usrp/dboard/e3xx/e3xx_bands.cpp
@@ -146,21 +146,21 @@ e3xx_radio_control_impl::rx_band e3xx_radio_control_impl::map_freq_to_rx_band(
{
e3xx_radio_control_impl::rx_band band;
- if (fp_compare_epsilon<double>(freq) < AD9361_RX_MIN_FREQ) {
+ if (freq_compare_epsilon(freq) < AD9361_RX_MIN_FREQ) {
band = rx_band::INVALID_BAND;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_LB_BAND3_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_LB_BAND3_MIN_FREQ) {
band = rx_band::LB_B2;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_LB_BAND4_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_LB_BAND4_MIN_FREQ) {
band = rx_band::LB_B3;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_LB_BAND5_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_LB_BAND5_MIN_FREQ) {
band = rx_band::LB_B4;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_LB_BAND6_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_LB_BAND6_MIN_FREQ) {
band = rx_band::LB_B5;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_LB_BAND7_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_LB_BAND7_MIN_FREQ) {
band = rx_band::LB_B6;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_RX_HB_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_RX_HB_MIN_FREQ) {
band = rx_band::LB_B7;
- } else if (fp_compare_epsilon<double>(freq) <= AD9361_RX_MAX_FREQ) {
+ } else if (freq_compare_epsilon(freq) <= AD9361_RX_MAX_FREQ) {
band = rx_band::HB;
} else {
band = rx_band::INVALID_BAND;
@@ -174,25 +174,25 @@ e3xx_radio_control_impl::tx_band e3xx_radio_control_impl::map_freq_to_tx_band(
{
e3xx_radio_control_impl::tx_band band;
- if (fp_compare_epsilon<double>(freq) < AD9361_TX_MIN_FREQ) {
+ if (freq_compare_epsilon(freq) < AD9361_TX_MIN_FREQ) {
band = tx_band::INVALID_BAND;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_160_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_160_MIN_FREQ) {
band = tx_band::LB_80;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_225_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_225_MIN_FREQ) {
band = tx_band::LB_160;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_400_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_400_MIN_FREQ) {
band = tx_band::LB_225;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_575_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_575_MIN_FREQ) {
band = tx_band::LB_400;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_1000_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_1000_MIN_FREQ) {
band = tx_band::LB_575;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_1700_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_1700_MIN_FREQ) {
band = tx_band::LB_1000;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_LB_2750_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_LB_2750_MIN_FREQ) {
band = tx_band::LB_1700;
- } else if (fp_compare_epsilon<double>(freq) < E3XX_TX_HB_MIN_FREQ) {
+ } else if (freq_compare_epsilon(freq) < E3XX_TX_HB_MIN_FREQ) {
band = tx_band::LB_2750;
- } else if (fp_compare_epsilon<double>(freq) <= AD9361_TX_MAX_FREQ) {
+ } else if (freq_compare_epsilon(freq) <= AD9361_TX_MAX_FREQ) {
band = tx_band::HB;
} else {
band = tx_band::INVALID_BAND;