diff options
author | Eric Blossom | 2010-12-27 20:07:16 -0800 |
---|---|---|
committer | Eric Blossom | 2010-12-27 20:07:16 -0800 |
commit | 63fce8a97ed3f6bd1e739615246bf8149207d79c (patch) | |
tree | 0d54cbf6cdc6d48faa36d1bdef3f759dd9fe2cc1 | |
parent | f290f9e4f1a9b9ca09ef95269d563cd785b08a61 (diff) | |
download | gnuradio-63fce8a97ed3f6bd1e739615246bf8149207d79c.tar.gz gnuradio-63fce8a97ed3f6bd1e739615246bf8149207d79c.tar.bz2 gnuradio-63fce8a97ed3f6bd1e739615246bf8149207d79c.zip |
Add scheme-ish convenience functions to usrp2.scm.
-rw-r--r-- | gr-usrp2/src/.gitignore | 1 | ||||
-rw-r--r-- | gr-usrp2/src/gnuradio/.gitignore | 2 | ||||
-rw-r--r-- | gr-usrp2/src/gnuradio/usrp2.scm | 79 | ||||
-rw-r--r-- | gr-usrp2/src/usrp2_swig.i | 1 |
4 files changed, 81 insertions, 2 deletions
diff --git a/gr-usrp2/src/.gitignore b/gr-usrp2/src/.gitignore index dd3d18d43..71f825820 100644 --- a/gr-usrp2/src/.gitignore +++ b/gr-usrp2/src/.gitignore @@ -8,7 +8,6 @@ /run_tests /test_gr_usrp2 /*.pyc -/gnuradio /guile /python /usrp2_swig.py diff --git a/gr-usrp2/src/gnuradio/.gitignore b/gr-usrp2/src/gnuradio/.gitignore new file mode 100644 index 000000000..3c1ff87f5 --- /dev/null +++ b/gr-usrp2/src/gnuradio/.gitignore @@ -0,0 +1,2 @@ +usrp2_swig.scm +usrp2_swig-primitive.scm diff --git a/gr-usrp2/src/gnuradio/usrp2.scm b/gr-usrp2/src/gnuradio/usrp2.scm new file mode 100644 index 000000000..7ead5015d --- /dev/null +++ b/gr-usrp2/src/gnuradio/usrp2.scm @@ -0,0 +1,79 @@ +;;; +;;; Copyright 2010 Free Software Foundation, Inc. +;;; +;;; This file is part of GNU Radio +;;; +;;; GNU Radio 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, or (at your option) +;;; any later version. +;;; +;;; GNU Radio 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/>. +;;; + +;;; Module that re-exports the usrp2_swig module and adds convenience functions + +(define-module (gnuradio usrp2) + #:use-module (oop goops) + #:use-module (gnuradio export-safely) + #:use-module (gnuradio usrp2_swig) + #:duplicates (merge-generics replace check)) + +(re-export-all '(gnuradio usrp2_swig)) + +;; Utilities (guaranteed not to leak the allocated object) +(define (call-with-long-ptr fn) + (let ((ptr #f)) + (dynamic-wind + (lambda () (set! ptr (gr:make-long-ptr))) + (lambda () (and (fn ptr) (gr:deref-long-ptr ptr))) + (lambda () (gr:free-long-ptr ptr))))) + +(define (call-with-int-ptr fn) + (let ((ptr #f)) + (dynamic-wind + (lambda () (set! ptr (gr:make-int-ptr))) + (lambda () (and (fn ptr) (gr:deref-int-ptr ptr))) + (lambda () (gr:free-int-ptr ptr))))) + +(define (call-with-uint16-ptr fn) + (let ((ptr #f)) + (dynamic-wind + (lambda () (set! ptr (gr:make-uint16-ptr))) + (lambda () (and (fn ptr) (gr:deref-uint16-ptr ptr))) + (lambda () (gr:free-uint16-ptr ptr))))) + + +;;; scheme-ish convenience functions + +(define-method (gr:set-center-freq self freq) + (let ((tr (make <tune-result>))) + (if (gr:-real-set-center-freq self freq tr) + tr + #f))) + +(define-method (gr:fpga-master-clock-freq self) + (call-with-long-ptr (lambda (ptr) (gr:-real-fpga-master-clock-freq self ptr)))) + +(define-method (gr:adc-rate self) + (call-with-long-ptr (lambda (ptr) (gr:-real-adc-rate self ptr)))) + +(define-method (gr:dac-rate self) + (call-with-long-ptr (lambda (ptr) (gr:-real-dac-rate self ptr)))) + +(define-method (gr:daughterboard-id self) + (call-with-int-ptr (lambda (ptr) (gr:-real-daugherboard-id self ptr)))) + +;; (define-method (gr:default-tx-scale-iq self) ...) FIXME + +(define-method (gr:read-gpio self) + (call-with-uint16-ptr (lambda (ptr) (gr:-real-read-gpio self ptr)))) + +;; Export them +(export-safely gr:set-center-freq gr:fpga-master-clock-freq gr:adc-rate gr:dac-rate gr:daughterboard-id gr:read-gpio) diff --git a/gr-usrp2/src/usrp2_swig.i b/gr-usrp2/src/usrp2_swig.i index ef598d7d9..6e8fa1960 100644 --- a/gr-usrp2/src/usrp2_swig.i +++ b/gr-usrp2/src/usrp2_swig.i @@ -348,7 +348,6 @@ usrp2_sink_32fc_sptr.read_gpio = __read_gpio usrp2_sink_16sc_sptr.read_gpio = __read_gpio %} -#warning "usrp2.i needs to be implemented fr guile!" #endif #if SWIGGUILE |