[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10724 - in gnuradio/branches/developers/jcorgan/gpio2
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r10724 - in gnuradio/branches/developers/jcorgan/gpio2/usrp2/host: apps include/usrp2 lib |
Date: |
Tue, 31 Mar 2009 15:23:14 -0600 (MDT) |
Author: jcorgan
Date: 2009-03-31 15:23:14 -0600 (Tue, 31 Mar 2009)
New Revision: 10724
Added:
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/gpio.cc
Modified:
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/Makefile.am
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
Log:
Adds libusrp2 skeleton functions for GPIO access.
Property changes on: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
.libs
.deps
test_eth
test_usrp2
gen_const
find_usrps
cerr
*.sh
tx_samples
rx_streaming_samples
u2_burn_mac_addr
usrp2_burn_mac_addr
test_mimo_tx
+ Makefile
Makefile.in
.libs
.deps
test_eth
test_usrp2
gen_const
find_usrps
cerr
*.sh
tx_samples
rx_streaming_samples
u2_burn_mac_addr
usrp2_burn_mac_addr
test_mimo_tx
gpio
Modified: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/Makefile.am
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/Makefile.am
2009-03-31 18:35:04 UTC (rev 10723)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/Makefile.am
2009-03-31 21:23:14 UTC (rev 10724)
@@ -36,7 +36,8 @@
gen_const \
rx_streaming_samples \
tx_samples \
- test_mimo_tx
+ test_mimo_tx \
+ gpio
find_usrps_SOURCES = find_usrps.cc
usrp2_burn_mac_addr_SOURCES = usrp2_burn_mac_addr.cc
Added: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/gpio.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/gpio.cc
(rev 0)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/apps/gpio.cc
2009-03-31 21:23:14 UTC (rev 10724)
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <usrp2/usrp2.h>
+
+int
+main(int argc, char **argv)
+{
+ usrp2::usrp2::sptr u2 = usrp2::usrp2::make("eth0");
+
+ // Set io_tx[15] as FPGA output
+ u2->set_gpio_ddr(usrp2::GPIO_TX_BANK, 0x8000, 0x8000);
+
+ // Set io_tx[15] under host sofware control
+ u2->set_gpio_src(usrp2::GPIO_TX_BANK, "s...............");
+
+ // Write pins
+ uint16_t v = 0x8000;
+ u2->write_gpio(usrp2::GPIO_TX_BANK, v, 0x8000);
+
+ // Read back
+ v = 0;
+ u2->read_gpio(usrp2::GPIO_TX_BANK, &v);
+
+ printf("TX GPIO read: %04X\n", v);
+
+ return 0;
+}
Modified:
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
2009-03-31 18:35:04 UTC (rev 10723)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/include/usrp2/usrp2.h
2009-03-31 21:23:14 UTC (rev 10724)
@@ -63,6 +63,10 @@
props_vector_t find(const std::string &ifc, const std::string &mac_addr="");
class tune_result;
+
+ // FIXME: get from firmware include
+ static const int GPIO_TX_BANK = 0;
+ static const int GPIO_RX_BANK = 1;
class usrp2 : boost::noncopyable
{
@@ -414,6 +418,65 @@
*/
bool poke32(uint32_t addr, const std::vector<uint32_t> &data);
+ /*!
+ * Set daughterboard GPIO data direction register.
+ *
+ * \param bank GPIO_TX_BANK or GPIO_RX_BANK
+ * \param value 16-bits, 0=FPGA input, 1=FPGA output
+ * \param mask 16-bits, 0=ignore, 1=set
+ *
+ * \returns true iff successful
+ *
+ * WARNING: Improper usage of this function may result in damage to the
USRP2
+ *
+ */
+ bool set_gpio_ddr(int bank, uint16_t value, uint16_t mask);
+
+ /*!
+ * Set daughterboard GPIO output selection register. For those GPIO pins
that
+ * are configured as outputs in the DDR, this settings configures the
source
+ * of the pin value.
+ *
+ * \param bank GPIO_TX_BANK or GPIO_RX_BANK
+ * \param codes Exactly 16 character MSB->LSB string. For each
position:
+ * '.' = ignore this bit, i.e., leave current value
+ * 'a' = Output ATR value
+ * 's' = Output host software controlled value
+ * '0' = Output FPGA debug bus 0 value
+ * '1' = Output FPGA debug bus 1 value
+ *
+ * \returns true iff successful
+ *
+ * WARNING: Improper usage of this function may result in damage to the
USRP2
+ *
+ */
+ bool set_gpio_src(int bank, std::string src);
+
+ /*!
+ * Set daughterboard GPIO pin values.
+ *
+ * \param bank GPIO_TX_BANK or GPIO_RX_BANK
+ * \param value 16 bits, 0=low, 1=high
+ * \param mask 16 bits, 0=ignore, 1=set
+ *
+ * \returns true iff successful
+ *
+ * WARNING: Improper usage of this function may result in damage to the
USRP2
+ *
+ */
+ bool write_gpio(int bank, uint16_t value, uint16_t mask);
+
+ /*!
+ * Read daughterboard GPIO pin values
+ *
+ * \param bank GPIO_TX_BANK or GPIO_RX_BANK
+ * \param value pointer to uint16_t to hold read results
+ *
+ * \returns true iff successful
+ *
+ */
+ bool read_gpio(int bank, uint16_t *value);
+
#if 0 // not yet implemented
/*!
* \brief Write EEPROM on motherboard or any daughterboard.
Modified: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
2009-03-31 18:35:04 UTC (rev 10723)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2.cc
2009-03-31 21:23:14 UTC (rev 10724)
@@ -437,6 +437,26 @@
return d_impl->poke32(addr, data);
}
+ bool usrp2::set_gpio_ddr(int bank, uint16_t value, uint16_t mask)
+ {
+ return d_impl->set_gpio_ddr(bank, value, mask);
+ }
+
+ bool usrp2::set_gpio_src(int bank, std::string src)
+ {
+ return d_impl->set_gpio_src(bank, src);
+ }
+
+ bool usrp2::write_gpio(int bank, uint16_t value, uint16_t mask)
+ {
+ return d_impl->write_gpio(bank, value, mask);
+ }
+
+ bool usrp2::read_gpio(int bank, uint16_t *value)
+ {
+ return d_impl->read_gpio(bank, value);
+ }
+
} // namespace usrp2
Modified:
gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
2009-03-31 18:35:04 UTC (rev 10723)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.cc
2009-03-31 21:23:14 UTC (rev 10724)
@@ -1293,4 +1293,28 @@
return success;
}
+ bool usrp2::impl::set_gpio_ddr(int bank, uint16_t value, uint16_t mask)
+ {
+ fprintf(stderr, "set_gpio_ddr: bank=%i, value=%04X, mask=%04X\n", bank,
value, mask);
+ return true;
+ }
+
+ bool usrp2::impl::set_gpio_src(int bank, std::string src)
+ {
+ fprintf(stderr, "set_gpio_src: bank=%i, src=%s\n", bank, src.c_str());
+ return true;
+ }
+
+ bool usrp2::impl::write_gpio(int bank, uint16_t value, uint16_t mask)
+ {
+ fprintf(stderr, " write_gpio: bank=%i, value=%04X, mask=%04X\n", bank,
value, mask);
+ return true;
+ }
+
+ bool usrp2::impl::read_gpio(int bank, uint16_t *value)
+ {
+ fprintf(stderr, " read_gpio: bank=%i, address@hidden", bank, value);
+ return true;
+ }
+
} // namespace usrp2
Modified: gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
2009-03-31 18:35:04 UTC (rev 10723)
+++ gnuradio/branches/developers/jcorgan/gpio2/usrp2/host/lib/usrp2_impl.h
2009-03-31 21:23:14 UTC (rev 10724)
@@ -133,6 +133,10 @@
bool set_rx_decim(int decimation_factor);
int rx_decim() { return d_rx_decim; }
bool set_rx_scale_iq(int scale_i, int scale_q);
+ bool set_gpio_ddr(int bank, uint16_t value, uint16_t mask);
+ bool set_gpio_src(int bank, std::string src);
+ bool write_gpio(int bank, uint16_t value, uint16_t mask);
+ bool read_gpio(int bank, uint16_t *value);
bool start_rx_streaming(unsigned int channel, unsigned int
items_per_frame);
bool rx_samples(unsigned int channel, rx_sample_handler *handler);
bool stop_rx_streaming(unsigned int channel);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10724 - in gnuradio/branches/developers/jcorgan/gpio2/usrp2/host: apps include/usrp2 lib,
jcorgan <=