commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r7469 - in usrp2/trunk/firmware: apps lib
Date: Fri, 18 Jan 2008 17:18:17 -0700 (MST)

Author: eb
Date: 2008-01-18 17:18:16 -0700 (Fri, 18 Jan 2008)
New Revision: 7469

Added:
   usrp2/trunk/firmware/apps/test_lsadc.c
   usrp2/trunk/firmware/lib/lsadc.c
   usrp2/trunk/firmware/lib/lsadc.h
Modified:
   usrp2/trunk/firmware/apps/Makefile.am
   usrp2/trunk/firmware/apps/test_lsdac.c
   usrp2/trunk/firmware/lib/Makefile.am
Log:
Low speed DACs are working OK.  The wiring is swapped on the ADCs
between 0 and 1 on each daughterboard.

Things are wired like this:
{{{

Basic Tx:

  label         reality
  -----         -------
  DAC_D         dac 0
  DAC_A         dac 1
  DAC_B         dac 2
  DAC_C         dac 3

  ADC_A2        adc 1
  ADC_B2        adc 0


Basic Rx:

  label         reality
  -----         -------
  DAC_D         dac 3
  DAC_A         dac 2
  DAC_B         dac 1
  DAC_C         dac 0

  ADC_A1        adc 1
  ADC_B1        adc 0
}}}



Modified: usrp2/trunk/firmware/apps/Makefile.am
===================================================================
--- usrp2/trunk/firmware/apps/Makefile.am       2008-01-18 22:23:20 UTC (rev 
7468)
+++ usrp2/trunk/firmware/apps/Makefile.am       2008-01-19 00:18:16 UTC (rev 
7469)
@@ -32,6 +32,7 @@
        test1 \
        test_i2c \
        test_phy_comm \
+       test_lsadc \
        test_lsdac \
        test_serdes \
        timer_test \

Added: usrp2/trunk/firmware/apps/test_lsadc.c
===================================================================
--- usrp2/trunk/firmware/apps/test_lsadc.c                              (rev 0)
+++ usrp2/trunk/firmware/apps/test_lsadc.c      2008-01-19 00:18:16 UTC (rev 
7469)
@@ -0,0 +1,59 @@
+/* -*- 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 <lsadc.h>
+#include <lsdac.h>
+#include <u2_init.h>
+#include <nonstdio.h>
+#include <hal_io.h>
+
+int
+main(void)
+{
+  u2_init();
+
+  lsadc_init();                        // FIXME move to u2_init
+
+  puts("\ntest_lsadc");
+
+  uint32_t r;
+
+  unsigned int up_counter = 0;
+  
+  while (1){
+    unsigned int v;
+    v = up_counter;
+
+    lsdac_write_rx(0, v << 0);
+    lsdac_write_rx(2, v << 1);
+
+#if 1
+    r = lsadc_read_rx(0);
+    lsdac_write_rx(1, r & 0x0fff);
+    //puthex32_nl(r);
+#endif
+
+#if 1
+    r = lsadc_read_rx(1);
+    lsdac_write_rx(3, r & 0x0fff);
+    //puthex32_nl(r);
+#endif
+
+    up_counter++;
+  }
+}


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

Modified: usrp2/trunk/firmware/apps/test_lsdac.c
===================================================================
--- usrp2/trunk/firmware/apps/test_lsdac.c      2008-01-18 22:23:20 UTC (rev 
7468)
+++ usrp2/trunk/firmware/apps/test_lsdac.c      2008-01-19 00:18:16 UTC (rev 
7469)
@@ -39,11 +39,12 @@
     lsdac_write_rx(2, v << 2);
     lsdac_write_rx(3, v << 3);
 
-    v = dn_counter;
+    v = up_counter;
     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--;
   }

Modified: usrp2/trunk/firmware/lib/Makefile.am
===================================================================
--- usrp2/trunk/firmware/lib/Makefile.am        2008-01-18 22:23:20 UTC (rev 
7468)
+++ usrp2/trunk/firmware/lib/Makefile.am        2008-01-19 00:18:16 UTC (rev 
7469)
@@ -31,6 +31,7 @@
        hal_io.c \
        hal_uart.c \
        i2c.c \
+       lsadc.c \
        lsdac.c \
        mdelay.c \
        memcpy_wa.c \

Added: usrp2/trunk/firmware/lib/lsadc.c
===================================================================
--- usrp2/trunk/firmware/lib/lsadc.c                            (rev 0)
+++ usrp2/trunk/firmware/lib/lsadc.c    2008-01-19 00:18:16 UTC (rev 7469)
@@ -0,0 +1,73 @@
+/* -*- 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 "lsadc.h"
+#include "spi.h"
+#include "memory_map.h"
+
+
+// AD9712 or AD7922   1 MS/s, 10-/12-bit ADCs
+
+//#define SPI_SS_DEBUG SPI_SS_RX_DB
+#define SPI_SS_DEBUG 0
+
+
+void 
+lsadc_init(void)
+{
+  // nop
+}
+
+/* 
+ * The ADC's are pipelined.   That is, you have to tell them
+ * which of the two inputs you want one cycle ahead of time.
+ * We could optimize and keep track of which one we used last
+ * time, but for simplicity we'll always tell it which
+ * one we want.  This takes 2 16-bit xfers, one to set the
+ * input and one to read the one we want.
+ */
+
+int
+_lsadc_read(int which_adc, int slave_select)
+{
+  uint32_t r;
+  int channel = which_adc & 0x1;
+
+  // Set CHN and STY equal to channel number.  We don't want "daisy chain mode"
+  uint16_t cmd = (channel << 13) | (channel << 12);
+
+  spi_transact(SPI_TXONLY, slave_select | SPI_SS_DEBUG,
+              cmd, 16, SPIF_PUSH_RISE | SPIF_LATCH_RISE);
+
+  r = spi_transact(SPI_TXRX, slave_select | SPI_SS_DEBUG,
+                  cmd, 16, SPIF_PUSH_RISE | SPIF_LATCH_RISE);
+
+  return r & 0x0fff;
+}
+
+int
+lsadc_read_rx(int which_adc)
+{
+  return _lsadc_read(which_adc, SPI_SS_RX_ADC);
+}
+
+int
+lsadc_read_tx(int which_adc)
+{
+  return _lsadc_read(which_adc, SPI_SS_TX_ADC);
+}


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

Added: usrp2/trunk/firmware/lib/lsadc.h
===================================================================
--- usrp2/trunk/firmware/lib/lsadc.h                            (rev 0)
+++ usrp2/trunk/firmware/lib/lsadc.h    2008-01-19 00:18:16 UTC (rev 7469)
@@ -0,0 +1,45 @@
+/* -*- 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_LSADC_H
+#define INCLUDED_LSADC_H
+
+#include "memory_map.h"
+
+/*!
+ * \brief One time call to initialize low-speed ADCs.
+ */
+void lsadc_init(void);
+
+/*!
+ * \brief Read one of the low-speed Rx daughterboard ADCs.
+ * \param which_adc in [0, 1]
+ *
+ * \returns 12-bit value in [0,4095]
+ */
+int lsadc_read_rx(int which_adc);
+
+/*!
+ * \brief Read one of the low-speed Tx daughterboard ADCs.
+ * \param which_adc in [0, 1]
+ *
+ * \returns 12-bit value in [0,4095]
+ */
+int lsadc_read_tx(int which_adc);
+
+
+#endif /* INCLUDED_LSADC_H */


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





reply via email to

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