2 * Copyright 2007 Free Software Foundation, Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "memory_map.h"
25 #include "buffer_pool.h"
34 //#include "nonstdio.h"
37 * We ought to arrange for this to be called before main, but for now,
38 * we require that the user's main call u2_init as the first thing...
43 // Set GPIOs to inputs
44 hal_gpio_set_ddr(GPIO_TX_BANK, 0x0000, 0xffff);
45 hal_gpio_set_ddr(GPIO_RX_BANK, 0x0000, 0xffff);
47 hal_gpio_write(GPIO_TX_BANK, 0x0000, 0xffff); // init s/w output value to zero
48 hal_gpio_write(GPIO_RX_BANK, 0x0000, 0xffff);
52 // init spi, so that we can switch over to the high-speed clock
55 // set up the default clocks
58 // clocks_enable_test_clk(true);
61 output_regs->adc_ctrl = ADC_CTRL_ON;
64 ad9777_write_reg(0, R0_1R);
65 ad9777_write_reg(1, R1_INTERP_4X | R1_REAL_MIX);
66 ad9777_write_reg(2, 0);
67 ad9777_write_reg(3, R3_PLL_DIV_1);
68 ad9777_write_reg(4, R4_PLL_ON | R4_CP_AUTO);
69 ad9777_write_reg(5, R5_I_FINE_GAIN(0));
70 ad9777_write_reg(6, R6_I_COARSE_GAIN(0xf));
71 ad9777_write_reg(7, 0); // I dac offset
72 ad9777_write_reg(8, 0);
73 ad9777_write_reg(9, R9_Q_FINE_GAIN(0));
74 ad9777_write_reg(10, R10_Q_COARSE_GAIN(0xf));
75 ad9777_write_reg(11, 0); // Q dac offset
76 ad9777_write_reg(12, 0);
79 output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN);
81 pic_init(); // progammable interrupt controller
82 bp_init(); // buffer pool
84 lsadc_init(); // low-speed ADCs
85 lsdac_init(); // low-speed DACs
86 db_init(); // daughterboard init
90 // flash all leds to let us know board is alive
91 hal_set_leds(0x0, 0x1f);
93 hal_set_leds(0x1f, 0x1f);
95 hal_set_leds(0x0, 0x1f);
99 // test register readback
101 vv = ad9777_read_reg(0);
102 printf("ad9777 reg[0] = 0x%x\n", vv);
104 for (rr = 0x04; rr <= 0x0d; rr++){
105 vv = ad9510_read_reg(rr);
106 printf("ad9510 reg[0x%x] = 0x%x\n", rr, vv);