| 1 | /***************************************************************************//** |
| 2 | * @file ad9739a_fmc_ebz.c |
| 3 | * @brief Implementation of Main Function. |
| 4 | * @author DBogdan ([email protected]) |
| 5 | ******************************************************************************** |
| 6 | * Copyright 2015(c) Analog Devices, Inc. |
| 7 | * |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions are met: |
| 12 | * - Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * - Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in |
| 16 | * the documentation and/or other materials provided with the |
| 17 | * distribution. |
| 18 | * - Neither the name of Analog Devices, Inc. nor the names of its |
| 19 | * contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * - The use of this software may or may not infringe the patent rights |
| 22 | * of one or more patent holders. This license does not release you |
| 23 | * from the requirement that you obtain separate licenses from these |
| 24 | * patent holders to use this software. |
| 25 | * - Use of the software either in source or binary form, must be run |
| 26 | * on or directly connected to an Analog Devices Inc. component. |
| 27 | * |
| 28 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
| 29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
| 30 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 31 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 33 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | *******************************************************************************/ |
| 39 | |
| 40 | /******************************************************************************/ |
| 41 | /***************************** Include Files **********************************/ |
| 42 | /******************************************************************************/ |
| 43 | #include <xparameters.h> |
| 44 | #include <stdio.h> |
| 45 | #include "platform_drivers.h" |
| 46 | #include "dac_core.h" |
| 47 | #include "ad9739a.h" |
| 48 | #include "adf4350.h" |
| 49 | |
| 50 | /******************************************************************************/ |
| 51 | /********************** Macros and Constants Definitions **********************/ |
| 52 | /******************************************************************************/ |
| 53 | #define SPI_DEVICE_ID XPAR_PS7_SPI_0_DEVICE_ID |
| 54 | |
| 55 | /******************************************************************************/ |
| 56 | /************************ Variables Definitions *******************************/ |
| 57 | /******************************************************************************/ |
| 58 | adf4350_init_param default_adf4350_init_param = { |
| 59 | /* SPI */ |
| 60 | 0, // spi_chip_select |
| 61 | SPI_MODE_0, // spi_mode |
| 62 | PS7_SPI, // spi_type |
| 63 | SPI_DEVICE_ID, // spi_device_id |
| 64 | |
| 65 | /* Device settings */ |
| 66 | 25000000, // clkin; |
| 67 | 10000, // channel_spacing; |
| 68 | 2500000000ul, // power_up_frequency; |
| 69 | 0, // reference_div_factor; |
| 70 | 0, // reference_doubler_enable; |
| 71 | 0, // reference_div2_enable; |
| 72 | |
| 73 | /* r2_user_settings */ |
| 74 | 1, // phase_detector_polarity_positive_enable; |
| 75 | 0, // lock_detect_precision_6ns_enable; |
| 76 | 0, // lock_detect_function_integer_n_enable; |
| 77 | 2500, // charge_pump_current; |
| 78 | 0, // muxout_select; |
| 79 | 0, // low_spur_mode_enable; |
| 80 | |
| 81 | /* r3_user_settings */ |
| 82 | 0, // cycle_slip_reduction_enable; |
| 83 | 0, // charge_cancellation_enable; |
| 84 | 0, // anti_backlash_3ns_enable; |
| 85 | 0, // band_select_clock_mode_high_enable; |
| 86 | 0, // clk_divider_12bit; |
| 87 | 0, // clk_divider_mode; |
| 88 | |
| 89 | /* r4_user_settings */ |
| 90 | 0, // aux_output_enable; |
| 91 | 1, // aux_output_fundamental_enable; |
| 92 | 0, // mute_till_lock_enable; |
| 93 | 3, // output_power; |
| 94 | 0, // aux_output_power; |
| 95 | }; |
| 96 | |
| 97 | ad9739a_init_param default_ad9739a_init_param = { |
| 98 | /* SPI */ |
| 99 | 1, // spi_chip_select |
| 100 | SPI_MODE_0, // spi_mode |
| 101 | PS7_SPI, // spi_type |
| 102 | SPI_DEVICE_ID, // spi_device_id |
| 103 | /* Device settings */ |
| 104 | 0xF, // common_mode_voltage_dacclk_p |
| 105 | 0xF, // common_mode_voltage_dacclk_n |
| 106 | 20.0, // full_scale_current |
| 107 | }; |
| 108 | |
| 109 | /***************************************************************************//** |
| 110 | * @brief main |
| 111 | *******************************************************************************/ |
| 112 | int main(void) |
| 113 | { |
| 114 | adf4350_dev *adf4350_device; |
| 115 | ad9739a_dev *ad9739a_device; |
| 116 | |
| 117 | adf4350_setup(&adf4350_device, default_adf4350_init_param); |
| 118 | |
| 119 | dac_setup(XPAR_AXI_AD9739A_BASEADDR); |
| 120 | |
| 121 | ad9739a_setup(&ad9739a_device, default_ad9739a_init_param); |
| 122 | |
| 123 | dac_write(ADI_REG_CNTRL_2, ADI_DATA_FORMAT); |
| 124 | |
| 125 | dds_set_frequency(0, 300000000); |
| 126 | dds_set_phase(0, 0); |
| 127 | dds_set_scale(0, 250000); |
| 128 | |
| 129 | dds_set_frequency(1, 300000000); |
| 130 | dds_set_phase(1, 0); |
| 131 | dds_set_scale(1, 250000); |
| 132 | |
| 133 | printf("Done.\n"); |
| 134 | |
| 135 | return 0; |
| 136 | } |