3 * Copyright 2001,2004 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #include "microtune_xxxx_eval_board.h"
24 #include "microtune_eval_board_defs.h"
25 #include "microtune_xxxx.h"
27 #include "i2c_bitbang.h"
28 #include "i2c_bbio_pp.h"
31 static int AGC_DAC_I2C_ADDR = 0x2C;
33 microtune_xxxx_eval_board::microtune_xxxx_eval_board (int which_pp)
35 d_ppio = make_ppio (which_pp);
36 d_i2c = make_i2c_bitbang (make_i2c_bbio_pp (d_ppio));
40 microtune_xxxx_eval_board::~microtune_xxxx_eval_board ()
47 //! is the eval board present?
49 microtune_xxxx_eval_board::board_present_p ()
54 int t = d_ppio->read_status ();
55 if ((t & UT_SP_SHOULD_BE_ZERO) != 0
56 || (t & UT_SP_SHOULD_BE_ONE) != UT_SP_SHOULD_BE_ONE)
59 // could also see if SCL is looped back or not, but that seems like overkill
66 * ----------------------------------------------------------------
69 * We're using a MAX518 8-bit 5V dual dac for setting the AGC's
70 * ----------------------------------------------------------------
73 microtune_xxxx_eval_board::write_dac (int which, int value)
78 d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd));
82 microtune_xxxx_eval_board::write_both_dacs (int value0, int value1)
89 d_i2c->write (AGC_DAC_I2C_ADDR, cmd, sizeof (cmd));
92 static int scale_volts (float volts)
95 n = (int) rint (volts * (256 / 5.0));
105 microtune_xxxx_eval_board::set_RF_AGC_voltage (float volts)
107 write_dac (0, scale_volts (volts));
111 microtune_xxxx_eval_board::set_IF_AGC_voltage (float volts)
113 write_dac (1, scale_volts (volts));
119 microtune_xxxx_eval_board::set_RF_freq (double freq, double *actual_freq)
121 return d_tuner->set_RF_freq (freq, actual_freq);
125 microtune_xxxx_eval_board::set_RF_freq (double freq)
127 return d_tuner->set_RF_freq (freq);
131 microtune_xxxx_eval_board::pll_locked_p ()
133 return d_tuner->pll_locked_p ();
137 microtune_xxxx_eval_board::get_output_freq ()
139 return d_tuner->get_output_freq ();