/**************************************************************************//*** * @brief Sets the RX RF bandwidth [Hz]. * * @return None. *******************************************************************************/ void set_rx_rf_bandwidth(double* param, char param_no) // "rx_rf_bandwidth=" command { uint32_t bandwidth_hz; if(param_no >= 1) { bandwidth_hz = param[0]; ad9361_set_rx_rf_bandwidth(ad9361_phy, bandwidth_hz); console_print("rx_rf_bandwidth=%d\n", bandwidth_hz); } else show_invalid_param_message(1); }
/**************************************************************************//*** * @brief Sets the RX RF bandwidth [Hz]. * * @return None. *******************************************************************************/ void set_rx_rf_bandwidth(double* param, char param_no) // "rx_rf_bandwidth=" command { uint32_t bandwidth_hz; if (ad9361_phy==0) { console_print ("Error: no AD9361 device selected\n"); return; } if(param_no >= 1) { bandwidth_hz = param[0]; ad9361_set_rx_rf_bandwidth(ad9361_phy, bandwidth_hz); console_print("rx_rf_bandwidth=%d\n", bandwidth_hz); } else show_invalid_param_message(1); }
/***************************************************************************//** * @brief main *******************************************************************************/ int initAd9361(void) { int Status; uint64_t Value; uint8_t en_dis; /* * NOTE: The user has to choose the GPIO numbers according to desired * carrier board. The following configuration is valid for boards other * than the Fmcomms5. */ default_init_param.gpio_resetb = GPIO_RESET_PIN; default_init_param.gpio_sync = -1; default_init_param.gpio_cal_sw1 = -1; default_init_param.gpio_cal_sw2 = -1; /* * Initialize the GPIO */ gpio_init(GPIO_DEVICE_ID); gpio_direction(default_init_param.gpio_resetb, 1); /* * Initialize the SPI */ spi_init(SPI_DEVICE_ID, 1, 0); /* * Initialize AD9361 */ Status = ad9361_init(&ad9361_phy, &default_init_param); if (Status != 0) { xil_printf("Could not initialize AD9361\r\n"); xil_printf("Status\t%d\r\n", Status); return 1; } /* * Sampling frequency */ Status = ad9361_set_tx_sampling_freq(ad9361_phy, SAMPLING_FREQ); if (Status != 0) { xil_printf("Could not set Tx sampling freq.\r\n"); return 1; } Status = ad9361_set_rx_sampling_freq(ad9361_phy, SAMPLING_FREQ); if (Status != 0) { xil_printf("Could not set Rx sampling freq.\r\n"); return 1; } /* * Set Tx and Rx FIR */ Status = ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config); if (Status != 0) { xil_printf("Could not set Tx FIR\r\n"); return 1; } Status = ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config); if (Status != 0) { xil_printf("Could not set Rx FIR\r\n"); return 1; } // Enable both at the same time Status = ad9361_set_trx_fir_en_dis(ad9361_phy, 1); if (Status != 0) { xil_printf("Could not enable Tx and Rx FIR\r\n"); return 1; } // Check status Status = ad9361_get_tx_fir_en_dis(ad9361_phy, &en_dis); if (Status == 0) { xil_printf("Tx FIR status\t %d\r\n", en_dis); } else { xil_printf("Could not get Tx FIR enable\r\n"); return 1; } Status = ad9361_get_rx_fir_en_dis(ad9361_phy, &en_dis); if (Status == 0) { xil_printf("Rx FIR status\t %d\r\n", en_dis); } else { xil_printf("Could not get Rx FIR enable\r\n"); return 1; } /* * Rf bandwidth */ Status = ad9361_set_tx_rf_bandwidth(ad9361_phy, RF_BW); if (Status != 0) { xil_printf("Could not set Tx Rf bandwidth\r\n"); return 1; } Status = ad9361_set_rx_rf_bandwidth(ad9361_phy, RF_BW); if (Status != 0) { xil_printf("Could not set Rx Rf bandwidth\r\n"); return 1; } /* * Gain control mode */ Status = ad9361_set_rx_gain_control_mode(ad9361_phy, 0, RF_GAIN_SLOWATTACK_AGC); if (Status != 0) { xil_printf("Could not set Rx gain control mode for channel 0\r\n"); return 1; } /* * Hardware gains */ Status = ad9361_set_rx_rf_gain(ad9361_phy, 0, -10); if (Status != 0) { xil_printf("Could not set Rx gain for channel 0\r\n"); return 1; } Status = ad9361_get_rx_lo_freq(ad9361_phy, &Value); if (Status == 0) { xil_printf("LO Frequency\t %u \r\n", Value); } else { xil_printf("Could not get current LO frequency\r\n"); return 1; } #if ROE_CPRI_SINK == ROE_SINK_DAC dac_init(ad9361_phy, DATA_SEL_DMA, 1); #endif #ifndef AXI_ADC_NOT_PRESENT #if defined XILINX_PLATFORM && defined CAPTURE_SCRIPT // NOTE: To prevent unwanted data loss, it's recommended to invalidate // cache after each adc_capture() call, keeping in mind that the // size of the capture and the start address must be alinged to the size // of the cache line. mdelay(1000); adc_capture(16384, ADC_DDR_BASEADDR); Xil_DCacheInvalidateRange(ADC_DDR_BASEADDR, 16384); #endif #endif #ifdef CONSOLE_COMMANDS get_help(NULL, 0); while (1) { console_get_command(received_cmd); invalid_cmd = 0; for (cmd = 0; cmd < cmd_no; cmd++) { param_no = 0; cmd_type = console_check_commands(received_cmd, cmd_list[cmd].name, param, ¶m_no); if (cmd_type == UNKNOWN_CMD) { invalid_cmd++; } else { cmd_list[cmd].function(param, param_no); } } if (invalid_cmd == cmd_no) { console_print("Invalid command!\n"); } } #endif printf("AD9361 Initialization Done.\n"); #ifdef XILINX_PLATFORM Xil_DCacheDisable(); Xil_ICacheDisable(); #endif return 0; }