commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8325 - usrp2/trunk/firmware/lib


From: matt
Subject: [Commit-gnuradio] r8325 - usrp2/trunk/firmware/lib
Date: Thu, 8 May 2008 12:39:45 -0600 (MDT)

Author: matt
Date: 2008-05-08 12:39:45 -0600 (Thu, 08 May 2008)
New Revision: 8325

Modified:
   usrp2/trunk/firmware/lib/db_rfx.c
Log:
frequency setting mostly complete


Modified: usrp2/trunk/firmware/lib/db_rfx.c
===================================================================
--- usrp2/trunk/firmware/lib/db_rfx.c   2008-05-08 06:17:55 UTC (rev 8324)
+++ usrp2/trunk/firmware/lib/db_rfx.c   2008-05-08 18:39:45 UTC (rev 8325)
@@ -20,15 +20,46 @@
 #include <memory_map.h>
 #include <db_base.h>
 
+
 bool rfx_init(struct db_base *db);
 bool rfx_set_freq(struct db_base *db, u2_fxpt_freq_t freq);
 bool rfx_set_gain(struct db_base *db, u2_fxpt_gain_t gain);
 bool rfx_set_tx_enable(struct db_base *, bool on);
 
+// Control Latch Defines
+#define P 0  // Prescalar value for setting in regs, must match the next 
line...
+#define PRESCALER 8  // Presacalar value for computations
+#define PD 0  // Power down, 0 = normal operation
+#define PL 0 // PLL power output
+#define MTLD 1 // Mute till lock detect
+#define CPGAIN 0 // Charge pump gain, use setting 1, also in N-reg
+#define CP3S 0 // Charge pump tri-state, 0 = normal operation
+#define PDP 1 // Phase detector polarity
+#define MUXOUT 1 // Digital lock detect, active high
+#define CR 0 // normal operation
+#define PC 1 // core power
+
+// N Latch Defines
+#define DIVSEL 0 // N Counter always operates on full rate
+#define N_RSV 0
+
+// R Latch Defines
+#define R_RSV 0
+#define R_BSC 3
+#define R_TMB 0
+#define R_LDP 1
+#define R_ABP 0
+#define R_DIV 16
+
+const u2_fxpt_freq_t phdet_freq =  U2_DOUBLE_TO_FXPT_FREQ(100e6/R_DIV);
+
 struct db_rfx_common {
-
   // RFX common stuff here (if any)
-
+  unsigned char DIV2;
+  unsigned char CP1;
+  unsigned char CP2;
+  int freq_mult;
+  int spi_mask;
 };
 
 struct db_rfx_dummy {
@@ -60,7 +91,7 @@
  */
 struct db_rfx_400_rx rfx_400_rx = {
   .base.dbid = 0x0004,
-  .base.output_enables = 0x0000,                       // FIXME
+  .base.output_enables = 0x00FB,                       // FIXME
   //.base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(xxx),
   //.base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(xxx),
   //.base.freq_step_size = U2_DOUBLE_TO_FXPT_FREQ(xxx),
@@ -79,12 +110,17 @@
   // .base.atr_rxval =
   // .base.atr_tx_delay =
   // .base.atr_rx_delay =
+  .common.DIV2 = 0,
+  .common.CP1 = 7,
+  .common.CP2 = 7,
+  .common.spi_mask = SPI_SS_RX_DB,
+  .common.freq_mult = 2
 };
 
 
 struct db_rfx_400_tx rfx_400_tx = {
   .base.dbid = 0x0008,
-  .base.output_enables = 0x0000,                       // FIXME
+  .base.output_enables = 0x00FB,                       // FIXME
   //.base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(xxx),
   //.base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(xxx),
   //.base.freq_step_size = U2_DOUBLE_TO_FXPT_FREQ(xxx),
@@ -104,44 +140,40 @@
   // .base.atr_rxval =
   // .base.atr_tx_delay =
   // .base.atr_rx_delay =
+  .common.DIV2 = 1,
+  .common.CP1 = 7,
+  .common.CP2 = 7,
+  .common.spi_mask = SPI_SS_TX_DB,
+  .common.freq_mult = 2
 };
 
 bool
 rfx_init(struct db_base *dbb)
 {
-  struct rfx_dummy *db = (struct rfx_dummy *) dbb;
+  struct db_rfx_dummy *db = (struct db_rfx_dummy *) dbb;
+  return false;
 }
 
 bool
 rfx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq)
 {
-  struct rfx_dummy *db = (struct rfx_dummy *) dbb;
-  int R_DIV = 16;
-  int PRESCALER = 8;
-  u2_fxpt_freq_t phdet_freq =  U2_DOUBLE_TO_FXPT_FREQ(100e6/R_DIV);
-  u2_fxpt_freq_t desired_n = freq/phdet_freq;
+  struct db_rfx_dummy *db = (struct db_rfx_dummy *) dbb;
+  u2_fxpt_freq_t desired_n = 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;
-  int R_RSV = 0;
-  int R_BSC = 3;
-  int R_TMB = 0;
-  int R_LDP = 1;
-  int R_ABP = 0;
-  int DIVSEL, DIV2, CPGAIN, MUXOUT, CP1, CP2, PL, P, PD, CPG, CP3S, PDP, 
N_RSV, MTLD, CR, PC;
 
   if(B<A)
     return false;
 
   int R = 
(R_RSV<<22)|(R_BSC<<20)|(R_TMB<<19)|(R_LDP<<18)|(R_ABP<<16)|(R_DIV<<2)|1;
-  int N = (DIVSEL<<23)|(DIV2<<22)|(CPGAIN<<21)|(B<<8)|(N_RSV<<7)|(A<<2)|2;
-  int C = 
(P<<22)|(PD<<20)|(CP2<<17)|(CP1<<14)|(PL<<12)|(MTLD<<11)|(CPG<<10)|(CP3S<<9)|(PDP<<8)|
+  int N = 
(DIVSEL<<23)|(db->common.DIV2<<22)|(CPGAIN<<21)|(B<<8)|(N_RSV<<7)|(A<<2)|2;
+  int C = 
(P<<22)|(PD<<20)|(db->common.CP2<<17)|(db->common.CP1<<14)|(PL<<12)|(MTLD<<11)|(CPGAIN<<10)|(CP3S<<9)|(PDP<<8)|
     (MUXOUT<<5)|(CR<<4)|(PC<<2)|0;
 
-  spi_transact(SPI_TXONLY,SPI_SS_TX_DB,R,24,SPIF_PUSH_FALL);
-  spi_transact(SPI_TXONLY,SPI_SS_TX_DB,N,24,SPIF_PUSH_FALL);
-  spi_transact(SPI_TXONLY,SPI_SS_TX_DB,C,24,SPIF_PUSH_FALL);
+  spi_transact(SPI_TXONLY,db->common.spi_mask,C,24,SPIF_PUSH_FALL);
+  spi_transact(SPI_TXONLY,db->common.spi_mask,N,24,SPIF_PUSH_FALL);
+  spi_transact(SPI_TXONLY,db->common.spi_mask,R,24,SPIF_PUSH_FALL);
 
   return false;
 }
@@ -150,7 +182,7 @@
 bool
 rfx_set_gain(struct db_base *dbb, u2_fxpt_gain_t gain)
 {
-  struct rfx_dummy *db = (struct rfx_dummy *) dbb;
+  struct db_rfx_dummy *db = (struct db_rfx_dummy *) dbb;
 
   return false;
 }
@@ -159,7 +191,7 @@
 bool
 rfx_set_tx_enable(struct db_base *dbb, bool on)
 {
-  struct rfx_dummy *db = (struct rfx_dummy *) dbb;
+  struct db_rfx_dummy *db = (struct db_rfx_dummy *) dbb;
 
   return false;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]