[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9780 - in gnuradio/trunk/usrp2/firmware: apps lib
From: |
matt |
Subject: |
[Commit-gnuradio] r9780 - in gnuradio/trunk/usrp2/firmware: apps lib |
Date: |
Sat, 11 Oct 2008 18:26:16 -0600 (MDT) |
Author: matt
Date: 2008-10-11 18:26:16 -0600 (Sat, 11 Oct 2008)
New Revision: 9780
Modified:
gnuradio/trunk/usrp2/firmware/apps/txrx.c
gnuradio/trunk/usrp2/firmware/lib/clocks.c
gnuradio/trunk/usrp2/firmware/lib/clocks.h
gnuradio/trunk/usrp2/firmware/lib/u2_init.c
Log:
refactored divider setting on rxdb clk, txdb clk, and test clk
Modified: gnuradio/trunk/usrp2/firmware/apps/txrx.c
===================================================================
--- gnuradio/trunk/usrp2/firmware/apps/txrx.c 2008-10-11 23:04:06 UTC (rev
9779)
+++ gnuradio/trunk/usrp2/firmware/apps/txrx.c 2008-10-12 00:26:16 UTC (rev
9780)
@@ -35,8 +35,8 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+#include "clocks.h"
-
#define FW_SETS_SEQNO 1 // define to 0 or 1 (FIXME must be 1 for now)
#if (FW_SETS_SEQNO)
Modified: gnuradio/trunk/usrp2/firmware/lib/clocks.c
===================================================================
--- gnuradio/trunk/usrp2/firmware/lib/clocks.c 2008-10-11 23:04:06 UTC (rev
9779)
+++ gnuradio/trunk/usrp2/firmware/lib/clocks.c 2008-10-12 00:26:16 UTC (rev
9780)
@@ -52,7 +52,7 @@
// Set up other clocks
- clocks_enable_test_clk(false);
+ clocks_enable_test_clk(false, 0);
clocks_enable_tx_dboard(false, 0);
clocks_enable_rx_dboard(false, 0);
@@ -128,54 +128,55 @@
ad9510_write_reg(0x5A, 0x01); // Update Regs
}
-void
-clocks_enable_test_clk(bool enable)
+int inline
+clocks_gen_div(int divisor)
{
- if (enable){
- ad9510_write_reg(0x3C, 0x08); // Turn on output 0 -- Test output
- ad9510_write_reg(0x49, 0x80); // Bypass divider 0
- }
- else {
- ad9510_write_reg(0x3C, 0x02); // Turn off output 0
- }
- ad9510_write_reg(0x5A, 0x01); // Update Regs
+ int L,H;
+ L = (divisor>>1)-1;
+ H = divisor-L-2;
+ return (L<<4)|H;
}
+#define CLOCK_OUT_EN 0x08
+#define CLOCK_OUT_DIS_CMOS 0x01
+#define CLOCK_OUT_DIS_PECL 0x02
+#define CLOCK_DIV_DIS 0x80
+#define CLOCK_DIV_EN 0x00
-void
-clocks_enable_rx_dboard(bool enable, int divisor)
+void
+clocks_enable_XXX_clk(bool enable, int divisor, int reg_en, int reg_div, int
val_off)
{
- if (enable){
- ad9510_write_reg(0x43, 0x08); // enable output 7 (db_rx_clk), CMOS
-
- if (divisor == 0){
- ad9510_write_reg(0x57, 0x80); // Bypass Div #7, 100 MHz clock
+ if(enable) {
+ ad9510_write_reg(reg_en,CLOCK_OUT_EN); // Turn on output, normal levels
+ if(divisor>1) {
+ ad9510_write_reg(reg_div,clocks_gen_div(divisor)); // Set divisor
+ ad9510_write_reg(reg_div+1,CLOCK_DIV_EN); // Enable divider
}
else {
- // FIXME Matt, do something with divisor...
+ ad9510_write_reg(reg_div+1,CLOCK_DIV_DIS); // Disable Divider
}
}
else {
- ad9510_write_reg(0x43, 0x01); // Turn off output 7 (db_rx_clk)
+ ad9510_write_reg(reg_en,val_off); // Power off output (val different for
PECL/CMOS)
+ ad9510_write_reg(reg_div+1,CLOCK_DIV_DIS); // Bypass Divider to power it
down
}
- ad9510_write_reg(0x5A, 0x01); // Update Regs
+ ad9510_write_reg(0x5A, 0x01); // Update Regs
}
+void
+clocks_enable_test_clk(bool enable, int divisor)
+{
+ clocks_enable_XXX_clk(enable,divisor,0x3C,0x48,CLOCK_OUT_DIS_PECL);
+}
void
+clocks_enable_rx_dboard(bool enable, int divisor)
+{
+ clocks_enable_XXX_clk(enable,divisor,0x43,0x56,CLOCK_OUT_DIS_CMOS);
+}
+
+void
clocks_enable_tx_dboard(bool enable, int divisor)
{
- if (enable){
- ad9510_write_reg(0x42, 0x08); // enable output 6 (db_tx_clk), CMOS
- if (divisor == 0) {
- ad9510_write_reg(0x55, 0x80); // Bypass Div #6, 100 MHz clock
- }
- else {
- // FIXME Matt, do something with divisor
- }
- }
- else {
- ad9510_write_reg(0x42, 0x01); // Turn off output 6 (db_tx_clk)
- }
- ad9510_write_reg(0x5A, 0x01); // Update Regs
+ clocks_enable_XXX_clk(enable,divisor,0x42,0x54,CLOCK_OUT_DIS_CMOS);
}
Modified: gnuradio/trunk/usrp2/firmware/lib/clocks.h
===================================================================
--- gnuradio/trunk/usrp2/firmware/lib/clocks.h 2008-10-11 23:04:06 UTC (rev
9779)
+++ gnuradio/trunk/usrp2/firmware/lib/clocks.h 2008-10-12 00:26:16 UTC (rev
9780)
@@ -46,7 +46,7 @@
/*!
* \brief Enable or disable test clock (extra clock signal)
*/
-void clocks_enable_test_clk(bool enable);
+void clocks_enable_test_clk(bool enable, int divisor);
/*!
* \brief Enable or disable clock to Rx daughterboard
Modified: gnuradio/trunk/usrp2/firmware/lib/u2_init.c
===================================================================
--- gnuradio/trunk/usrp2/firmware/lib/u2_init.c 2008-10-11 23:04:06 UTC (rev
9779)
+++ gnuradio/trunk/usrp2/firmware/lib/u2_init.c 2008-10-12 00:26:16 UTC (rev
9780)
@@ -66,7 +66,7 @@
// set up the default clocks
clocks_init();
- // clocks_enable_test_clk(true);
+ // clocks_enable_test_clk(true,1);
// Enable ADCs
output_regs->adc_ctrl = ADC_CTRL_ON;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9780 - in gnuradio/trunk/usrp2/firmware: apps lib,
matt <=