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 "i2c_bbio_pp.h"
24 #include "microtune_eval_board_defs.h"
26 i2c_bbio_pp::i2c_bbio_pp (ppio_sptr pp)
30 d_pp->write_control (d_pp->read_control () & ~UT_CP_MUST_BE_ZERO); // output, no interrupts
35 make_i2c_bbio_pp (ppio_sptr pp)
37 return i2c_bbio_sptr (new i2c_bbio_pp (pp));
41 i2c_bbio_pp::set_scl (bool state)
43 int r = d_pp->read_control();
45 if (!state){ // active low
46 d_pp->write_control (r | UT_CP_TUNER_SCL);
49 d_pp->write_control (r & ~UT_CP_TUNER_SCL);
51 d_pp->read_control (); // use for 1us delay
52 d_pp->read_control (); // use for 1us delay
56 i2c_bbio_pp::set_sda (bool state)
58 int r = d_pp->read_data ();
60 if (!state){ // active low
61 d_pp->write_data (r | UT_DP_TUNER_SDA_OUT);
64 d_pp->write_data (r & ~UT_DP_TUNER_SDA_OUT);
66 d_pp->read_data (); // use for 1us delay
67 d_pp->read_data (); // use for 1us delay
71 i2c_bbio_pp::get_sda ()
73 int r = d_pp->read_status ();
74 return (r & UT_SP_TUNER_SDA_IN) == 0; // eval board has an inverter on it
84 i2c_bbio_pp::unlock ()