diff options
author | Trung Tran <trung.tran@ettus.com> | 2017-11-13 08:32:13 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:06 -0800 |
commit | 9ea0d6da9e3756af91c7d1e99ee35e56bf2270d6 (patch) | |
tree | b24c75a58aaf1217aefa9798ddf241b10031db8e /mpm/lib/mykonos/ad937x_device.cpp | |
parent | fa765de7db4ab0933578e986c967d6e8eea60170 (diff) | |
download | uhd-9ea0d6da9e3756af91c7d1e99ee35e56bf2270d6.tar.gz uhd-9ea0d6da9e3756af91c7d1e99ee35e56bf2270d6.tar.bz2 uhd-9ea0d6da9e3756af91c7d1e99ee35e56bf2270d6.zip |
mg: enable init and track calibration API
Currently, AD9371 turned on most of the calibration and hard coding the turning
on process during bringup time.
This change enables users to pass in a mask field for init ARM calibration and
tracking arm calibration at the time creating USRP device reference.
This mask field can be passed through device arguments of:
1/ init_cals : for init ARM calibration masks. This is defined in AD9371 UG-992
table 65. Default to 0x4DFF
2/ tracking_cals : for tracking calibration masks. This is defined in AD9371
UG-992 table 66. Default to 0xC3
Example of pasing in init calibration and tracking calibration mask
usrp_application --args "init_cals=0x4f, tracking_cals=0xC3"
NOTE: UHD currently expect user to input the correct init_cals and
tracking_cals. There's no mechanism to check if init mask and tracking mask are
valid. For example if the init mask field not mask 0x4f, the AD9371 will failed
to setup.
Diffstat (limited to 'mpm/lib/mykonos/ad937x_device.cpp')
-rw-r--r-- | mpm/lib/mykonos/ad937x_device.cpp | 65 |
1 files changed, 10 insertions, 55 deletions
diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp index 2614be600..de3671849 100644 --- a/mpm/lib/mykonos/ad937x_device.cpp +++ b/mpm/lib/mykonos/ad937x_device.cpp @@ -19,7 +19,6 @@ #include "adi/mykonos.h" #include "adi/mykonos_gpio.h" #include "adi/mykonos_debug/mykonos_dbgjesd.h" - #include <boost/format.hpp> #include <functional> @@ -49,50 +48,6 @@ static const uint32_t AD9371_PRODUCT_ID = 0x3; static const size_t ARM_BINARY_SIZE = 98304; static const uint32_t PLL_LOCK_TIMEOUT_MS = 200; -static const uint32_t INIT_CAL_TIMEOUT_MS = 10000; - -// TODO: actually figure out what cals we want to run -// minimum required cals are 0x4F -static const uint32_t INIT_CALS = - TX_BB_FILTER | - ADC_TUNER | - TIA_3DB_CORNER | - DC_OFFSET | - TX_ATTENUATION_DELAY | - RX_GAIN_DELAY | - FLASH_CAL | - PATH_DELAY | - TX_LO_LEAKAGE_INTERNAL | -//// TX_LO_LEAKAGE_EXTERNAL | - TX_QEC_INIT | - LOOPBACK_RX_LO_DELAY | - LOOPBACK_RX_RX_QEC_INIT | - RX_LO_DELAY | - RX_QEC_INIT | -//// DPD_INIT | -//// CLGC_INIT | -//// VSWR_INIT | - 0; - -static const uint32_t TRACKING_CALS = - TRACK_RX1_QEC | - TRACK_RX2_QEC | -// TRACK_ORX1_QEC | -// TRACK_ORX2_QEC | -//// TRACK_TX1_LOL | -//// TRACK_TX2_LOL | - TRACK_TX1_QEC | - TRACK_TX2_QEC | -//// TRACK_TX1_DPD | -//// TRACK_TX2_DPD | -//// TRACK_TX1_CLGC | -//// TRACK_TX2_CLGC | -//// TRACK_TX1_VSWR | -//// TRACK_TX2_VSWR | -//// TRACK_ORX1_QEC_SNLO | -//// TRACK_ORX2_QEC_SNLO | -//// TRACK_SRX_QEC | - 0; /****************************************************** Helper functions @@ -318,8 +273,7 @@ ad937x_device::ad937x_device( { } -void ad937x_device::_initialize_rf() -{ +void ad937x_device::_setup_rf(){ // TODO: add setRfPllLoopFilter here // Set frequencies @@ -345,19 +299,21 @@ void ad937x_device::_initialize_rf() set_gain(uhd::TX_DIRECTION, chain_t::ONE, TX_DEFAULT_GAIN); set_gain(uhd::TX_DIRECTION, chain_t::TWO, TX_DEFAULT_GAIN); - // Run and wait for init cals - CALL_API(MYKONOS_runInitCals(mykonos_config.device, INIT_CALS)); +} + +void ad937x_device::setup_cal(uint32_t init_cals_mask, uint32_t tracking_cals_mask, uint32_t timeout){ + // Run and wait for init cals + CALL_API(MYKONOS_runInitCals(mykonos_config.device, init_cals_mask)); uint8_t errorFlag = 0, errorCode = 0; - CALL_API(MYKONOS_waitInitCals(mykonos_config.device, INIT_CAL_TIMEOUT_MS, &errorFlag, &errorCode)); + CALL_API(MYKONOS_waitInitCals(mykonos_config.device, timeout, &errorFlag, &errorCode)); if ((errorFlag != 0) || (errorCode != 0)) { throw mpm::runtime_error("Init cals failed!"); // TODO: add more debugging information here } - - CALL_API(MYKONOS_enableTrackingCals(mykonos_config.device, TRACKING_CALS)); + CALL_API(MYKONOS_enableTrackingCals(mykonos_config.device, tracking_cals_mask)); // ready for radioOn } @@ -389,9 +345,8 @@ void ad937x_device::finish_initialization() // TODO: check ARM version before or after the load of the ARM // currently binary has no readable version number until after it's loaded - - // TODO: separate initialize rf into its own step - _initialize_rf(); + //Run setup RF + _setup_rf(); } void ad937x_device::start_jesd_tx() |