Merge branch 'pfbclk'
authorTom Rondeau <trondeau@vt.edu>
Sun, 18 Apr 2010 21:55:09 +0000 (17:55 -0400)
committerTom Rondeau <trondeau@vt.edu>
Sun, 18 Apr 2010 21:55:09 +0000 (17:55 -0400)
grc/gui/Param.py
grc/python/Param.py
usrp/firmware/src/common/build_eeprom.py
usrp/host/lib/db_wbxng.cc
usrp2/firmware/lib/adf4350.c
usrp2/firmware/lib/db_wbxng.c
usrp2/host/apps/tx_samples.cc

index b3018dab216a59b43b8539b72abb1a35172585bf..7c00c1b67f04b73cbc109f5ef9882b869d36eb68 100644 (file)
@@ -1,5 +1,5 @@
 """
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -135,10 +135,21 @@ PARAM_LABEL_MARKUP_TMPL="""\
 <span underline="$underline" foreground="$foreground" font_desc="Sans 9">$encode($param.get_name())</span>"""
 
 TIP_MARKUP_TMPL="""\
+########################################
+#def truncate(string)
+       #set $max_len = 100
+       #set $string = str($string)
+       #if len($string) > $max_len
+$('%s...%s'%($string[:$max_len/2], $string[-$max_len/2:]))#slurp
+       #else
+$string#slurp
+       #end if
+#end def
+########################################
 Key: $param.get_key()
 Type: $param.get_type()
 #if $param.is_valid()
-Value: $param.get_evaluated()
+Value: $truncate($param.get_evaluated())
 #elif len($param.get_error_messages()) == 1
 Error: $(param.get_error_messages()[0])
 #else
index e04bc8fcb587589effbc2bcfef2fc61085bfba69..6dd008d1d04b5ce181631f275c5be5bc1d997102 100644 (file)
@@ -1,5 +1,5 @@
 """
-Copyright 2008, 2009 Free Software Foundation, Inc.
+Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -108,7 +108,23 @@ class Param(_Param, _GUIParam):
                Get the repr (nice string format) for this param.
                @return the string representation
                """
-               if not self.is_valid(): return self.get_value()
+               ##################################################
+               # truncate helper method
+               ##################################################
+               def _truncate(string, style=0):
+                       max_len = max(27 - len(self.get_name()), 3)
+                       if len(string) > max_len:
+                               if style < 0: #front truncate
+                                       string = '...' + string[3-max_len:]
+                               elif style == 0: #center truncate
+                                       string = string[:max_len/2 -3] + '...' + string[-max_len/2:]
+                               elif style > 0: #rear truncate
+                                       string = string[:max_len-3] + '...'
+                       return string
+               ##################################################
+               # simple conditions
+               ##################################################
+               if not self.is_valid(): return _truncate(self.get_value())
                if self.get_value() in self.get_option_keys(): return self.get_option(self.get_value()).get_name()
                ##################################################
                # display logic for numbers
@@ -126,7 +142,6 @@ class Param(_Param, _GUIParam):
                # split up formatting by type
                ##################################################
                truncate = 0 #default center truncate
-               max_len = max(27 - len(self.get_name()), 3)
                e = self.get_evaluated()
                t = self.get_type()
                if isinstance(e, bool): return str(e)
@@ -141,16 +156,9 @@ class Param(_Param, _GUIParam):
                        truncate = -1
                else: dt_str = str(e) #other types
                ##################################################
-               # truncate
+               # done
                ##################################################
-               if len(dt_str) > max_len:
-                       if truncate < 0: #front truncate
-                               dt_str = '...' + dt_str[3-max_len:]
-                       elif truncate == 0: #center truncate
-                               dt_str = dt_str[:max_len/2 -3] + '...' + dt_str[-max_len/2:]
-                       elif truncate > 0: #rear truncate
-                               dt_str = dt_str[:max_len-3] + '...'
-               return dt_str
+               return _truncate(dt_str, truncate)
 
        def get_input(self, *args, **kwargs):
                if self.get_type() in ('file_open', 'file_save'): return FileParam(self, *args, **kwargs)
index ed9bb56a4816174b3d0d02f04ed64559a1022b16..d73cbbc4f74d647a80eef358a7bb34e33c41da1e 100755 (executable)
@@ -146,7 +146,7 @@ def build_shell_script (out, ihx_filename, rev, prefix):
 
     out.write ('#!/bin/sh\n')
     out.write ('usrper -x load_firmware ' + prefix + '/share/usrp/rev%d/std.ihx\n' % rev)
-    out.write ('sleep 1\n')
+    out.write ('sleep 2\n')
     
     # print "len(image) =", len(image)
     
@@ -161,7 +161,7 @@ def build_shell_script (out, ihx_filename, rev, prefix):
                    (i2c_addr, rom_addr, ''.join (hex_image[0:l])))
         hex_image = hex_image[l:]
         rom_addr = rom_addr + l
-        out.write ('sleep 1\n')
+        out.write ('sleep 2\n')
 
 if __name__ == '__main__':
     usage = "usage: %prog -p PREFIX -r REV [options] bootfile.ihx"
index b35a9cb35d75222df2412dacd04c47c3e9308dd6..bd836dfe331090724a18c8c9f414ec274dd66032 100644 (file)
@@ -80,7 +80,9 @@ wbxng_base::set_freq(double freq)
     actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
   */
 
-  freq_t int_freq = freq_t(freq);
+  // clamp freq
+  freq_t int_freq = freq_t(std::max(freq_min(), std::min(freq, freq_max())));
+
   bool ok = d_common->_set_freq(int_freq*2);
   double freq_result = (double) d_common->_get_freq()/2.0;
   struct freq_result_t args = {ok, freq_result};
index 0725c93379533e123f0439196fe015b42b8d0b2f..dbab654ea30bdeca9bbfdb141a279776d6788810 100644 (file)
@@ -30,7 +30,7 @@
 #define MIN_VCO_FREQ U2_DOUBLE_TO_FXPT_FREQ(2.2e9)                      /* minimum vco freq */
 #define MAX_VCO_FREQ U2_DOUBLE_TO_FXPT_FREQ(4.4e9)                      /* minimum vco freq */
 #define MAX_FREQ MAX_VCO_FREQ                                           /* upper bound freq (rf div = 1) */
-#define MIN_FREQ DIV_ROUND(MIN_VCO_FREQ, MAX_RF_DIV)                    /* calculated lower bound freq */
+#define MIN_FREQ U2_DOUBLE_TO_FXPT_FREQ(68.75e6)                        /* lower bound freq (rf div = 16) */
 
 u2_fxpt_freq_t adf4350_get_max_freq(void){
        return MAX_FREQ;
@@ -170,7 +170,7 @@ bool adf4350_set_freq(u2_fxpt_freq_t freq, struct db_base *dbb){
        adf4350_load_register(2, dbb);
        adf4350_load_register(4, dbb);
        adf4350_load_register(0, dbb); /* register 0 must be last */
-       return true;
+       return adf4350_get_locked(dbb);
 }
 
 u2_fxpt_freq_t adf4350_get_freq(struct db_base *dbb){
index 115ac8a246b0cd79dbb4b2bd93c68d3c7e53bb69..954633da245b725427f9957b164ae3944cb4bf54 100644 (file)
@@ -29,6 +29,9 @@
 #include <stdio.h>
 #include <stdint.h>
 
+#define min(X,Y) ((X) < (Y) ? (X) : (Y))
+#define max(X,Y) ((X) > (Y) ? (X) : (Y))
+
 bool wbxng_init_rx(struct db_base *dbb);
 bool wbxng_init_tx(struct db_base *dbb);
 bool wbxng_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc);
@@ -45,7 +48,7 @@ struct db_wbxng_rx db_wbxng_rx = {
   .base.is_tx = false,
   .base.output_enables = RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5|PLL_CE|PLL_PDBRF|ATTN_MASK,
   .base.used_pins = 0xFFFF,
-  .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(67.5e6),
+  .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(68.75e6),
   .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2200e6),
   .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0),
   .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(31.5),
@@ -81,7 +84,7 @@ struct db_wbxng_tx db_wbxng_tx = {
   .base.is_tx = true,
   .base.output_enables = RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5|PLL_CE|PLL_PDBRF,
   .base.used_pins = 0xFFFF,
-  .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(67.5e6),
+  .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(68.75e6),
   .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2200e6),
   .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0),
   .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(25),
@@ -149,8 +152,11 @@ wbxng_init_rx(struct db_base *dbb)
 bool
 wbxng_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc)
 {
-  bool ok = adf4350_set_freq(2*freq,dbb);
-  *dc = adf4350_get_freq(dbb)/2;
+  // clamp freq
+  u2_fxpt_freq_t clamp_freq = max(dbb->freq_min, min(freq, dbb->freq_max));
+  //printf("Requested LO freq = %u", (uint32_t) ((clamp_freq >> U2_FPF_RP)/1000));
+  bool ok = adf4350_set_freq(clamp_freq<<1,dbb);
+  *dc = adf4350_get_freq(dbb)>>1;
 
   return ok;
 }
index 5c3728fb1518d2859dc1b56fc6bb089c5e33f9d1..3e41bbf8d0ad454627f225ecd83fb39f4b8c3e19 100644 (file)
@@ -150,6 +150,10 @@ main(int argc, char **argv)
       interp = strtol(optarg, 0, 0);
       break;
 
+    case 'g':
+      gain = strtod(optarg, 0);
+      break;
+
     case 'S':
       if (!strtod_si(optarg, &tmp)){
        std::cerr << "invalid number: " << optarg << std::endl;