diff options
author | jcorgan | 2009-02-04 23:06:02 +0000 |
---|---|---|
committer | jcorgan | 2009-02-04 23:06:02 +0000 |
commit | 9b388ac1184c71449c49fb44551c5c38f8098d8e (patch) | |
tree | 619f89d81e2030a831063415c29d78c739e47c1c /usrp2/firmware/lib | |
parent | 68282b6ffed904bb55700314a600fe5d731dd0ea (diff) | |
download | gnuradio-9b388ac1184c71449c49fb44551c5c38f8098d8e.tar.gz gnuradio-9b388ac1184c71449c49fb44551c5c38f8098d8e.tar.bz2 gnuradio-9b388ac1184c71449c49fb44551c5c38f8098d8e.zip |
Merged r10383:10390 from jcorgan/u2-wip into trunk.
* Implements daughterboard independent LO offset tuning
* Removes RFX specific LO offset code
* Adds 'set_lo_offset' to libusrp2 and Python API
* Adds --lo-offset to usrp2_fft.py and usrp2_rx_cfile.py
* Ensures daughterboards are reset to default values at
startup.
Trunk passes distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10392 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp2/firmware/lib')
-rw-r--r-- | usrp2/firmware/lib/db.h | 12 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_base.h | 5 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_basic.c | 10 | ||||
-rw-r--r--[-rwxr-xr-x] | usrp2/firmware/lib/db_dbsrx.c | 2 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_init.c | 14 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_rfx.c | 55 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_tvrx.c | 8 | ||||
-rw-r--r-- | usrp2/firmware/lib/db_xcvr2450.c | 2 |
8 files changed, 59 insertions, 49 deletions
diff --git a/usrp2/firmware/lib/db.h b/usrp2/firmware/lib/db.h index 5828fb00d..cec960267 100644 --- a/usrp2/firmware/lib/db.h +++ b/usrp2/firmware/lib/db.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,16 @@ void db_init(void); /*! + * \brief Set daughterboard LO offset frequency. + * + * \param[in] db is the daughterboard instance + * \param[in] offset is the amount to add to tuning requests + * \param[out] success or failure + */ +bool +db_set_lo_offset(struct db_base *db, u2_fxpt_freq_t offset); + +/*! * \brief Two stage tuning. Given target_freq, tune LO and DDC/DUC * * \param[in] db is the daughterboard instance diff --git a/usrp2/firmware/lib/db_base.h b/usrp2/firmware/lib/db_base.h index 9b5ce051f..2ccfbf509 100644 --- a/usrp2/firmware/lib/db_base.h +++ b/usrp2/firmware/lib/db_base.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,8 @@ struct db_base { u2_fxpt_gain_t gain_max; //< max gain that can be set (dB) u2_fxpt_gain_t gain_step_size; //< (dB) - // u2_fxpt_freq_t lo_offset; + u2_fxpt_freq_t default_lo_offset; //< offset to add to tune frequency, reset value + u2_fxpt_freq_t current_lo_offset; //< current value of lo_offset /* * Auto T/R control values diff --git a/usrp2/firmware/lib/db_basic.c b/usrp2/firmware/lib/db_basic.c index 0f1ad6504..2bd4ebfbe 100644 --- a/usrp2/firmware/lib/db_basic.c +++ b/usrp2/firmware/lib/db_basic.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,7 +42,7 @@ struct db_basic db_basic_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.atr_mask = 0, .base.atr_txval = 0, .base.atr_rxval = 0, @@ -68,7 +68,7 @@ struct db_basic db_basic_rx = { .base.is_quadrature = false, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.atr_mask = 0, .base.atr_txval = 0, .base.atr_rxval = 0, @@ -94,7 +94,7 @@ struct db_basic db_lf_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.atr_mask = 0, .base.atr_txval = 0, .base.atr_rxval = 0, @@ -120,7 +120,7 @@ struct db_basic db_lf_rx = { .base.is_quadrature = false, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.atr_mask = 0, .base.atr_txval = 0, .base.atr_rxval = 0, diff --git a/usrp2/firmware/lib/db_dbsrx.c b/usrp2/firmware/lib/db_dbsrx.c index 31b02722b..6e261cc3a 100755..100644 --- a/usrp2/firmware/lib/db_dbsrx.c +++ b/usrp2/firmware/lib/db_dbsrx.c @@ -80,7 +80,7 @@ struct db_dbsrx db_dbsrx = { .base.is_quadrature = true, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = db_dbsrx_init, .base.set_freq = db_dbsrx_set_freq, .base.set_gain = db_dbsrx_set_gain, diff --git a/usrp2/firmware/lib/db_init.c b/usrp2/firmware/lib/db_init.c index 121bfbd9f..0aef75e57 100644 --- a/usrp2/firmware/lib/db_init.c +++ b/usrp2/firmware/lib/db_init.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -270,6 +270,7 @@ db_init(void) //m = determine_tx_mux_value(tx_dboard); //dsp_tx_regs->tx_mux = m; //printf("tx_mux = 0x%x\n", m); + tx_dboard->current_lo_offset = tx_dboard->default_lo_offset; rx_dboard = lookup_dboard(I2C_ADDR_RX_A, &db_basic_rx, "Rx"); //printf("db_init: rx dbid = 0x%x\n", rx_dboard->dbid); @@ -278,6 +279,7 @@ db_init(void) m = determine_rx_mux_value(rx_dboard); dsp_rx_regs->rx_mux = m; //printf("rx_mux = 0x%x\n", m); + rx_dboard->current_lo_offset = rx_dboard->default_lo_offset; } /*! @@ -330,6 +332,12 @@ calc_dxc_freq(u2_fxpt_freq_t target_freq, u2_fxpt_freq_t baseband_freq, } } +bool +db_set_lo_offset(struct db_base *db, u2_fxpt_freq_t offset) +{ + db->current_lo_offset = offset; + return true; +} bool db_tune(struct db_base *db, u2_fxpt_freq_t target_freq, struct tune_result *result) @@ -339,8 +347,8 @@ db_tune(struct db_base *db, u2_fxpt_freq_t target_freq, struct tune_result *resu u2_fxpt_freq_t dxc_freq; u2_fxpt_freq_t actual_dxc_freq; - // Ask the d'board to tune as closely as it can to target_freq - bool ok = db->set_freq(db, target_freq, &result->baseband_freq); + // Ask the d'board to tune as closely as it can to target_freq+lo_offset + bool ok = db->set_freq(db, target_freq+db->current_lo_offset, &result->baseband_freq); // Calculate the DDC setting that will downconvert the baseband from the // daughterboard to our target frequency. diff --git a/usrp2/firmware/lib/db_rfx.c b/usrp2/firmware/lib/db_rfx.c index 0d5c89a81..3efb9f664 100644 --- a/usrp2/firmware/lib/db_rfx.c +++ b/usrp2/firmware/lib/db_rfx.c @@ -1,5 +1,5 @@ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,7 +73,6 @@ struct db_rfx_common { unsigned char CP2; int freq_mult; int spi_mask; - u2_fxpt_freq_t freq_offset; }; struct db_rfx_dummy { @@ -149,7 +148,7 @@ struct db_rfx_400_rx db_rfx_400_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = rfx_init_rx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_rx, @@ -163,8 +162,7 @@ struct db_rfx_400_rx db_rfx_400_rx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_RX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(0) + .common.freq_mult = 2 }; @@ -181,7 +179,7 @@ struct db_rfx_400_tx db_rfx_400_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), .base.init = rfx_init_tx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_tx, @@ -195,8 +193,7 @@ struct db_rfx_400_tx db_rfx_400_tx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_TX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6) + .common.freq_mult = 2 }; struct db_rfx_900_rx db_rfx_900_rx = { @@ -212,7 +209,7 @@ struct db_rfx_900_rx db_rfx_900_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = rfx_init_rx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_rx, @@ -226,8 +223,7 @@ struct db_rfx_900_rx db_rfx_900_rx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_RX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(0) + .common.freq_mult = 2 }; @@ -244,7 +240,7 @@ struct db_rfx_900_tx db_rfx_900_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), .base.init = rfx_init_tx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_tx, @@ -258,8 +254,7 @@ struct db_rfx_900_tx db_rfx_900_tx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_TX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6) + .common.freq_mult = 2 }; struct db_rfx_1200_rx db_rfx_1200_rx = { @@ -275,7 +270,7 @@ struct db_rfx_1200_rx db_rfx_1200_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = rfx_init_rx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_rx, @@ -289,8 +284,7 @@ struct db_rfx_1200_rx db_rfx_1200_rx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_RX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(0) + .common.freq_mult = 2 }; @@ -307,7 +301,7 @@ struct db_rfx_1200_tx db_rfx_1200_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), .base.init = rfx_init_tx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_tx, @@ -321,8 +315,7 @@ struct db_rfx_1200_tx db_rfx_1200_tx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_TX_DB, - .common.freq_mult = 2, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6) + .common.freq_mult = 2 }; struct db_rfx_1800_rx db_rfx_1800_rx = { @@ -338,7 +331,7 @@ struct db_rfx_1800_rx db_rfx_1800_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = rfx_init_rx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_rx, @@ -352,8 +345,7 @@ struct db_rfx_1800_rx db_rfx_1800_rx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_RX_DB, - .common.freq_mult = 1, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(0) + .common.freq_mult = 1 }; @@ -370,7 +362,7 @@ struct db_rfx_1800_tx db_rfx_1800_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), .base.init = rfx_init_tx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_tx, @@ -384,8 +376,7 @@ struct db_rfx_1800_tx db_rfx_1800_tx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_TX_DB, - .common.freq_mult = 1, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6) + .common.freq_mult = 1 }; @@ -402,7 +393,7 @@ struct db_rfx_2400_rx db_rfx_2400_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = rfx_init_rx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_rx, @@ -416,8 +407,7 @@ struct db_rfx_2400_rx db_rfx_2400_rx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_RX_DB, - .common.freq_mult = 1, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(0) + .common.freq_mult = 1 }; @@ -434,7 +424,7 @@ struct db_rfx_2400_tx db_rfx_2400_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), .base.init = rfx_init_tx, .base.set_freq = rfx_set_freq, .base.set_gain = rfx_set_gain_tx, @@ -448,8 +438,7 @@ struct db_rfx_2400_tx db_rfx_2400_tx = { .common.CP1 = 7, .common.CP2 = 7, .common.spi_mask = SPI_SS_TX_DB, - .common.freq_mult = 1, - .common.freq_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6) + .common.freq_mult = 1 }; @@ -488,7 +477,7 @@ rfx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc) *dc = 0; struct db_rfx_dummy *db = (struct db_rfx_dummy *) dbb; - u2_fxpt_freq_t desired_n = (U2_DOUBLE_TO_FXPT_FREQ(1.0)*db->common.freq_mult*(freq+db->common.freq_offset))/phdet_freq; + u2_fxpt_freq_t desired_n = (U2_DOUBLE_TO_FXPT_FREQ(1.0)*db->common.freq_mult*freq)/phdet_freq; int N_DIV = u2_fxpt_freq_round_to_int(desired_n); int B = N_DIV/PRESCALER; int A = N_DIV - PRESCALER*B; diff --git a/usrp2/firmware/lib/db_tvrx.c b/usrp2/firmware/lib/db_tvrx.c index 9e600bf88..435fe7dad 100644 --- a/usrp2/firmware/lib/db_tvrx.c +++ b/usrp2/firmware/lib/db_tvrx.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,7 +88,7 @@ struct db_tvrx1 db_tvrx1 = { .base.is_quadrature = false, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = tvrx_init, .base.set_freq = tvrx_set_freq, .base.set_gain = tvrx_set_gain, @@ -115,7 +115,7 @@ struct db_tvrx2 db_tvrx2 = { .base.is_quadrature = false, .base.i_and_q_swapped = false, .base.spectrum_inverted = true, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = tvrx_init, .base.set_freq = tvrx_set_freq, .base.set_gain = tvrx_set_gain, @@ -142,7 +142,7 @@ struct db_tvrx3 db_tvrx3 = { .base.is_quadrature = false, .base.i_and_q_swapped = false, .base.spectrum_inverted = true, - //.base.lo_offset = U2_DOUBLE_TO_FXPT_FREQ(4e6), + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = tvrx_init, .base.set_freq = tvrx_set_freq, .base.set_gain = tvrx_set_gain, diff --git a/usrp2/firmware/lib/db_xcvr2450.c b/usrp2/firmware/lib/db_xcvr2450.c index 6c165bc96..8132d69a7 100644 --- a/usrp2/firmware/lib/db_xcvr2450.c +++ b/usrp2/firmware/lib/db_xcvr2450.c @@ -147,6 +147,7 @@ struct db_xcvr2450_rx db_xcvr2450_rx = { .base.is_quadrature = true, .base.i_and_q_swapped = false, .base.spectrum_inverted = false, + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = xcvr2450_init, .base.set_freq = xcvr2450_set_freq, .base.set_gain = xcvr2450_set_gain_rx, @@ -169,6 +170,7 @@ struct db_xcvr2450_tx db_xcvr2450_tx = { .base.is_quadrature = true, .base.i_and_q_swapped = true, .base.spectrum_inverted = false, + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = xcvr2450_init, .base.set_freq = xcvr2450_set_freq, .base.set_gain = xcvr2450_set_gain_tx, |