kopia lustrzana https://github.com/Hamlib/Hamlib
new directory structure
rodzic
85541cc257
commit
9bff33896e
11
Makefile.am
11
Makefile.am
|
@ -14,19 +14,16 @@ doc_DATA = ChangeLog COPYING COPYING.LIB LICENSE \
|
|||
|
||||
SUBDIRS = macros include lib \
|
||||
$(BACKEND_LIST) \
|
||||
$(RIG_BACKEND_LIST) \
|
||||
$(ROT_BACKEND_LIST) \
|
||||
$(AMP_BACKEND_LIST) \
|
||||
src \
|
||||
$(BINDINGS) \
|
||||
tests doc
|
||||
|
||||
## Static list of distributed directories. $(BACKEND_LIST) is dynamically
|
||||
## assigned by 'configure' so list rig backends statically.
|
||||
DIST_SUBDIRS = macros include lib src c++ bindings tests doc android scripts\
|
||||
adat alinco aor barrett drake dorji dummy elad flexradio icom icmarine jrc\
|
||||
kachina kenwood kit lowe pcr prm80 racal rft rs skanti tapr tentec\
|
||||
tuner uniden wj yaesu winradio\
|
||||
$(ROT_BACKEND_LIST) $(AMP_BACKEND_LIST)
|
||||
## Static list of distributed directories.
|
||||
DIST_SUBDIRS = macros include lib src c++ bindings tests doc android scripts \
|
||||
$(BACKEND_LIST) $(RIG_BACKEND_LIST) $(ROT_BACKEND_LIST) $(AMP_BACKEND_LIST)
|
||||
|
||||
# Install any third party macros into our tree for distribution
|
||||
ACLOCAL_AMFLAGS = -I macros --install
|
||||
|
|
5
NEWS
5
NEWS
|
@ -6,7 +6,7 @@ Copyright (C) 2000-2018 Stephane Fillod, and others
|
|||
Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net
|
||||
|
||||
Version 4.0
|
||||
2019-??-??
|
||||
2020-??-??
|
||||
* API/ABI changes, advance ABI to 4 0 0.
|
||||
* Add GPIO and GPION options for DCD. Jeroen Vreeken
|
||||
* New backend: ELAD FDM DUO. Giovanni, HB9EIK.
|
||||
|
@ -15,6 +15,9 @@ Version 4.0
|
|||
* New utility: rigctlcom. Mike, W9MDB
|
||||
* New model: FT847UNI for unidirectional early serial numbers. Mike, W9MDB
|
||||
* Remove GNU Texinfo files and build system dependency.
|
||||
* Fix a lot of static code analysis errors and warnings. Mike, W9MDB
|
||||
* Rearrange directory structure to put rigs and rotators sources
|
||||
under their own subdirectories. Mike, W9MDB
|
||||
|
||||
Version 3.3
|
||||
2018-08-12
|
||||
|
|
122
README.developer
122
README.developer
|
@ -38,75 +38,89 @@ utility), and USB. Other connectivity will follow afterwards.
|
|||
General Guidelines.
|
||||
-------------------
|
||||
|
||||
0. The top level directory looks like this as of 07 May 2013
|
||||
(Note, it has grown considerably).
|
||||
0. The top level directory looks like this as of 2020-01-18
|
||||
|
||||
$ tree -d -I .git
|
||||
.
|
||||
├── adat
|
||||
├── alinco
|
||||
├── amsat
|
||||
├── amplifiers
|
||||
│ └── elecraft
|
||||
├── android
|
||||
├── aor
|
||||
├── ars
|
||||
├── autom4te.cache
|
||||
├── bindings
|
||||
├── build-aux
|
||||
├── c++
|
||||
├── celestron
|
||||
├── doc
|
||||
├── drake
|
||||
│ ├── man1
|
||||
│ └── man7
|
||||
├── dummy
|
||||
├── easycomm
|
||||
├── flexradio
|
||||
├── fodtrack
|
||||
├── gnuradio
|
||||
├── gs232a
|
||||
├── heathkit
|
||||
├── icom
|
||||
├── extra
|
||||
│ ├── gnuradio
|
||||
│ └── kylix
|
||||
│ └── tests
|
||||
├── include
|
||||
│ └── hamlib
|
||||
├── jrc
|
||||
├── kachina
|
||||
├── kenwood
|
||||
├── kit
|
||||
├── kylix
|
||||
│ └── tests
|
||||
│ └── hamlib
|
||||
├── lib
|
||||
├── lowe
|
||||
├── m2
|
||||
├── macros
|
||||
├── microtune
|
||||
├── miniVNA
|
||||
├── pcr
|
||||
├── perl
|
||||
├── prm80
|
||||
├── racal
|
||||
├── rft
|
||||
├── rotorez
|
||||
├── rs
|
||||
├── sartek
|
||||
├── rigs
|
||||
│ ├── adat
|
||||
│ ├── alinco
|
||||
│ ├── aor
|
||||
│ ├── barrett
|
||||
│ ├── dorji
|
||||
│ ├── drake
|
||||
│ ├── elad
|
||||
│ ├── flexradio
|
||||
│ ├── icmarine
|
||||
│ ├── icom
|
||||
│ ├── jrc
|
||||
│ ├── kachina
|
||||
│ ├── kenwood
|
||||
│ ├── kit
|
||||
│ ├── lowe
|
||||
│ ├── pcr
|
||||
│ ├── prm80
|
||||
│ ├── racal
|
||||
│ ├── rft
|
||||
│ ├── rs
|
||||
│ ├── skanti
|
||||
│ ├── tapr
|
||||
│ ├── tentec
|
||||
│ ├── tuner
|
||||
│ ├── uniden
|
||||
│ ├── winradio
|
||||
│ │ └── linradio
|
||||
│ ├── wj
|
||||
│ └── yaesu
|
||||
├── rotators
|
||||
│ ├── amsat
|
||||
│ ├── ars
|
||||
│ ├── celestron
|
||||
│ ├── cnctrk
|
||||
│ ├── easycomm
|
||||
│ ├── ether6
|
||||
│ ├── fodtrack
|
||||
│ ├── gs232a
|
||||
│ ├── heathkit
|
||||
│ ├── ioptron
|
||||
│ ├── m2
|
||||
│ ├── meade
|
||||
│ ├── prosistel
|
||||
│ ├── rotorez
|
||||
│ ├── sartek
|
||||
│ ├── spid
|
||||
│ └── ts7400
|
||||
│ └── include
|
||||
├── scripts
|
||||
├── skanti
|
||||
├── spid
|
||||
├── src
|
||||
├── tapr
|
||||
├── tentec
|
||||
├── tests
|
||||
│ ├── config
|
||||
│ ├── rigctl.test
|
||||
│ ├── testbcd.test
|
||||
│ ├── testfreq.test
|
||||
│ └── testloc.test
|
||||
├── ts7400
|
||||
│ └── include
|
||||
├── tuner
|
||||
├── uniden
|
||||
├── winradio
|
||||
│ └── linradio
|
||||
├── wj
|
||||
└── yaesu
|
||||
|
||||
61 directories
|
||||
└── tests
|
||||
├── config
|
||||
├── rigctl.test
|
||||
├── testbcd.test
|
||||
├── testfreq.test
|
||||
└── testloc.test
|
||||
|
||||
77 directories
|
||||
|
||||
1. Building
|
||||
|
||||
|
|
118
configure.ac
118
configure.ac
|
@ -51,8 +51,9 @@ dnl added to AC_CONFIG_FILES near the end of this file. See README.developer
|
|||
dnl Beware of duplication should a backend directory include both rig and
|
||||
dnl rotor definitions, e.g. "dummy". Optional backends will not be listed
|
||||
dnl here but will be added later, e.g. "winradio".
|
||||
BACKEND_LIST="adat alinco aor barrett dorji drake dummy elad flexradio icom icmarine jrc kachina kenwood kit lowe pcr prm80 racal rft rs skanti tapr tentec tuner uniden wj yaesu"
|
||||
ROT_BACKEND_LIST="amsat ars celestron cnctrk easycomm ether6 fodtrack gs232a heathkit m2 meade rotorez sartek spid ts7400 prosistel ioptron"
|
||||
BACKEND_LIST="dummy"
|
||||
RIG_BACKEND_LIST="rigs/adat rigs/alinco rigs/aor rigs/barrett rigs/dorji rigs/drake rigs/elad rigs/flexradio rigs/icom rigs/icmarine rigs/jrc rigs/kachina rigs/kenwood rigs/kit rigs/lowe rigs/pcr rigs/prm80 rigs/racal rigs/rft rigs/rs rigs/skanti rigs/tapr rigs/tentec rigs/tuner rigs/uniden rigs/winradio rigs/wj rigs/yaesu"
|
||||
ROT_BACKEND_LIST="rotators/amsat rotators/ars rotators/celestron rotators/cnctrk rotators/easycomm rotators/ether6 rotators/fodtrack rotators/gs232a rotators/heathkit rotators/m2 rotators/meade rotators/rotorez rotators/sartek rotators/spid rotators/ts7400 rotators/prosistel rotators/ioptron"
|
||||
# Amplifiers are all in the amplifiers directory
|
||||
AMP_BACKEND_LIST="amplifiers/elecraft"
|
||||
|
||||
|
@ -653,7 +654,7 @@ AC_MSG_RESULT([$cf_with_winradio])
|
|||
DL_LIBS=""
|
||||
|
||||
AS_IF([test x"${cf_with_winradio}" = "xyes"],
|
||||
[BACKEND_LIST="$BACKEND_LIST winradio"
|
||||
[RIGS_BACKEND_LIST="$RIGS_BACKEND_LIST rigs/winradio"
|
||||
dnl Check for libdl and set DL_LIBS if found--used for linradio WR-G313 backend.
|
||||
AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"],
|
||||
[AC_MSG_WARN([dlopen was not found in libdl--linradio backend will be disabled])])
|
||||
|
@ -704,6 +705,10 @@ AM_CONDITIONAL([HAVE_USRP], [test x"${cf_with_usrp}" = "xyes"])
|
|||
|
||||
dnl otherwise parallel 'make -jn' will fail
|
||||
|
||||
## ---------------------------------- ##
|
||||
## Prepare toplevel backend dependencies ##
|
||||
## ---------------------------------- ##
|
||||
|
||||
for be in ${BACKEND_LIST} ; do
|
||||
BACKENDEPS="${BACKENDEPS} \$(top_builddir)/${be}/libhamlib-${be}.la"
|
||||
done
|
||||
|
@ -711,6 +716,18 @@ done
|
|||
AC_SUBST([BACKEND_LIST])
|
||||
AC_SUBST([BACKENDEPS])
|
||||
|
||||
## ---------------------------------- ##
|
||||
## Prepare rig backend dependencies ##
|
||||
## ---------------------------------- ##
|
||||
|
||||
for be in ${RIG_BACKEND_LIST} ; do
|
||||
RIGDIR=`echo $be | awk -F "/" '{print $2}'`
|
||||
RIG_BACKENDEPS="${RIG_BACKENDEPS} \$(top_builddir)/rigs/${RIGDIR}/libhamlib-${RIGDIR}.la"
|
||||
done
|
||||
|
||||
AC_SUBST([RIG_BACKEND_LIST])
|
||||
AC_SUBST([RIG_BACKENDEPS])
|
||||
|
||||
|
||||
## ---------------------------------- ##
|
||||
## Prepare rotor backend dependencies ##
|
||||
|
@ -719,7 +736,8 @@ AC_SUBST([BACKENDEPS])
|
|||
# otherwise parallel 'make -jn' will fail
|
||||
|
||||
for be in ${ROT_BACKEND_LIST} ; do
|
||||
ROT_BACKENDEPS="${ROT_BACKENDEPS} \$(top_builddir)/${be}/libhamlib-${be}.la"
|
||||
ROTDIR=`echo $be | awk -F "/" '{print $2}'`
|
||||
ROT_BACKENDEPS="${ROT_BACKENDEPS} \$(top_builddir)/rotators/${ROTDIR}/libhamlib-${ROTDIR}.la"
|
||||
done
|
||||
|
||||
AC_SUBST([ROT_BACKEND_LIST])
|
||||
|
@ -756,59 +774,59 @@ macros/Makefile
|
|||
include/Makefile
|
||||
lib/Makefile
|
||||
dummy/Makefile
|
||||
elad/Makefile
|
||||
yaesu/Makefile
|
||||
icom/Makefile
|
||||
icmarine/Makefile
|
||||
aor/Makefile
|
||||
kenwood/Makefile
|
||||
winradio/Makefile
|
||||
pcr/Makefile
|
||||
alinco/Makefile
|
||||
uniden/Makefile
|
||||
tentec/Makefile
|
||||
kachina/Makefile
|
||||
jrc/Makefile
|
||||
drake/Makefile
|
||||
lowe/Makefile
|
||||
rft/Makefile
|
||||
rs/Makefile
|
||||
kit/Makefile
|
||||
tapr/Makefile
|
||||
skanti/Makefile
|
||||
prm80/Makefile
|
||||
wj/Makefile
|
||||
racal/Makefile
|
||||
tuner/Makefile
|
||||
ars/Makefile
|
||||
easycomm/Makefile
|
||||
fodtrack/Makefile
|
||||
gs232a/Makefile
|
||||
heathkit/Makefile
|
||||
spid/Makefile
|
||||
sartek/Makefile
|
||||
src/Makefile
|
||||
c++/Makefile
|
||||
bindings/Makefile
|
||||
tests/Makefile
|
||||
doc/Makefile
|
||||
doc/hamlib.cfg
|
||||
rotorez/Makefile
|
||||
flexradio/Makefile
|
||||
m2/Makefile
|
||||
amsat/Makefile
|
||||
adat/Makefile
|
||||
ts7400/Makefile
|
||||
celestron/Makefile
|
||||
cnctrk/Makefile
|
||||
ether6/Makefile
|
||||
rotators/amsat/Makefile
|
||||
rotators/ars/Makefile
|
||||
rotators/celestron/Makefile
|
||||
rotators/cnctrk/Makefile
|
||||
rotators/easycomm/Makefile
|
||||
rotators/ether6/Makefile
|
||||
rotators/fodtrack/Makefile
|
||||
rotators/gs232a/Makefile
|
||||
rotators/heathkit/Makefile
|
||||
rotators/ioptron/Makefile
|
||||
rotators/m2/Makefile
|
||||
rotators/meade/Makefile
|
||||
rotators/prosistel/Makefile
|
||||
rotators/rotorez/Makefile
|
||||
rotators/sartek/Makefile
|
||||
rotators/spid/Makefile
|
||||
rotators/ts7400/Makefile
|
||||
rigs/adat/Makefile
|
||||
rigs/alinco/Makefile
|
||||
rigs/aor/Makefile
|
||||
rigs/barrett/Makefile
|
||||
rigs/dorji/Makefile
|
||||
rigs/drake/Makefile
|
||||
rigs/elad/Makefile
|
||||
rigs/flexradio/Makefile
|
||||
rigs/icmarine/Makefile
|
||||
rigs/icom/Makefile
|
||||
rigs/jrc/Makefile
|
||||
rigs/kachina/Makefile
|
||||
rigs/kenwood/Makefile
|
||||
rigs/kit/Makefile
|
||||
rigs/lowe/Makefile
|
||||
rigs/pcr/Makefile
|
||||
rigs/prm80/Makefile
|
||||
rigs/racal/Makefile
|
||||
rigs/rft/Makefile
|
||||
rigs/rs/Makefile
|
||||
rigs/skanti/Makefile
|
||||
rigs/tapr/Makefile
|
||||
rigs/tentec/Makefile
|
||||
rigs/tuner/Makefile
|
||||
rigs/uniden/Makefile
|
||||
rigs/winradio/Makefile
|
||||
rigs/wj/Makefile
|
||||
rigs/yaesu/Makefile
|
||||
tests/Makefile
|
||||
scripts/Makefile
|
||||
android/Makefile
|
||||
prosistel/Makefile
|
||||
dorji/Makefile
|
||||
barrett/Makefile
|
||||
meade/Makefile
|
||||
ioptron/Makefile
|
||||
amplifiers/elecraft/Makefile
|
||||
hamlib.pc
|
||||
])
|
||||
|
|
|
@ -6,6 +6,6 @@ echo "As of cppcheck v1.90 should be one message about missing include files"
|
|||
echo "This takes several minutes to run"
|
||||
# We do suppress some errors which are expected or other code
|
||||
# There are quite a few C++ items to take care of still if anybody cares
|
||||
SUPPRESS="-i bindings -i lib/getopt.c -i lib/getopt_long.c --suppress=*:gnuradio/demod.h --suppress=*:gnuradio/HrAGC.h --suppress=*:gnuradio/nfm.h --suppress=*:gnuradio/am.h --suppress=*:gnuradio/ssb.h --suppress=*:gnuradio/wfm.h --suppress=*:gnuradio/wfm.h --suppress=*:microtune/i2c.h --suppress=*:microtune/i2cio.h --suppress=*:microtune/i2cio_pp.h --suppress=*:microtune/microtune_4702.h --suppress=*:microtune/microtune_4937.h --suppress=*:microtune/microtune_eval_board.h -i microtune/microtune_eval_board.cc --suppress=*:gnuradio/HrAGC.h --suppress=knownConditionTrueFalse:tests/rotctl.c --suppress=knownConditionTrueFalse:tests/rigctl.c --suppress=knownConditionTrueFalse:tests/ampctl.c --suppress=knownConditionTrueFalse:tests/rotctl_parse.c --suppress=knownConditionTrueFalse:tests/rigctl_parse.c --suppress=knownConditionTrueFalse:tests/ampctl_parse.c"
|
||||
SUPPRESS="-i bindings -i lib/getopt.c -i lib/getopt_long.c --suppress=*:extra/gnuradio/demod.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=*:extra/gnuradio/nfm.h --suppress=*:extra/gnuradio/am.h --suppress=*:extra/gnuradio/ssb.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/wfm.h --suppress=*:extra/gnuradio/HrAGC.h --suppress=knownConditionTrueFalse:tests/rotctl.c --suppress=knownConditionTrueFalse:tests/rigctl.c --suppress=knownConditionTrueFalse:tests/ampctl.c --suppress=knownConditionTrueFalse:tests/rotctl_parse.c --suppress=knownConditionTrueFalse:tests/rigctl_parse.c --suppress=knownConditionTrueFalse:tests/ampctl_parse.c"
|
||||
CHECK="-D RIG_LEVEL_LINEOUT=1 -D SIGPIPE -D SIGINT -D IPV6_V6ONLY -D RIG_MODE_WFM -D ABI_VERSION=4 -D F_SETSIG=1 -U O_ASYNC -U SA_SIGINFO -U HASH_BLOOM -U HASH_EMIT_KEYS -U HASH_FUNCTION -U __USEP5P6__"
|
||||
cppcheck -q --force --enable=all --std=c99 $SUPPRESS $CHECK . &>cppcheck.log
|
||||
|
|
|
@ -869,8 +869,6 @@ static int flrig_close(RIG *rig)
|
|||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
|
||||
|
||||
if (rig->state.priv) { free(rig->state.priv); }
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
@ -892,7 +890,12 @@ static int flrig_cleanup(RIG *rig)
|
|||
|
||||
for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
|
||||
{
|
||||
if (modeMap[i].mode_flrig) { free(modeMap[i].mode_flrig); }
|
||||
if (modeMap[i].mode_flrig)
|
||||
{
|
||||
free(modeMap[i].mode_flrig);
|
||||
modeMap[i].mode_flrig = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
MTSRC = module_4937.c module_4702.c
|
||||
|
||||
GRIO_SOURCES = \
|
||||
i2cio.cc i2cio.h \
|
||||
i2cio_pp.cc i2cio_pp.h \
|
||||
i2c.cc i2c.h \
|
||||
microtune_4937.cc microtune_4937.h \
|
||||
microtune_4702.cc microtune_4702.h \
|
||||
microtune_eval_board.cc microtune_eval_board.h \
|
||||
microtune_eval_board_defs.h
|
||||
|
||||
noinst_LTLIBRARIES = libhamlib-microtune.la
|
||||
libhamlib_microtune_la_SOURCES = $(MTSRC) $(GRIO_SOURCES) microtune.cc microtune.h
|
||||
hamlib_microtune_la_LIBADD = -lstdc++
|
146
microtune/i2c.cc
146
microtune/i2c.cc
|
@ -1,146 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2c.cc
|
||||
* Description: generic i2c bus controller
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
i2c::i2c (i2cio *io)
|
||||
{
|
||||
d_io = io;
|
||||
d_io->lock ();
|
||||
|
||||
stop (); // get bus in known state
|
||||
|
||||
d_io->unlock ();
|
||||
}
|
||||
|
||||
|
||||
// start:
|
||||
// entry: SCL = 1, SDA = 1
|
||||
// exit: SCL = 0, SDA = 0
|
||||
|
||||
void
|
||||
i2c::start ()
|
||||
{
|
||||
set_sda (1);
|
||||
set_scl (1);
|
||||
set_sda (0); // SDA high -> low while SCL high
|
||||
set_scl (0);
|
||||
}
|
||||
|
||||
|
||||
// stop:
|
||||
// entry: SCL = X, SDA = X
|
||||
// exit: SCL = 1, SDA = 1
|
||||
|
||||
void
|
||||
i2c::stop ()
|
||||
{
|
||||
set_scl (0);
|
||||
set_sda (0);
|
||||
set_scl (1);
|
||||
set_sda (1); // SDA low -> high while SCL high
|
||||
}
|
||||
|
||||
|
||||
// write_bit:
|
||||
// entry: SCL = 0, SDA = X
|
||||
// exit: SCL = 0, SDA = X
|
||||
|
||||
void
|
||||
i2c::write_bit (bool bit)
|
||||
{
|
||||
set_sda (bit);
|
||||
set_scl (1);
|
||||
set_scl (0);
|
||||
}
|
||||
|
||||
|
||||
// write_byte:
|
||||
// entry: SCL = 0, SDA = X
|
||||
// exit: SCL = 0, SDA = 1
|
||||
|
||||
bool
|
||||
i2c::write_byte (char t)
|
||||
{
|
||||
int i;
|
||||
bool ack_bit;
|
||||
|
||||
for (i = 0; i < 8; i++){
|
||||
write_bit (t & 0x80);
|
||||
t <<= 1;
|
||||
}
|
||||
|
||||
// clock #9. This is the ACK bit.
|
||||
|
||||
set_sda (1); // tristate SDA
|
||||
set_scl (1);
|
||||
ack_bit = get_sda (); // slave should pull SDA line low
|
||||
set_scl (0);
|
||||
|
||||
return ack_bit == 0;
|
||||
}
|
||||
|
||||
|
||||
// write: the high level entry point...
|
||||
// entry: SCL = 1, SDA = 1
|
||||
// exit: SCL = 1, SDA = 1
|
||||
|
||||
bool
|
||||
i2c::write (int addr, const unsigned char *buf, int nbytes)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
d_io->lock ();
|
||||
start ();
|
||||
ok = write_byte ((addr << 1) | 0); // addr plus "read opcode"
|
||||
|
||||
for (int i = 0; i < nbytes; i++)
|
||||
ok &= write_byte (buf[i]);
|
||||
|
||||
stop ();
|
||||
d_io->unlock ();
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
// read: the high level entry point...
|
||||
// entry: SCL = 1, SDA = 1
|
||||
// exit: SCL = 1, SDA = 1
|
||||
|
||||
int
|
||||
i2c::read (int addr, unsigned char *buf, int max_bytes)
|
||||
{
|
||||
d_io->lock ();
|
||||
|
||||
// FIXME
|
||||
|
||||
d_io->unlock ();
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2c.h
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _I2C_H_
|
||||
#define _I2C_H_
|
||||
|
||||
#include "i2cio.h"
|
||||
|
||||
/*!
|
||||
* \brief class for controlling i2c bus
|
||||
*/
|
||||
class i2c {
|
||||
public:
|
||||
|
||||
/*! i2c does not control lifetime of a_io */
|
||||
i2c (i2cio *io);
|
||||
~i2c () {};
|
||||
|
||||
//! \returns true iff successful
|
||||
bool write (int addr, const unsigned char *buf, int nbytes);
|
||||
|
||||
//! \returns number of bytes read or -1 if error
|
||||
int read (int addr, unsigned char *buf, int max_bytes);
|
||||
|
||||
|
||||
private:
|
||||
void start ();
|
||||
void stop ();
|
||||
void write_bit (bool bit);
|
||||
bool write_byte (char byte);
|
||||
|
||||
void set_sda (bool bit) { d_io->set_sda (bit); }
|
||||
void set_scl (bool bit) { d_io->set_scl (bit); }
|
||||
bool get_sda () { return d_io->get_sda (); }
|
||||
|
||||
i2cio *d_io;
|
||||
};
|
||||
|
||||
#endif /* _I2C_H_ */
|
|
@ -1,33 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2cio.cc
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "i2cio.h"
|
||||
|
||||
i2cio::~i2cio(){}
|
|
@ -1,71 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2cio.h
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _I2CIO_H_
|
||||
#define _I2CIO_H_
|
||||
|
||||
/*!
|
||||
* \brief abstract class that implements low level i/o for i2c bus.
|
||||
*/
|
||||
class i2cio {
|
||||
public:
|
||||
|
||||
i2cio () :
|
||||
udelay_scl_lo(0), udelay_scl_hi(0),
|
||||
udelay_sda_lo(0), udelay_sda_hi(0) {};
|
||||
|
||||
virtual ~i2cio ();
|
||||
|
||||
virtual void set_scl (bool state) = 0;
|
||||
virtual void set_sda (bool state) = 0;
|
||||
virtual bool get_sda () = 0;
|
||||
|
||||
void set_udelay_scl_lo (int usecs) { udelay_scl_lo = usecs; }
|
||||
void set_udelay_scl_hi (int usecs) { udelay_scl_hi = usecs; }
|
||||
void set_udelay_sda_lo (int usecs) { udelay_sda_lo = usecs; }
|
||||
void set_udelay_sda_hi (int usecs) { udelay_sda_hi = usecs; }
|
||||
|
||||
int get_udelay_scl_lo () { return udelay_scl_lo; }
|
||||
int get_udelay_scl_hi () { return udelay_scl_hi; }
|
||||
int get_udelay_sda_lo () { return udelay_sda_lo; }
|
||||
int get_udelay_sda_hi () { return udelay_sda_hi; }
|
||||
|
||||
virtual void lock () = 0;
|
||||
virtual void unlock () = 0;
|
||||
|
||||
private:
|
||||
int udelay_scl_lo;
|
||||
int udelay_scl_hi;
|
||||
int udelay_sda_lo;
|
||||
int udelay_sda_hi;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _I2CIO_H_ */
|
|
@ -1,94 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2cio_pp.cc
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "i2cio_pp.h"
|
||||
#include "microtune_eval_board_defs.h"
|
||||
|
||||
i2cio_pp::i2cio_pp (hamlib_port_t *pp)
|
||||
{
|
||||
unsigned char r;
|
||||
d_pp = pp;
|
||||
par_lock (d_pp);
|
||||
par_read_control (d_pp, &r);
|
||||
par_write_control (d_pp, r & ~UT_CP_MUST_BE_ZERO); // output, no interrupts
|
||||
par_unlock (d_pp);
|
||||
}
|
||||
|
||||
void
|
||||
i2cio_pp::set_scl (bool state)
|
||||
{
|
||||
unsigned char r;
|
||||
par_read_control(d_pp, &r);
|
||||
|
||||
if (!state){ // active low
|
||||
par_write_control (d_pp, r | UT_CP_TUNER_SCL);
|
||||
}
|
||||
else {
|
||||
par_write_control (d_pp, r & ~UT_CP_TUNER_SCL);
|
||||
}
|
||||
par_read_control (d_pp, &r); // use for 1us delay
|
||||
par_read_control (d_pp, &r); // use for 1us delay
|
||||
}
|
||||
|
||||
void
|
||||
i2cio_pp::set_sda (bool state)
|
||||
{
|
||||
unsigned char r;
|
||||
par_read_data (d_pp, &r);
|
||||
|
||||
if (!state){ // active low
|
||||
par_write_data (d_pp, r | UT_DP_TUNER_SDA_OUT);
|
||||
}
|
||||
else {
|
||||
par_write_data (d_pp, r & ~UT_DP_TUNER_SDA_OUT);
|
||||
}
|
||||
par_read_data (d_pp, &r); // use for 1us delay
|
||||
par_read_data (d_pp, &r); // use for 1us delay
|
||||
}
|
||||
|
||||
bool
|
||||
i2cio_pp::get_sda ()
|
||||
{
|
||||
unsigned char r;
|
||||
par_read_status (d_pp, &r);
|
||||
return (r & UT_SP_TUNER_SDA_IN) == 0; // eval board has an inverter on it
|
||||
}
|
||||
|
||||
void
|
||||
i2cio_pp::lock ()
|
||||
{
|
||||
par_lock (d_pp);
|
||||
}
|
||||
|
||||
void
|
||||
i2cio_pp::unlock ()
|
||||
{
|
||||
par_unlock (d_pp);
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/* -*-C-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: i2cio_pp.h
|
||||
* Description: i2cio class for parallel port
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _I2CIO_PP_H_
|
||||
#define _I2CIO_PP_H_
|
||||
|
||||
#include "i2cio.h"
|
||||
#include "parallel.h"
|
||||
|
||||
/*!
|
||||
* \brief concrete class that implements low level i/o for i2c bus using parallel port
|
||||
*/
|
||||
class i2cio_pp : public i2cio {
|
||||
public:
|
||||
|
||||
i2cio_pp (hamlib_port_t *a_pp);
|
||||
|
||||
virtual void set_scl (bool state);
|
||||
virtual void set_sda (bool state);
|
||||
virtual bool get_sda ();
|
||||
|
||||
virtual void lock ();
|
||||
virtual void unlock ();
|
||||
|
||||
private:
|
||||
hamlib_port_t *d_pp;
|
||||
};
|
||||
|
||||
#endif /* _I2CIO_PP_H_ */
|
|
@ -1,192 +0,0 @@
|
|||
/*
|
||||
* Hamlib Microtune backend - main file
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
*
|
||||
* This library 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
#include "register.h"
|
||||
|
||||
#include "microtune.h"
|
||||
#include "microtune_eval_board.h"
|
||||
|
||||
#include "microtune_4937.h"
|
||||
#include "microtune_4702.h"
|
||||
|
||||
/*
|
||||
* TODO: allow these to be modifiable through rig_set_conf
|
||||
int i2c_addr;
|
||||
int reference_divider;
|
||||
bool fast_tuning_p; if set, higher charge pump current:
|
||||
faster tuning, worse phase noise
|
||||
for distance < 10kHz to the carrier
|
||||
*/
|
||||
|
||||
struct microtune_priv_data {
|
||||
microtune_eval_board *board;
|
||||
freq_t actual_freq;
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - status iff PLL is locked
|
||||
* - returns the output frequency of the tuner in Hz (->5.75e6) //3x7702.
|
||||
* or 36.00e6
|
||||
*/
|
||||
|
||||
int microtune_init(RIG *rig)
|
||||
{
|
||||
struct microtune_priv_data *priv;
|
||||
|
||||
rig->state.priv = (struct microtune_priv_data*)malloc(sizeof(struct microtune_priv_data));
|
||||
if (!rig->state.priv) {
|
||||
/* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
priv = rig->state.priv;
|
||||
|
||||
priv->actual_freq = RIG_FREQ_NONE;
|
||||
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int module_4937_open(RIG *rig)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
priv->board = new microtune_4937(&rig->state.rigport);
|
||||
if (!priv->board) {
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
if (!priv->board->board_present_p()) {
|
||||
rig_debug(RIG_DEBUG_WARN, "microtune: eval board is NOT present\n");
|
||||
delete priv->board;
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int module_4702_open(RIG *rig)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
priv->board = new microtune_4702(&rig->state.rigport);
|
||||
if (!priv->board) {
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
if (!priv->board->board_present_p()) {
|
||||
rig_debug(RIG_DEBUG_WARN, "microtune: eval board is NOT present\n");
|
||||
delete priv->board;
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int microtune_close(RIG *rig)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
delete priv->board;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int microtune_cleanup(RIG *rig)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
if (priv) {
|
||||
free(priv);
|
||||
}
|
||||
rig->state.priv = NULL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* It takes about 100 ms for the PLL to settle.
|
||||
*/
|
||||
int microtune_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
double actual_freq;
|
||||
bool status;
|
||||
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
status = priv->board->set_RF_freq((double)freq, &actual_freq);
|
||||
|
||||
if (!status)
|
||||
return -RIG_EIO;
|
||||
|
||||
priv->actual_freq = (freq_t)actual_freq;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
int microtune_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
*freq = priv->actual_freq;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
*/
|
||||
int microtune_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
|
||||
{
|
||||
struct microtune_priv_data *priv = (struct microtune_priv_data *)rig->state.priv;
|
||||
|
||||
switch(token) {
|
||||
case TOK_AGCGAIN:
|
||||
priv->board->set_AGC(val.f*1000);
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DECLARE_INITRIG_BACKEND(microtune)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "microtune: _init called\n");
|
||||
|
||||
rig_register(&module_4937_caps);
|
||||
rig_register(&module_4702_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Hamlib Microtune backend - main header
|
||||
* Copyright (c) 2001-2003 by Stephane Fillod
|
||||
*
|
||||
*
|
||||
* This library 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _MICRTOUNE_H
|
||||
#define _MICRTOUNE_H 1
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <token.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define TOK_AGCGAIN TOKEN_BACKEND(1)
|
||||
|
||||
|
||||
int microtune_init(RIG *rig);
|
||||
int microtune_cleanup(RIG *rig);
|
||||
int module_4937_open(RIG *rig);
|
||||
int module_4702_open(RIG *rig);
|
||||
int microtune_close(RIG *rig);
|
||||
int microtune_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int microtune_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
int microtune_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val);
|
||||
|
||||
|
||||
extern const struct rig_caps module_4937_caps;
|
||||
extern const struct rig_caps module_4702_caps;
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _MICRTOUNE_H */
|
|
@ -1,177 +0,0 @@
|
|||
/* -*- c++-*- */
|
||||
/*
|
||||
* Copyright 2001,2003 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "microtune_4702.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static const double first_IF = 36.00e6;
|
||||
|
||||
// The tuner internally has 3 bands: VHF Low, VHF High & UHF.
|
||||
// These are the recommened boundaries
|
||||
static const double VHF_High_takeover = 174e6;
|
||||
static const double UHF_takeover = 470e6;
|
||||
|
||||
static int PLL_I2C_ADDR = 0x60;
|
||||
|
||||
static unsigned char
|
||||
control_byte_1 (bool prescaler, int reference_divisor)
|
||||
{
|
||||
int c = 0x80;
|
||||
//Note: Last two divider bits (bits 2 and 3 of this byte) determined later
|
||||
if (prescaler)
|
||||
c |= 0x10;
|
||||
|
||||
switch (reference_divisor){
|
||||
case 2:
|
||||
c |= 0x00; break;
|
||||
case 4:
|
||||
c |= 0x01; break;
|
||||
case 8:
|
||||
c |= 0x02; break;
|
||||
case 16:
|
||||
c |= 0x03; break;
|
||||
case 32:
|
||||
c |= 0x04; break;
|
||||
case 64:
|
||||
c |= 0x05; break;
|
||||
case 128:
|
||||
c |= 0x06; break;
|
||||
case 256:
|
||||
c |= 0x07; break;
|
||||
case 24:
|
||||
c |= 0x08; break;
|
||||
case 5:
|
||||
c |= 0x09; break;
|
||||
case 10:
|
||||
c |= 0x0A; break;
|
||||
case 20:
|
||||
c |= 0x0B; break;
|
||||
case 40:
|
||||
c |= 0x0C; break;
|
||||
case 80:
|
||||
c |= 0x0D; break;
|
||||
case 160:
|
||||
c |= 0x0E; break;
|
||||
case 320:
|
||||
c |= 0x0F; break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
control_byte_2 (double target_freq)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (target_freq < VHF_High_takeover) // VHF low
|
||||
c = 0x8E;
|
||||
else if (target_freq < UHF_takeover) // VHF high
|
||||
{
|
||||
c = 0x05;
|
||||
if (target_freq < 390e6)
|
||||
c |= 0x40;
|
||||
else
|
||||
c |= 0x80;
|
||||
}
|
||||
else
|
||||
{ // UHF
|
||||
c = 0x03;
|
||||
if (target_freq < 750e6)
|
||||
c |= 0x80;
|
||||
else
|
||||
c |= 0xC0;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief select RF frequency to be tuned to output frequency.
|
||||
* \p target_freq is the requested frequency in Hz, \p actual_freq
|
||||
* is set to the actual frequency tuned. It takes about 100 ms
|
||||
* for the PLL to settle.
|
||||
*
|
||||
* \returns true iff sucessful.
|
||||
*/
|
||||
bool
|
||||
microtune_4702::set_RF_freq (double target_freq, double *p_actual_freq)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
double target_f_osc = target_freq + first_IF;
|
||||
|
||||
double f_ref = 4e6 / d_reference_divider;
|
||||
|
||||
//int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8));
|
||||
|
||||
long int divisor = (long int) (target_f_osc / f_ref);
|
||||
double actual_freq = (f_ref * divisor) - first_IF;
|
||||
if (p_actual_freq != 0)
|
||||
*p_actual_freq = actual_freq;
|
||||
|
||||
if ((divisor & ~0x1ffff) != 0) // >17 bit divisor
|
||||
return false;
|
||||
|
||||
buf[0] = ((divisor & 0x07f00) >> 8) & 0xff; // DB1
|
||||
buf[1] = divisor & 0xff; // DB2
|
||||
buf[2] = control_byte_1 (prescaler, d_reference_divider);
|
||||
buf[2] = (buf[2]|(((divisor & 0x18000) >> 10)) & 0xff);
|
||||
buf[3] = control_byte_2 (target_freq);
|
||||
|
||||
printf ("%x\n", PLL_I2C_ADDR);
|
||||
//#if 0
|
||||
printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n",
|
||||
target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]);
|
||||
//#endif
|
||||
|
||||
return i2c_write (PLL_I2C_ADDR, buf, sizeof (buf));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
microtune_4702::read_info (unsigned char* buf)
|
||||
{
|
||||
return i2c_write (PLL_I2C_ADDR, buf, 2);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \returns true iff PLL is locked
|
||||
*/
|
||||
bool
|
||||
microtune_4702::pll_locked_p ()
|
||||
{
|
||||
// FIXME
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \returns the output frequency of the tuner in Hz.
|
||||
*/
|
||||
double
|
||||
microtune_4702::get_output_freq ()
|
||||
{
|
||||
return 36.00e6;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2001,2003 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MICROTUNE_4702_H_
|
||||
#define _MICROTUNE_4702_H_
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "microtune_eval_board.h"
|
||||
|
||||
/*!
|
||||
* \brief abstract class for controlling microtune 4702 tuner module
|
||||
*/
|
||||
class microtune_4702 : public microtune_eval_board {
|
||||
public:
|
||||
|
||||
microtune_4702(hamlib_port_t *port) : microtune_eval_board (port), d_reference_divider(320), prescaler(false) {}
|
||||
~microtune_4702() {}
|
||||
|
||||
/*!
|
||||
* \brief select RF frequency to be tuned to output frequency.
|
||||
* \p freq is the requested frequency in Hz, \p actual_freq
|
||||
* is set to the actual frequency tuned. It takes about 100 ms
|
||||
* for the PLL to settle.
|
||||
*
|
||||
* \returns true iff sucessful.
|
||||
*/
|
||||
bool set_RF_freq (double freq, double *actual_freq);
|
||||
bool read_info (unsigned char* buf);
|
||||
|
||||
double get_output_freq ();
|
||||
bool pll_locked_p ();
|
||||
|
||||
private:
|
||||
int d_reference_divider;
|
||||
bool prescaler; /* if set, higher charge pump current:
|
||||
faster tuning, worse phase noise
|
||||
for distance < 10kHz to the carrier */
|
||||
};
|
||||
|
||||
#endif /* _MICROTUNE_4702_H_ */
|
|
@ -1,134 +0,0 @@
|
|||
/* -*- c++-*- */
|
||||
/*
|
||||
* Copyright 2001,2003 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "microtune_4937.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static const double first_IF = 43.75e6;
|
||||
|
||||
// The tuner internally has 3 bands: VHF Low, VHF High & UHF.
|
||||
// These are the recommened boundaries
|
||||
static const double VHF_High_takeover = 158e6;
|
||||
static const double UHF_takeover = 464e6;
|
||||
|
||||
static int PLL_I2C_ADDR = 0x61;
|
||||
|
||||
static unsigned char
|
||||
control_byte_1 (bool fast_tuning_p, int reference_divisor)
|
||||
{
|
||||
int c = 0x88;
|
||||
|
||||
if (fast_tuning_p)
|
||||
c |= 0x40;
|
||||
|
||||
switch (reference_divisor){
|
||||
case 512:
|
||||
c |= 0x3 << 1; break;
|
||||
case 640:
|
||||
c |= 0x0 << 1; break;
|
||||
case 1024:
|
||||
c |= 0x1 << 1; break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
control_byte_2 (double target_freq, bool shutdown_tx_PGA)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (target_freq < VHF_High_takeover) // VHF low
|
||||
c = 0xa0;
|
||||
else if (target_freq < UHF_takeover) // VHF high
|
||||
c = 0x90;
|
||||
else // UHF
|
||||
c = 0x30;
|
||||
|
||||
if (shutdown_tx_PGA)
|
||||
c |= 0x08;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief select RF frequency to be tuned to output frequency.
|
||||
* \p target_freq is the requested frequency in Hz, \p actual_freq
|
||||
* is set to the actual frequency tuned. It takes about 100 ms
|
||||
* for the PLL to settle.
|
||||
*
|
||||
* \returns true iff sucessful.
|
||||
*/
|
||||
bool
|
||||
microtune_4937::set_RF_freq (double target_freq, double *p_actual_freq)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
double target_f_osc = target_freq + first_IF;
|
||||
|
||||
double f_ref = 4e6 / d_reference_divider;
|
||||
|
||||
// f_osc = f_ref * 8 * divisor
|
||||
// divisor = f_osc / (f_ref * 8)
|
||||
|
||||
int divisor = (int) ((target_f_osc + (f_ref * 4)) / (f_ref * 8));
|
||||
double actual_freq = (f_ref * 8 * divisor) - first_IF;
|
||||
if (p_actual_freq != 0)
|
||||
*p_actual_freq = actual_freq;
|
||||
|
||||
if ((divisor & ~0x7fff) != 0) // 15 bit divisor
|
||||
return false;
|
||||
|
||||
buf[0] = (divisor >> 8) & 0xff; // DB1
|
||||
buf[1] = divisor & 0xff; // DB2
|
||||
buf[2] = control_byte_1 (d_fast_tuning_p, d_reference_divider);
|
||||
buf[3] = control_byte_2 (target_freq, true);
|
||||
|
||||
#if 0
|
||||
printf ("set_RF_freq: target: %g MHz actual: %g MHz %02x %02x %02x %02x\n",
|
||||
target_freq/1e6, actual_freq/1e6, buf[0], buf[1], buf[2], buf[3]);
|
||||
#endif
|
||||
|
||||
return i2c_write (PLL_I2C_ADDR, buf, 4);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \returns true iff PLL is locked
|
||||
*/
|
||||
bool
|
||||
microtune_4937::pll_locked_p ()
|
||||
{
|
||||
// FIXME
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \returns the output frequency of the tuner in Hz.
|
||||
*/
|
||||
double
|
||||
microtune_4937::get_output_freq ()
|
||||
{
|
||||
return 5.75e6; // 3x7702
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2001,2003 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MICROTUNE_4937_H_
|
||||
#define _MICROTUNE_4937_H_
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "microtune_eval_board.h"
|
||||
|
||||
/*!
|
||||
* \brief abstract class for controlling microtune 4937 tuner module
|
||||
*/
|
||||
class microtune_4937 : public microtune_eval_board {
|
||||
public:
|
||||
microtune_4937(hamlib_port_t *port) : microtune_eval_board (port), d_reference_divider(640), d_fast_tuning_p(false) {}
|
||||
~microtune_4937() {}
|
||||
|
||||
/*!
|
||||
* \brief select RF frequency to be tuned to output frequency.
|
||||
* \p freq is the requested frequency in Hz, \p actual_freq
|
||||
* is set to the actual frequency tuned. It takes about 100 ms
|
||||
* for the PLL to settle.
|
||||
*
|
||||
* \returns true iff sucessful.
|
||||
*/
|
||||
bool set_RF_freq (double freq, double *actual_freq);
|
||||
|
||||
/*!
|
||||
* \returns true iff PLL is locked
|
||||
*/
|
||||
bool pll_locked_p ();
|
||||
|
||||
/*!
|
||||
* \returns the output frequency (IF center freq) of the tuner in Hz.
|
||||
*/
|
||||
double get_output_freq ();
|
||||
|
||||
private:
|
||||
int d_reference_divider;
|
||||
bool d_fast_tuning_p; /* if set, higher charge pump current:
|
||||
faster tuning, worse phase noise
|
||||
for distance < 10kHz to the carrier */
|
||||
};
|
||||
|
||||
#endif /* _MICROTUNE_4937_H_ */
|
|
@ -1,194 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: microtune_eval_board.cc
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "microtune_eval_board.h"
|
||||
#include "microtune_eval_board_defs.h"
|
||||
#include "serial.h"
|
||||
#include "i2cio_pp.h"
|
||||
#include "i2c.h"
|
||||
#include <cmath>
|
||||
|
||||
static int AGC_DAC_I2C_ADDR = 0x2C;
|
||||
|
||||
microtune_eval_board::microtune_eval_board (hamlib_port_t *port)
|
||||
{
|
||||
m_ppio = port;
|
||||
m_i2cio = new i2cio_pp (m_ppio);
|
||||
m_i2c = new i2c (m_i2cio);
|
||||
|
||||
// disable upstream amplifier
|
||||
par_lock (m_ppio);
|
||||
unsigned char t;
|
||||
par_read_data (m_ppio, &t);
|
||||
t &= ~(UT_DP_TX_ENABLE | UT_DP_TX_SDA | UT_DP_TX_SCL);
|
||||
t |= UT_DP_TX_AS;
|
||||
par_write_data (m_ppio, t);
|
||||
par_unlock (m_ppio);
|
||||
}
|
||||
|
||||
microtune_eval_board::~microtune_eval_board ()
|
||||
{
|
||||
delete m_i2c;
|
||||
delete m_i2cio;
|
||||
}
|
||||
|
||||
|
||||
//! is the eval board present?
|
||||
bool
|
||||
microtune_eval_board::board_present_p ()
|
||||
{
|
||||
bool result = true;
|
||||
par_lock (m_ppio);
|
||||
|
||||
unsigned char t;
|
||||
par_read_status (m_ppio, &t);
|
||||
if ((t & UT_SP_SHOULD_BE_ZERO) != 0
|
||||
|| (t & UT_SP_SHOULD_BE_ONE) != UT_SP_SHOULD_BE_ONE)
|
||||
result = false;
|
||||
|
||||
// could also see if SCL is looped back or not, but that seems like overkill
|
||||
|
||||
par_unlock (m_ppio);
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns true iff successful
|
||||
bool
|
||||
microtune_eval_board::i2c_write (int addr, const unsigned char *buf, int nbytes)
|
||||
{
|
||||
return m_i2c->write (addr, buf, nbytes);
|
||||
}
|
||||
|
||||
// returns number of bytes read or -1 if error
|
||||
int
|
||||
microtune_eval_board::i2c_read (int addr, unsigned char *buf, int max_bytes)
|
||||
{
|
||||
return m_i2c->read (addr, buf, max_bytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------
|
||||
* AGC stuff
|
||||
*
|
||||
* We're using a MAX518 8-bit 5V dual dac for setting the AGC's
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
microtune_eval_board::write_dac (int which, int value)
|
||||
{
|
||||
unsigned char cmd[2];
|
||||
cmd[0] = which & 1;
|
||||
cmd[1] = value;
|
||||
i2c_write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd));
|
||||
}
|
||||
|
||||
void
|
||||
microtune_eval_board::write_both_dacs (int value0, int value1)
|
||||
{
|
||||
unsigned char cmd[4];
|
||||
cmd[0] = 0;
|
||||
cmd[1] = value0;
|
||||
cmd[2] = 1;
|
||||
cmd[3] = value1;
|
||||
i2c_write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd));
|
||||
}
|
||||
|
||||
static int scale_volts (float volts)
|
||||
{
|
||||
int n;
|
||||
n = (int) rint (volts * (256 / 5.0));
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
if (n > 255)
|
||||
n = 255;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
microtune_eval_board::set_RF_AGC_voltage (float volts)
|
||||
{
|
||||
write_dac (0, scale_volts (volts));
|
||||
}
|
||||
|
||||
void
|
||||
microtune_eval_board::set_IF_AGC_voltage (float volts)
|
||||
{
|
||||
write_dac (1, scale_volts (volts));
|
||||
}
|
||||
|
||||
static const float RF_MIN_V = 1.5; // RF AGC control voltages
|
||||
static const float RF_MAX_V = 4.0;
|
||||
static const float IF_MIN_V = 2.0; // IF AGC control voltages
|
||||
static const float IF_MAX_V = 4.0;
|
||||
|
||||
static const float MIN_AGC = 0; // bottom of synthetic range
|
||||
static const float MAX_AGC = 1000; // top of synthetic range
|
||||
|
||||
static const float CUTOVER_POINT = 667;
|
||||
|
||||
|
||||
// linear is in the range MIN_AGC to MAX_AGC
|
||||
|
||||
static float
|
||||
linear_to_RF_AGC_voltage (float linear)
|
||||
{
|
||||
if (linear >= CUTOVER_POINT)
|
||||
return RF_MAX_V;
|
||||
|
||||
float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT;
|
||||
return RF_MIN_V + linear * slope;
|
||||
}
|
||||
|
||||
static float
|
||||
linear_to_IF_AGC_voltage (float linear)
|
||||
{
|
||||
if (linear < CUTOVER_POINT)
|
||||
return IF_MIN_V;
|
||||
|
||||
float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT);
|
||||
return IF_MIN_V + (linear - CUTOVER_POINT) * slope;
|
||||
}
|
||||
|
||||
void
|
||||
microtune_eval_board::set_AGC (float v)
|
||||
{
|
||||
if (v < MIN_AGC)
|
||||
v = MIN_AGC;
|
||||
|
||||
if (v > MAX_AGC)
|
||||
v = MAX_AGC;
|
||||
|
||||
float rf_agc_voltage = linear_to_RF_AGC_voltage (v);
|
||||
float if_agc_voltage = linear_to_IF_AGC_voltage (v);
|
||||
|
||||
set_RF_AGC_voltage (rf_agc_voltage);
|
||||
set_IF_AGC_voltage (if_agc_voltage);
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/* -*-C++-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: microtune_eval_board.h
|
||||
* Description:
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MICROTUNE_EVAL_BOARD_H_
|
||||
#define _MICROTUNE_EVAL_BOARD_H_
|
||||
|
||||
#include "serial.h"
|
||||
|
||||
class i2cio;
|
||||
class i2c;
|
||||
|
||||
/*!
|
||||
* \brief concrete class for controlling a microtune eval board attached to parallel port
|
||||
*/
|
||||
class microtune_eval_board {
|
||||
public:
|
||||
microtune_eval_board (hamlib_port_t *port);
|
||||
virtual ~microtune_eval_board ();
|
||||
|
||||
//! is the eval board present?
|
||||
virtual bool board_present_p ();
|
||||
|
||||
|
||||
/*!
|
||||
* \brief select RF frequency to be tuned to output frequency.
|
||||
* \p freq is the requested frequency in Hz, \p actual_freq
|
||||
* is set to the actual frequency tuned. It takes about 100 ms
|
||||
* for the PLL to settle.
|
||||
*
|
||||
* \returns true iff sucessful.
|
||||
*/
|
||||
virtual bool set_RF_freq (double freq, double *actual_freq) = 0;
|
||||
|
||||
/*!
|
||||
* \returns true iff PLL is locked
|
||||
*/
|
||||
virtual bool pll_locked_p () = 0;
|
||||
|
||||
|
||||
/*!
|
||||
* \returns the output frequency (IF center freq) of the tuner in Hz.
|
||||
*/
|
||||
virtual double get_output_freq () = 0;
|
||||
|
||||
/*!
|
||||
* \brief set RF and IF AGC control voltages ([0, 5] volts)
|
||||
*/
|
||||
void set_RF_AGC_voltage (float volts);
|
||||
void set_IF_AGC_voltage (float volts);
|
||||
|
||||
/*!
|
||||
* \brief set RF and IF AGC levels together (scale [0, 1000])
|
||||
*
|
||||
* This provides a simple linear interface for adjusting both
|
||||
* the RF and IF gain in consort. This is the easy to use interface.
|
||||
* 0 corresponds to minimum gain. 1000 corresponds to maximum gain.
|
||||
*/
|
||||
void set_AGC (float value_0_1000);
|
||||
|
||||
|
||||
protected:
|
||||
//! \returns true iff successful
|
||||
virtual bool i2c_write (int addr, const unsigned char *buf, int nbytes);
|
||||
|
||||
//! \returns number of bytes read or -1 if error
|
||||
virtual int i2c_read (int addr, unsigned char *buf, int max_bytes);
|
||||
|
||||
private:
|
||||
void write_dac (int which, int value);
|
||||
void write_both_dacs (int val0, int val1);
|
||||
|
||||
hamlib_port_t *m_ppio;
|
||||
i2cio *m_i2cio;
|
||||
i2c *m_i2c;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _MICROTUNE_EVAL_BOARD_H_ */
|
|
@ -1,71 +0,0 @@
|
|||
/* -*-C-*-
|
||||
*******************************************************************************
|
||||
*
|
||||
* File: microtune_eval_board_defs.h
|
||||
* Description: defines for parallel port control of eval board
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2001 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 2, 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 GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MICROTUNE_EVAL_BOARD_DEFS_H_
|
||||
#define _MICROTUNE_EVAL_BOARD_DEFS_H_
|
||||
|
||||
/*
|
||||
* The Microtune 4937DI5/4702DT5 cable modem tuner eval board is controlled
|
||||
* by bit banging the PC parallel port. This file defines the relevant
|
||||
* bits.
|
||||
*
|
||||
* The parallel port has an 8 bit data port (output),
|
||||
* an 8 bit control port (output) and
|
||||
* an 8 bit status port (input).
|
||||
*
|
||||
* Not all bits of the control and status ports may be arbitrarily used.
|
||||
*/
|
||||
|
||||
|
||||
// parallel port data port constants (output)
|
||||
|
||||
static const int UT_DP_TX_SDA = 0x01; // upstream control bus
|
||||
static const int UT_DP_TX_SCL = 0x02; // upstream control bus
|
||||
static const int UT_DP_TX_AS = 0x04; // upstream control bus
|
||||
static const int UT_DP_TX_ENABLE = 0x08; // upstream h/w enable
|
||||
// bits 4,5,6 not used
|
||||
static const int UT_DP_TUNER_SDA_OUT = 0x80; // tuner i2c bus data
|
||||
|
||||
// parallel port control port constants (output)
|
||||
|
||||
static const int UT_CP_TUNER_SCL = 0x08; // tuner i2c bus clock
|
||||
static const int UT_CP_MUST_BE_ZERO = 0xf0; // must be zero
|
||||
|
||||
// parallel port status port constants (input)
|
||||
|
||||
// bits 0,1,2 not used
|
||||
static const int UT_SP_TUNER_SCL_LOOP_BACK= 0x08; // inverted SCL loop back
|
||||
static const int UT_SP_SHOULD_BE_ZERO = 0x10; // reads as zero
|
||||
static const int UT_SP_SHOULD_BE_ONE = 0x20; // reads as one
|
||||
// bit 6 not used
|
||||
static const int UT_SP_TUNER_SDA_IN = 0x80;
|
||||
|
||||
|
||||
#endif /* _MICROTUNE_EVAL_BOARD_DEFS_H_ */
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Hamlib microtune backend - 4702 file
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
*
|
||||
* This library 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
#include "microtune.h"
|
||||
|
||||
/*
|
||||
* Microtune 4702 rig capabilities.
|
||||
*/
|
||||
|
||||
#define M4702_FUNC RIG_FUNC_NONE
|
||||
#define M4702_LEVEL RIG_LEVEL_NONE
|
||||
#define M4702_PARM RIG_PARM_NONE
|
||||
|
||||
#define M4702_MODES (RIG_MODE_NONE) /* FIXME: IF */
|
||||
|
||||
#define M4702_VFO RIG_VFO_A
|
||||
|
||||
static const struct confparams module_4702_ext_parms[] =
|
||||
{
|
||||
{
|
||||
TOK_AGCGAIN, "agcgain", "AGC gain level", "RF and IF AGC levels",
|
||||
NULL, RIG_CONF_NUMERIC, { .n = { 0, 1, .001 } }
|
||||
},
|
||||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
|
||||
const struct rig_caps module_4702_caps =
|
||||
{
|
||||
.rig_model = RIG_MODEL_MICROTUNE_4702,
|
||||
.model_name = "4702 DT5 tuner module",
|
||||
.mfg_name = "Microtune",
|
||||
.version = "0.2.1",
|
||||
.copyright = "GPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.rig_type = RIG_TYPE_TUNER,
|
||||
.targetable_vfo = 0,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_PARALLEL,
|
||||
.has_get_func = M4702_FUNC,
|
||||
.has_set_func = M4702_FUNC,
|
||||
.has_get_level = M4702_LEVEL,
|
||||
.has_set_level = RIG_LEVEL_SET(M4702_LEVEL),
|
||||
.has_get_parm = M4702_PARM,
|
||||
.has_set_parm = RIG_PARM_SET(M4702_PARM),
|
||||
.chan_list = {
|
||||
RIG_CHAN_END,
|
||||
},
|
||||
.scan_ops = RIG_SCAN_NONE,
|
||||
.vfo_ops = RIG_OP_NONE,
|
||||
.transceive = RIG_TRN_OFF,
|
||||
.attenuator = { RIG_DBLST_END, },
|
||||
.preamp = { RIG_DBLST_END, },
|
||||
.rx_range_list2 = { {
|
||||
.start = MHz(50), .end = MHz(860), .modes = M4702_MODES,
|
||||
.low_power = -1, .high_power = -1, M4702_VFO
|
||||
},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = { RIG_FRNG_END, },
|
||||
|
||||
/* minimum tuning step with a reference divider of 640? (see Advance data sheet) */
|
||||
.tuning_steps = { {M4702_MODES, kHz(50)},
|
||||
RIG_TS_END,
|
||||
},
|
||||
.extparms = module_4702_ext_parms,
|
||||
.priv = NULL, /* priv */
|
||||
|
||||
.rig_init = microtune_init,
|
||||
.rig_cleanup = microtune_cleanup,
|
||||
.rig_open = module_4702_open,
|
||||
.rig_close = microtune_close,
|
||||
|
||||
.set_freq = microtune_set_freq,
|
||||
.get_freq = microtune_get_freq,
|
||||
.set_ext_level = microtune_set_ext_level,
|
||||
};
|
||||
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* Hamlib microtune backend - 4937 file
|
||||
* Copyright (c) 2003 by Stephane Fillod
|
||||
*
|
||||
*
|
||||
* This library 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
|
||||
#include "microtune.h"
|
||||
|
||||
/*
|
||||
* Microtune 4937 rig capabilities.
|
||||
*
|
||||
* TODO: set_ptt
|
||||
*/
|
||||
|
||||
#define M4937_FUNC RIG_FUNC_NONE
|
||||
#define M4937_LEVEL RIG_LEVEL_NONE
|
||||
#define M4937_PARM RIG_PARM_NONE
|
||||
|
||||
#define M4937_MODES (RIG_MODE_NONE) /* FIXME: IF */
|
||||
|
||||
#define M4937_VFO RIG_VFO_A
|
||||
|
||||
static const struct confparams module_4937_ext_parms[] =
|
||||
{
|
||||
{
|
||||
TOK_AGCGAIN, "agcgain", "AGC gain level", "RF and IF AGC levels",
|
||||
NULL, RIG_CONF_NUMERIC, { .n = { 0, 1, .001 } }
|
||||
},
|
||||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
|
||||
const struct rig_caps module_4937_caps =
|
||||
{
|
||||
.rig_model = RIG_MODEL_MICROTUNE_4937,
|
||||
.model_name = "4937 DI5 tuner module",
|
||||
.mfg_name = "Microtune",
|
||||
.version = "0.2.1",
|
||||
.copyright = "GPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.rig_type = RIG_TYPE_TUNER,
|
||||
.targetable_vfo = 0,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_PARALLEL,
|
||||
.has_get_func = M4937_FUNC,
|
||||
.has_set_func = M4937_FUNC,
|
||||
.has_get_level = M4937_LEVEL,
|
||||
.has_set_level = RIG_LEVEL_SET(M4937_LEVEL),
|
||||
.has_get_parm = M4937_PARM,
|
||||
.has_set_parm = RIG_PARM_SET(M4937_PARM),
|
||||
.chan_list = {
|
||||
RIG_CHAN_END,
|
||||
},
|
||||
.scan_ops = RIG_SCAN_NONE,
|
||||
.vfo_ops = RIG_OP_NONE,
|
||||
.transceive = RIG_TRN_OFF,
|
||||
.attenuator = { RIG_DBLST_END, },
|
||||
.preamp = { RIG_DBLST_END, },
|
||||
.rx_range_list2 = { {
|
||||
.start = MHz(55), .end = MHz(860), .modes = M4937_MODES,
|
||||
.low_power = -1, .high_power = -1, M4937_VFO
|
||||
},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = { {
|
||||
.start = MHz(5), .end = MHz(42), .modes = M4937_MODES,
|
||||
.low_power = mW(1), .high_power = W(1), M4937_VFO
|
||||
}, /* FIXME: power */
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
|
||||
/* minimum tuning step with a reference divider of 640 (see Advance data sheet) */
|
||||
.tuning_steps = { {M4937_MODES, kHz(50)},
|
||||
RIG_TS_END,
|
||||
},
|
||||
.extparms = module_4937_ext_parms,
|
||||
.priv = NULL, /* priv */
|
||||
|
||||
.rig_init = microtune_init,
|
||||
.rig_cleanup = microtune_cleanup,
|
||||
.rig_open = module_4937_open,
|
||||
.rig_close = microtune_close,
|
||||
|
||||
.set_freq = microtune_set_freq,
|
||||
.get_freq = microtune_get_freq,
|
||||
.set_ext_level = microtune_set_ext_level,
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Ładowanie…
Reference in New Issue