Commit 13c589f2 authored by Florian Kaltenberger's avatar Florian Kaltenberger

Merge remote-tracking branch 'origin/fix-clock-source' into integration-develop-nr-2019w51

parents f2a54b34 17a53880
......@@ -2272,6 +2272,9 @@ void RCconfig_RU(void)
LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
}
}
else {
RC.ru[j]->openair0_cfg.clock_source = unset;
}
if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) {
if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) {
......
......@@ -106,7 +106,6 @@ int config_sync_var=-1;
#endif
volatile int oai_exit = 0;
static clock_source_t clock_source = internal;
static int wait_for_sync = 0;
unsigned int mmapped_dma=0;
......
......@@ -23,7 +23,6 @@
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \
{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \
{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \
{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \
{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \
......
......@@ -116,7 +116,7 @@ volatile int start_eNB = 0;
volatile int start_UE = 0;
volatile int oai_exit = 0;
static clock_source_t clock_source = internal;
static clock_source_t clock_source = unset;
int single_thread_flag=1;
static double snr_dB=20;
......
......@@ -65,7 +65,7 @@
{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \
{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"clock-source", CONFIG_HLP_EXCCLK, 0, iptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \
{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \
......
......@@ -135,6 +135,8 @@ typedef struct {
/*! \brief Clock source types */
typedef enum {
//! this means the paramter has not been set
unset=-1,
//! This tells the underlying hardware to use the internal reference
internal=0,
//! This tells the underlying hardware to use the external reference
......
......@@ -279,13 +279,16 @@ static int trx_usrp_start(openair0_device *device) {
s->usrp->set_gpio_attr("FP0", "DDR", 0x7f, 0x7f);
//set control register to ATR
s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0x7f);
//set ATR register
//set pins 4 (RX_TX_Switch) and 6 (Shutdown PA) to 1 when the radio is only receiving (ATR_RX)
s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f);
// set pin 5 (Shutdown LNA) to 1 when the radio is transmitting and receiveing (ATR_XX)
// (we use full duplex here, because our RX is on all the time - this might need to change later)
s->usrp->set_gpio_attr("FP0", "ATR_XX", (1<<5), 0x7f);
// init recv and send streaming
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
LOG_I(HW,"Time in secs now: %llu \n", s->usrp->get_time_now().to_ticks(s->sample_rate));
LOG_I(HW,"Time in secs last pps: %llu \n", s->usrp->get_time_last_pps().to_ticks(s->sample_rate));
if (s->use_gps == 1 || device->openair0_cfg[0].time_source == external) {
s->wait_for_first_pps = 1;
cmd.time_spec = s->usrp->get_time_last_pps() + uhd::time_spec_t(1.0);
......@@ -1007,25 +1010,34 @@ extern "C" {
s->usrp = uhd::usrp::multi_usrp::make(args);
if (args.find("clock_source")==std::string::npos) {
LOG_I(HW, "Using clock_source == '%d'\n", openair0_cfg[0].clock_source);
if (openair0_cfg[0].clock_source == internal) {
//in UHD 3.14 we could use
//s->usrp->set_sync_source("clock_source=internal","time_source=internal");
s->usrp->set_time_source("internal");
s->usrp->set_clock_source("internal");
} else if (openair0_cfg[0].clock_source == external ) {
//s->usrp->set_sync_source("clock_source=external","time_source=external");
s->usrp->set_time_source("external");
s->usrp->set_clock_source("external");
} else if (openair0_cfg[0].clock_source==gpsdo) {
s->usrp->set_clock_source("gpsdo");
s->usrp->set_time_source("gpsdo");
}
} else {
LOG_W(HW, "clock_source already specified in device arguments! Ignoring command line parameter\n");
if (openair0_cfg[0].clock_source == internal) {
//in UHD 3.14 we could use
//s->usrp->set_sync_source("clock_source=internal","time_source=internal");
s->usrp->set_time_source("internal");
s->usrp->set_clock_source("internal");
LOG_D(HW,"Setting time and clock source to internal\n");
}
else if (openair0_cfg[0].clock_source == external ) {
//s->usrp->set_sync_source("clock_source=external","time_source=external");
s->usrp->set_time_source("external");
s->usrp->set_clock_source("external");
LOG_D(HW,"Setting time and clock source to external\n");
}
else if (openair0_cfg[0].clock_source==gpsdo) {
s->usrp->set_clock_source("gpsdo");
s->usrp->set_time_source("gpsdo");
LOG_D(HW,"Setting time and clock source to gpsdo\n");
}
else {
LOG_W(HW,"Clock source set neither in usrp_args nor on command line, using default!\n");
}
}
else {
if (openair0_cfg[0].clock_source != unset) {
LOG_W(HW,"Clock source set in both usrp_args and in clock_source, ingnoring the latter!\n");
}
}
if (s->usrp->get_clock_source(0) == "gpsdo") {
s->use_gps = 1;
......
......@@ -146,7 +146,7 @@
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \
{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \
{"clock", CONFIG_HLP_CLK, 0, uptr:&clock_source, defintval:0, TYPE_UINT, 0}, \
{"clock-source", CONFIG_HLP_CLK, 0, iptr:&clock_source, defintval:0, TYPE_INT, 0}, \
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
{"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0} \
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment