commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7456 - in usrp2/trunk/firmware: apps lib


From: eb
Subject: [Commit-gnuradio] r7456 - in usrp2/trunk/firmware: apps lib
Date: Wed, 16 Jan 2008 21:09:50 -0700 (MST)

Author: eb
Date: 2008-01-16 21:09:50 -0700 (Wed, 16 Jan 2008)
New Revision: 7456

Added:
   usrp2/trunk/firmware/apps/ramp_lsdac.c
   usrp2/trunk/firmware/lib/lsdac.c
   usrp2/trunk/firmware/lib/lsdac.h
Modified:
   usrp2/trunk/firmware/apps/
   usrp2/trunk/firmware/apps/Makefile.am
   usrp2/trunk/firmware/lib/Makefile.am
   usrp2/trunk/firmware/lib/u2_init.c
Log:
new: code to control and test low speed dacs


Property changes on: usrp2/trunk/firmware/apps
___________________________________________________________________
Name: svn:ignore
   - *-stamp
*.a
*.bin
*.dump
*.log
*.rom
*.map
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
blink_leds
blink_leds2
build
compile
config.h
config.h.in
config.log
config.status
configure
depcomp
eth_test
gen_eth_packets
ibs_rx_test
ibs_tx_test
install-sh
libtool
ltmain.sh
missing
py-compile
rcv_eth_packets
run_tests.sh
stamp-h1
test1
test_phy_comm
timer_test
buf_ram_test
buf_ram_zero
hello
test_printf
test_spi
test_i2c
gen_pause_frames
test_serdes
rx_only
tx_only
tx_standalone
tx_drop
tx_drop2
tx_drop_rate_limited

   + *-stamp
*.a
*.bin
*.dump
*.log
*.rom
*.map
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
blink_leds
blink_leds2
build
compile
config.h
config.h.in
config.log
config.status
configure
depcomp
eth_test
gen_eth_packets
ibs_rx_test
ibs_tx_test
install-sh
libtool
ltmain.sh
missing
py-compile
rcv_eth_packets
run_tests.sh
stamp-h1
test1
test_phy_comm
timer_test
buf_ram_test
buf_ram_zero
hello
test_printf
test_spi
test_i2c
gen_pause_frames
test_serdes
rx_only
tx_only
tx_standalone
tx_drop
tx_drop2
tx_drop_rate_limited
ramp_lsdac


Modified: usrp2/trunk/firmware/apps/Makefile.am
===================================================================
--- usrp2/trunk/firmware/apps/Makefile.am       2008-01-16 20:38:54 UTC (rev 
7455)
+++ usrp2/trunk/firmware/apps/Makefile.am       2008-01-17 04:09:50 UTC (rev 
7456)
@@ -27,6 +27,7 @@
        hello \
        ibs_rx_test \
        ibs_tx_test \
+       ramp_lsdac \
        rcv_eth_packets \
        rx_only \
        test1 \

Added: usrp2/trunk/firmware/apps/ramp_lsdac.c
===================================================================
--- usrp2/trunk/firmware/apps/ramp_lsdac.c                              (rev 0)
+++ usrp2/trunk/firmware/apps/ramp_lsdac.c      2008-01-17 04:09:50 UTC (rev 
7456)
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <lsdac.h>
+#include <u2_init.h>
+#include <nonstdio.h>
+#include <hal_io.h>
+
+int
+main(void)
+{
+  u2_init();
+
+  puts("\ntest_ldac");
+
+  unsigned int up_counter = 0;
+  unsigned int dn_counter = 0;
+
+  while(1){
+    unsigned int v;
+    v = up_counter << 4;
+    lsdac_write_rx(0, v << 0);
+    lsdac_write_rx(1, v << 1);
+    lsdac_write_rx(2, v << 2);
+    lsdac_write_rx(3, v << 3);
+
+    v = dn_counter << 4;
+    lsdac_write_tx(0, v << 0);
+    lsdac_write_tx(1, v << 1);
+    lsdac_write_tx(2, v << 2);
+    lsdac_write_tx(3, v << 3);
+    up_counter++;
+    dn_counter--;
+  }
+}


Property changes on: usrp2/trunk/firmware/apps/ramp_lsdac.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: usrp2/trunk/firmware/lib/Makefile.am
===================================================================
--- usrp2/trunk/firmware/lib/Makefile.am        2008-01-16 20:38:54 UTC (rev 
7455)
+++ usrp2/trunk/firmware/lib/Makefile.am        2008-01-17 04:09:50 UTC (rev 
7456)
@@ -30,6 +30,7 @@
        hal_io.c \
        hal_uart.c \
        i2c.c \
+       lsdac.c \
        mdelay.c \
        memcpy_wa.c \
        nonstdio.c \

Added: usrp2/trunk/firmware/lib/lsdac.c
===================================================================
--- usrp2/trunk/firmware/lib/lsdac.c                            (rev 0)
+++ usrp2/trunk/firmware/lib/lsdac.c    2008-01-17 04:09:50 UTC (rev 7456)
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "lsdac.h"
+#include "spi.h"
+#include "memory_map.h"
+
+// AD5624, AD5623
+
+#define CMD(x)           ((x) << 19)
+#define CMD_WR_INPUT_N      CMD(0)   // write input N
+#define        CMD_UP_DAC_N         CMD(1)   // update DAC N from input reg
+#define CMD_WR_INPUT_N_LDAC  CMD(2)   // write input N, update all
+#define        CMD_WR_UP_DAC_N      CMD(3)   // write and update N
+#define CMD_WR_PWR_CONFIG    CMD(4)   // write power up/down config reg
+#define        CMD_SW_RESET         CMD(5)   // force s/w reset
+#define        CMD_WR_LDAC_CFG      CMD(6)   // write LDAC config reg
+#define        CMD_WR_INT_REF_CFG   CMD(7)   // write internal ref cfg reg 
(AD5623R only)
+
+inline static void
+_write_rx(uint32_t v)
+{
+  spi_transact(SPI_TXONLY, SPI_SS_RX_DAC, v, 24, 1);
+}
+
+inline static void
+_write_tx(uint32_t v)
+{
+  spi_transact(SPI_TXONLY, SPI_SS_TX_DAC, v, 24, 1);
+}
+
+void 
+lsdac_init(void)
+{
+  _write_tx(CMD_SW_RESET | 0x1);               // power-on reset
+  _write_rx(CMD_SW_RESET | 0x1);               // power-on reset
+}
+
+void
+lsdac_write_rx(int which_dac, int value)
+{
+  _write_rx(CMD_WR_UP_DAC_N | ((which_dac & 0x7) << 16) | (value & 0xffff));
+}
+
+void
+lsdac_write_tx(int which_dac, int value)
+{
+  _write_tx(CMD_WR_UP_DAC_N | ((which_dac & 0x7) << 16) | (value & 0xffff));
+}


Property changes on: usrp2/trunk/firmware/lib/lsdac.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: usrp2/trunk/firmware/lib/lsdac.h
===================================================================
--- usrp2/trunk/firmware/lib/lsdac.h                            (rev 0)
+++ usrp2/trunk/firmware/lib/lsdac.h    2008-01-17 04:09:50 UTC (rev 7456)
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef INCLUDED_LSDAC_H
+#define INCLUDED_LSDAC_H
+
+#include "memory_map.h"
+
+/*!
+ * \brief One time call to initialize low-speed DACs.
+ */
+void lsdac_init(void);
+
+/*!
+ * \brief Write one of the low-speed Rx daughterboard DACs.
+ * \param which_dac in [0, 3]
+ * \param unsigned 16-bit value (really 12-bits, low 4 bits ignored)
+ *
+ * value maps linearly to output voltage from 0 to 3.3V
+ */
+void lsdac_write_rx(int which_dac, int value);
+
+/*!
+ * \brief Write one of the low-speed Tx daughterboard DACs.
+ * \param which_dac in [0, 3]
+ * \param unsigned 16-bit value (really 12-bits, low 4 bits ignored)
+ *
+ * value maps linearly to output voltage from 0 to 3.3V
+ */
+void lsdac_write_tx(int which_dac, int value);
+
+
+#endif /* INCLUDED_LSDAC_H */


Property changes on: usrp2/trunk/firmware/lib/lsdac.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: usrp2/trunk/firmware/lib/u2_init.c
===================================================================
--- usrp2/trunk/firmware/lib/u2_init.c  2008-01-16 20:38:54 UTC (rev 7455)
+++ usrp2/trunk/firmware/lib/u2_init.c  2008-01-17 04:09:50 UTC (rev 7456)
@@ -20,6 +20,7 @@
 #include "spi.h"
 #include "pic.h"
 #include "hal_io.h"
+#include "lsdac.h"
 #include "buffer_pool.h"
 #include "hal_uart.h"
 #include "i2c.h"
@@ -157,6 +158,7 @@
   pic_init();  // progammable interrupt controller
   bp_init();   // buffer pool
   i2c_init();
+  lsdac_init();            // low speed dacs
 
   hal_enable_ints();
 





reply via email to

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