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 3, 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_4937_eval_board.h"
24 #include "microtune_eval_board_defs.h"
26 #include "microtune_4937.h"
28 static const int TUNER_I2C_ADDR = 0x61;
30 microtune_4937_eval_board::microtune_4937_eval_board (int which_pp)
31 : microtune_xxxx_eval_board (which_pp)
33 d_tuner = new microtune_4937 (d_i2c, TUNER_I2C_ADDR);
35 // disable upstream amplifier
37 int t = d_ppio->read_data ();
38 t &= ~(UT_DP_TX_ENABLE | UT_DP_TX_SDA | UT_DP_TX_SCL);
40 d_ppio->write_data (t);
44 microtune_4937_eval_board::~microtune_4937_eval_board ()
46 // Default action is OK
50 static const float RF_MIN_V = 1.5; // RF AGC control voltages
51 static const float RF_MAX_V = 4.0;
52 static const float IF_MIN_V = 2.0; // IF AGC control voltages
53 static const float IF_MAX_V = 4.0;
55 static const float MIN_AGC = 0; // bottom of synthetic range
56 static const float MAX_AGC = 1000; // top of synthetic range
58 static const float CUTOVER_POINT = 667;
61 // linear is in the range MIN_AGC to MAX_AGC
64 linear_to_RF_AGC_voltage (float linear)
66 if (linear >= CUTOVER_POINT)
69 float slope = (RF_MAX_V - RF_MIN_V) / CUTOVER_POINT;
70 return RF_MIN_V + linear * slope;
74 linear_to_IF_AGC_voltage (float linear)
76 if (linear < CUTOVER_POINT)
79 float slope = (IF_MAX_V - IF_MIN_V) / (MAX_AGC - CUTOVER_POINT);
80 return IF_MIN_V + (linear - CUTOVER_POINT) * slope;
84 microtune_4937_eval_board::set_AGC (float v)
92 float rf_agc_voltage = linear_to_RF_AGC_voltage (v);
93 float if_agc_voltage = linear_to_IF_AGC_voltage (v);
95 set_RF_AGC_voltage (rf_agc_voltage);
96 set_IF_AGC_voltage (if_agc_voltage);