Commit 54f5383e authored by 111's avatar 111

modify to oxgrf

parent deb31add
trx
.vscode/
\ No newline at end of file
......@@ -38,21 +38,22 @@
#include "common_lib.h"
#include "assertions.h"
#include "load_module_shlib.h"
#include "common/utils/load_module_shlib.h"
#include "common/utils/LOG/log.h"
//#include "targets/RT/USER/lte-softmodem.h"
#include "executables/softmodem-common.h"
const char* devtype_names[MAX_RF_DEV_TYPE] = {
"",
"EXMIMO",
"USRP B200",
"USRP X300",
"USRP N300",
"USRP X400",
"BLADERF",
"YunSDR",
"OXGRF_DEV",
"LMSSDR",
"IRIS",
"No HW",
"ADRV9371_ZC706",
"UEDv2",
"RFSIMULATOR"
};
......
......@@ -35,8 +35,6 @@
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
//#include <openair1/PHY/TOOLS/tools_defs.h>
//#include "record_player.h"
/* default name of shared library implementing the radio front end */
#define OAI_RF_LIBNAME "oai_device"
......@@ -47,6 +45,7 @@
/* name of shared library implementing the rf simulator */
#define OAI_RFSIM_LIBNAME "rfsimulator"
/* name of shared library implementing the iq player */
#define OAI_IQPLAYER_LIBNAME "oai_iqplayer"
/* flags for BBU to determine whether the attached radio head is local or remote */
#define RAU_LOCAL_RADIO_HEAD 0
......@@ -81,8 +80,6 @@ typedef enum {
*/
typedef enum {
MIN_RF_DEV_TYPE = 0,
/*!\brief device is ExpressMIMO */
EXMIMO_DEV,
/*!\brief device is USRP B200/B210*/
USRP_B200_DEV,
/*!\brief device is USRP X300/X310*/
......@@ -93,16 +90,14 @@ typedef enum {
USRP_X400_DEV,
/*!\brief device is BLADE RF*/
BLADERF_DEV,
/*!\brief device is YUNSDR pcie*/
YUNSDR_DEV,
/*!\brief device is OXGRF pcie*/
OXGRF_DEV,
/*!\brief device is LMSSDR (SoDeRa)*/
LMSSDR_DEV,
/*!\brief device is Iris */
IRIS_DEV,
/*!\brief device is NONE*/
NONE_DEV,
/*!\brief device is ADRV9371_ZC706 */
ADRV9371_ZC706_DEV,
/*!\brief device is UEDv2 */
UEDv2_DEV,
RFSIMULATOR,
......@@ -154,6 +149,13 @@ typedef enum {
gpsdo=2
} clock_source_t;
/*! \brief Radio Tx burst flags */
typedef enum {
Invalid = 0,
MiddleOfBurst,
StartOfBurst,
EndOfBurst
} radio_tx_flag_t;
/*! \brief RF frontend parameters set by application */
typedef struct {
......@@ -179,9 +181,15 @@ typedef struct {
int rx_num_channels;
//! number of TX channels (=TX antennas)
int tx_num_channels;
//! rx daughter card
char* rx_subdev;
//! tx daughter card
char* tx_subdev;
//! \brief RX base addresses for mmapped_dma
int32_t *rxbase[4];
//! \brief TX base addresses for mmapped_dma
//! \brief RX buffer size for direct access
int rxsize;
//! \brief TX base addresses for mmapped_dma or direct access
int32_t *txbase[4];
//! \brief Center frequency in Hz for RX.
//! index: [0..rx_num_channels[
......@@ -212,7 +220,6 @@ typedef struct {
//! timing_source
clock_source_t time_source;
//! Manual SDR IP address
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_YUNSDR)
char *sdr_addrs;
//! Auto calibration flag
int autocal[4];
......@@ -247,6 +254,10 @@ typedef struct {
int nr_band;
//! NR scs for raster
int nr_scs_for_raster;
//! Core IDs for RX FH
int rxfh_cores[4];
//! Core IDs for TX FH
int txfh_cores[4];
} openair0_config_t;
/*! \brief RF mapping */
......@@ -311,8 +322,23 @@ typedef struct {
pthread_cond_t cond_write;
/// mutex for trx write thread
pthread_mutex_t mutex_write;
/// to inform the thread to exit
int write_thread_exit;
} openair0_thread_t;
typedef struct fhstate_s {
openair0_timestamp TS[8];
openair0_timestamp TS0;
openair0_timestamp olddeltaTS[8];
openair0_timestamp oldTS[8];
openair0_timestamp TS_read;
int first_read;
uint32_t *buff[8];
uint32_t buff_size;
int r[8];
int active;
} fhstate_t;
/*!\brief structure holds the parameters to configure USRP devices */
struct openair0_device_t {
/*!tx write thread*/
......@@ -338,7 +364,6 @@ struct openair0_device_t {
/* !brief ETH params set by application */
eth_params_t *eth_params;
/* !brief Indicates if device already initialized */
int is_init;
......@@ -346,6 +371,18 @@ struct openair0_device_t {
/*!brief Can be used by driver to hold internal structure*/
void *priv;
/*!brief pointer to FH state, used in ECPRI split 8*/
fhstate_t fhstate;
/*!brief Used in ECPRI split 8 to indicate numerator of sampling rate ratio*/
int sampling_rate_ratio_n;
/*!brief Used in ECPRI split 8 to indicate denominator of sampling rate ratio*/
int sampling_rate_ratio_d;
/*!brief Used in ECPRI split 8 to indicate the TX/RX timing offset*/
int txrx_offset;
/* Functions API, which are called by the application*/
/*! \brief Called to start the transceiver. Return 0 if OK, < 0 if error
......@@ -380,7 +417,7 @@ struct openair0_device_t {
@param buff Buffer which holds the samples (2 dimensional)
@param nsamps number of samples to be sent
@param number of antennas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
@param flags flags must be set to true if timestamp parameter needs to be applied
*/
int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int antenna_id, int flags);
......@@ -390,9 +427,9 @@ struct openair0_device_t {
@param buff Buffer which holds the samples (1 dimensional)
@param nsamps number of samples to be sent
@param antenna_id index of the antenna if the device has multiple anteannas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
@param flags flags must be set to true if timestamp parameter needs to be applied
*/
int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void *buff, int nsamps,int antenna_id, int flags);
int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void **buff, int fd_ind,int nsamps, int flags,int nant);
/*! \brief Receive samples from hardware.
* Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
......@@ -414,12 +451,13 @@ struct openair0_device_t {
* was received.
* \param device the hardware to use
* \param[out] ptimestamp the time at which the first sample was received.
* \param[out] buff A pointers to a buffer for received samples. The buffer must be large enough to hold the number of samples \ref nsamps.
* \param[out] buff A pointer to a buffer[ant_id][] for received samples. The buffer[ant_id] must be large enough to hold the number of samples \ref nsamps * the number of packets.
* \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
* \param packet_idx offset into
* \param antenna_id Index of antenna from which samples were received
* \returns the number of sample read
*/
int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, void *buff, int nsamps,int *antenna_id);
int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, uint32_t **buff, int nsamps);
/*! \brief print the device statistics
* \param device the hardware to use
......@@ -447,10 +485,9 @@ struct openair0_device_t {
/*! \brief Set RX feaquencies
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
* \param exmimo_dump_config dump EXMIMO configuration
* \returns 0 in success
*/
int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg);
/*! \brief Set gains
* \param device the hardware to use
......@@ -468,6 +505,7 @@ struct openair0_device_t {
/*! \brief Pointer to generic RRU private information
*/
void *thirdparty_priv;
/*! \brief Callback for Third-party RRU Initialization routine
......@@ -494,6 +532,8 @@ struct openair0_device_t {
* \return a pointer to the parameter
*/
void *(*get_internal_parameter)(char *id);
/* \brief timing statistics for TX fronthaul (ethernet)
*/
};
/* type of device init function, implemented in shared lib */
......@@ -563,9 +603,6 @@ openair0_timestamp get_usrp_time(openair0_device *device);
*/
int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg);
/*! \brief store recorded iqs from memory to file. */
extern void iqrecorder_end(openair0_device *device);
#include <unistd.h>
#ifndef gettid
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
/** oxgrf_lib.c
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/** yunsdr_lib.c
*
* Author: eric
* base on bladerf_lib.c
* Author: openxg
*/
......@@ -33,10 +11,9 @@
#include <string.h>
#include <inttypes.h>
#include <math.h>
#include "yunsdr_lib.h"
#include "rf_helper.h"
#include "oxgrf_lib.h"
/** @addtogroup _YUNSDR_PHY_RF_INTERFACE_
/** @addtogroup _OXGRF_PHY_RF_INTERFACE_
* @{
*/
......@@ -48,11 +25,7 @@
# include <immintrin.h>
#endif
#ifdef __aarch64__
#include <arm_neon.h>
#endif
//! Number of YUNSDR devices
//! Number of OXGRF devices
int num_devices = 0;
#ifdef __GNUC__
static int recving = 0;
......@@ -60,7 +33,7 @@ static int transmiting = 0;
#endif
static bool running = false;
#define RX_MTU 15360 //30720
#define RX_MTU 30720
#define BUFFER_SIZE (122880 * 10 * sizeof(int))
#define NCHAN_PER_DEV 4
static void *cache_buf[NCHAN_PER_DEV];
......@@ -88,26 +61,26 @@ static inline int channel_to_mask(int channel_count)
/*! \brief get current timestamp
*\param device the hardware to use
*\returns timestamp of YunSDR
*\returns timestamp of OXGRF
*/
openair0_timestamp trx_get_timestamp(openair0_device *device) {
return 0;
}
/*! \brief Start yunsdr
/*! \brief Start oxgrf
* \param device the hardware to use
* \returns 0 on success
*/
int trx_yunsdr_start(openair0_device *device) {
int trx_oxgrf_start(openair0_device *device) {
printf("[yunsdr] Start yunsdr ...\n");
printf( "[oxgrf] Start oxgrf ...\n");
running = true;
return 0;
}
/*! \brief Called to send samples to the yunsdr RF target
/*! \brief Called to send samples to the oxgrf RF target
\param device pointer to the device structure specific to the RF hardware target
\param timestamp The timestamp at whicch the first sample MUST be sent
\param buff Buffer which holds the samples
......@@ -116,10 +89,10 @@ int trx_yunsdr_start(openair0_device *device) {
\param flags Ignored for the moment
\returns 0 on success
*/
static int trx_yunsdr_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
static int trx_oxgrf_write(openair0_device *device,openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
int status;
yunsdr_state_t *yunsdr = (yunsdr_state_t*)device->priv;
oxgrf_state_t *oxgrf = (oxgrf_state_t*)device->priv;
#ifdef __GNUC__
__sync_fetch_and_add(&transmiting, 1);
......@@ -136,15 +109,15 @@ static int trx_yunsdr_write(openair0_device *device,openair0_timestamp timestamp
iq += 16;
len -= 16;
}
#elif defined(__arm__) || defined(__aarch64__)
int16x8_t a, *b;
#else
__m128i a, *b;
int len = nsamps * 2;
int16_t *iq = buff[0];
while (len >= 8) {
a = *(int16x8_t *)&iq[0];
b = (int16x8_t *)&iq[0];
*b = vshlq_n_s16(a, 4);
a = *(__m128i *)&iq[0];
b = (__m128i *)&iq[0];
*b = _mm_slli_epi16(a, 4);
iq += 8;
len -= 8;
}
......@@ -156,10 +129,10 @@ static int trx_yunsdr_write(openair0_device *device,openair0_timestamp timestamp
len--;
}
status = yunsdr_write_samples_multiport(yunsdr->dev, (const void **)buff, nsamps, channel_to_mask(yunsdr->tx_num_channels), timestamp, 0);
status = oxgrf_write_samples_multiport(oxgrf->dev, (const void **)buff, nsamps, channel_to_mask(oxgrf->tx_num_channels), timestamp, 0);
if (status < 0) {
yunsdr->num_tx_errors++;
printf("[yunsdr] Failed to TX samples\n");
oxgrf->num_tx_errors++;
printf("[oxgrf] Failed to TX samples\n");
exit(-1);
}
#ifdef __GNUC__
......@@ -167,9 +140,9 @@ static int trx_yunsdr_write(openair0_device *device,openair0_timestamp timestamp
#endif
//LOG_D(HW, "Provided TX timestamp: %u, nsamps: %u\n", ptimestamp, nsamps);
yunsdr->tx_current_ts = timestamp;
yunsdr->tx_nsamps += nsamps;
yunsdr->tx_count++;
oxgrf->tx_current_ts = timestamp;
oxgrf->tx_nsamps += nsamps;
oxgrf->tx_count++;
return nsamps;
}
......@@ -185,10 +158,10 @@ static int trx_yunsdr_write(openair0_device *device,openair0_timestamp timestamp
* \param cc Index of component carrier
* \returns number of samples read
*/
static int trx_yunsdr_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
static int trx_oxgrf_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
int status;
yunsdr_state_t *yunsdr = (yunsdr_state_t *)device->priv;
oxgrf_state_t *oxgrf = (oxgrf_state_t *)device->priv;
uint64_t timestamp = 0L;
#ifdef __GNUC__
......@@ -202,32 +175,32 @@ static int trx_yunsdr_read(openair0_device *device, openair0_timestamp *ptimesta
else
recv = nsamps;
timestamp = 0L;
status = yunsdr_read_samples_multiport(yunsdr->dev, iq_buf, recv, channel_to_mask(yunsdr->rx_num_channels), &timestamp);
status = oxgrf_read_samples_multiport(oxgrf->dev, iq_buf, recv, channel_to_mask(oxgrf->rx_num_channels), &timestamp);
if (status < 0) {
printf("[yunsdr] Failed to read samples %d\n", nsamps);
yunsdr->num_rx_errors++;
printf("[oxgrf] Failed to read samples %d\n", nsamps);
oxgrf->num_rx_errors++;
exit(-1);
}
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memcpy(buff[i], iq_buf[i], nsamps * 4);
if(recv > nsamps) {
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memcpy(cache_buf[i], iq_buf[i] + nsamps * 4, (recv - nsamps) * 4);
remain = recv - nsamps;
}
*(uint64_t *)ptimestamp = timestamp;
yunsdr->rx_current_ts = timestamp + nsamps;
oxgrf->rx_current_ts = timestamp + nsamps;
//LOG_D(HW, "case 0: Current RX timestamp %"PRIu64", hw ts %"PRIu64", nsamps %u, remain %u, recv: %u\n", *ptimestamp, timestamp, nsamps, remain, recv);
} else if(remain >= nsamps) {
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memcpy(buff[i], cache_buf[i], nsamps * 4);
remain -= nsamps;
if(remain > 0) {
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memmove(cache_buf[i], cache_buf[i] + nsamps * 4, remain * 4);
}
*(uint64_t *)ptimestamp = yunsdr->rx_current_ts;
yunsdr->rx_current_ts += nsamps;
*(uint64_t *)ptimestamp = oxgrf->rx_current_ts;
oxgrf->rx_current_ts += nsamps;
//LOG_D(HW, "case 1: Current RX timestamp %"PRIu64", nsamps %u, remain %u\n", *ptimestamp, nsamps, remain);
} else {
int recv;
......@@ -236,27 +209,27 @@ static int trx_yunsdr_read(openair0_device *device, openair0_timestamp *ptimesta
else
recv = (nsamps / RX_MTU + 1) * RX_MTU;
timestamp = 0L;
status = yunsdr_read_samples_multiport(yunsdr->dev, iq_buf, recv, channel_to_mask(yunsdr->rx_num_channels), &timestamp);
status = oxgrf_read_samples_multiport(oxgrf->dev, iq_buf, recv, channel_to_mask(oxgrf->rx_num_channels), &timestamp);
if (status < 0) {
printf("[yunsdr] Failed to read samples %d\n", nsamps);
yunsdr->num_rx_errors++;
printf("[oxgrf] Failed to read samples %d\n", nsamps);
oxgrf->num_rx_errors++;
exit(-1);
}
if(timestamp != (yunsdr->rx_current_ts + remain)) {
int overflow = timestamp - (yunsdr->rx_current_ts + remain);
//printf("Rx overflow %u samples\n", overflow);
if(timestamp != (oxgrf->rx_current_ts + remain)) {
int overflow = timestamp - (oxgrf->rx_current_ts + remain);
//LOG_W(HW, "Rx overflow %u samples\n", overflow);
remain += overflow;
}
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memcpy(cache_buf[i] + remain * 4, iq_buf[i], recv * 4);
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memcpy(buff[i], cache_buf[i], nsamps * 4);
remain = recv + remain - nsamps;
for(int i = 0; i < yunsdr->rx_num_channels; i++)
for(int i = 0; i < oxgrf->rx_num_channels; i++)
memmove(cache_buf[i], cache_buf[i] + nsamps * 4, remain * 4);
*(uint64_t *)ptimestamp = yunsdr->rx_current_ts;
yunsdr->rx_current_ts += nsamps;
*(uint64_t *)ptimestamp = oxgrf->rx_current_ts;
oxgrf->rx_current_ts += nsamps;
//LOG_D(HW, "case 2: Current RX timestamp %"PRIu64", hw ts %"PRIu64", nsamps %u, remain %u, recv: %u\n", *ptimestamp, timestamp, nsamps, remain, recv);
}
......@@ -264,19 +237,19 @@ static int trx_yunsdr_read(openair0_device *device, openair0_timestamp *ptimesta
__sync_fetch_and_sub(&recving, 1);
#endif
//LOG_D(HW, "Current RX timestamp %"PRIu64", nsamps %u\n", *ptimestamp, nsamps);
yunsdr->rx_nsamps += nsamps;
yunsdr->rx_count++;
oxgrf->rx_nsamps += nsamps;
oxgrf->rx_count++;
return nsamps;
}
/*! \brief Terminate operation of the yunsdr transceiver -- free all associated resources
/*! \brief Terminate operation of the oxgrf transceiver -- free all associated resources
* \param device the hardware to use
*/
void trx_yunsdr_end(openair0_device *device) {
void trx_oxgrf_end(openair0_device *device) {
yunsdr_state_t *yunsdr = (yunsdr_state_t*)device->priv;
oxgrf_state_t *oxgrf = (oxgrf_state_t*)device->priv;
if(!running)
return;
......@@ -289,38 +262,38 @@ void trx_yunsdr_end(openair0_device *device) {
#endif
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
uint32_t count = 0;
yunsdr_get_channel_event(yunsdr->dev, TX_CHANNEL_TIMEOUT, 1, &count);
printf("[yunsdr] TX%d Channel timeout: %u\n", 1, count);
yunsdr_get_channel_event(yunsdr->dev, RX_CHANNEL_OVERFLOW, 1, &count);
printf("[yunsdr] RX%d Channel overflow: %u\n", 1, count);
oxgrf_get_channel_event(oxgrf->dev, TX_CHANNEL_TIMEOUT, 1, &count);
printf("[oxgrf] TX%d Channel timeout: %u\n", 1, count);
oxgrf_get_channel_event(oxgrf->dev, RX_CHANNEL_OVERFLOW, 1, &count);
printf("[oxgrf] RX%d Channel overflow: %u\n", 1, count);
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
yunsdr_close_device(yunsdr->dev);
oxgrf_close_device(oxgrf->dev);
//exit(1);
}
/*! \brief print the yunsdr statistics
/*! \brief print the oxgrf statistics
* \param device the hardware to use
* \returns 0 on success
*/
int trx_yunsdr_get_stats(openair0_device* device) {
int trx_oxgrf_get_stats(openair0_device* device) {
return(0);
}
/*! \brief Reset the yunsdr statistics
/*! \brief Reset the oxgrf statistics
* \param device the hardware to use
* \returns 0 on success
*/
int trx_yunsdr_reset_stats(openair0_device* device) {
int trx_oxgrf_reset_stats(openair0_device* device) {
return(0);
}
/*! \brief Stop yunsdr
/*! \brief Stop oxgrf
* \param card the hardware to use
* \returns 0 in success
*/
int trx_yunsdr_stop(openair0_device* device) {
int trx_oxgrf_stop(openair0_device* device) {
return(0);
}
......@@ -330,21 +303,21 @@ int trx_yunsdr_stop(openair0_device* device) {
* \param exmimo_dump_config (ignored)
* \returns 0 in success
*/
int trx_yunsdr_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1,int exmimo_dump_config) {
int trx_oxgrf_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1) {
int status;
yunsdr_state_t *yunsdr = (yunsdr_state_t *)device->priv;
oxgrf_state_t *oxgrf = (oxgrf_state_t *)device->priv;
openair0_config_t *openair0_cfg = (openair0_config_t *)device->openair0_cfg;
if ((status = yunsdr_set_tx_lo_freq(yunsdr->dev, 0, (uint64_t)(openair0_cfg->tx_freq[0]))) < 0) {
printf("[yunsdr] Failed to set TX frequency\n");
if ((status = oxgrf_set_tx_lo_freq(oxgrf->dev, 0, (uint64_t)(openair0_cfg->tx_freq[0]))) < 0) {
printf("[oxgrf] Failed to set TX frequency\n");
} else
printf("[yunsdr] set TX frequency to %lu\n",(uint64_t)(openair0_cfg->tx_freq[0]));
printf("[oxgrf] set TX frequency to %lu\n",(uint64_t)(openair0_cfg->tx_freq[0]));
if ((status = yunsdr_set_rx_lo_freq(yunsdr->dev, 0, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[yunsdr] Failed to set RX frequency\n");
if ((status = oxgrf_set_rx_lo_freq(oxgrf->dev, 0, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[oxgrf] Failed to set RX frequency\n");
} else
printf("[yunsdr] set RX frequency to %lu\n",(uint64_t)(openair0_cfg->rx_freq[0]));
printf("[oxgrf] set RX frequency to %lu\n",(uint64_t)(openair0_cfg->rx_freq[0]));
return(0);
......@@ -355,46 +328,46 @@ int trx_yunsdr_set_freq(openair0_device* device, openair0_config_t *openair0_cfg
* \param openair0_cfg openair0 Config structure
* \returns 0 in success
*/
int trx_yunsdr_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) {
int trx_oxgrf_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) {
int ret = 0;
yunsdr_state_t *yunsdr = (yunsdr_state_t *)device->priv;
oxgrf_state_t *oxgrf = (oxgrf_state_t *)device->priv;
if (openair0_cfg->rx_gain[0] > 65+openair0_cfg->rx_gain_offset[0]) {
printf("[yunsdr] Reduce RX Gain 0 by %f dB\n", openair0_cfg->rx_gain[0] - openair0_cfg->rx_gain_offset[0] - 65);
printf("[oxgrf] Reduce RX Gain 0 by %f dB\n", openair0_cfg->rx_gain[0] - openair0_cfg->rx_gain_offset[0] - 65);
return -1;
}
if ((ret = yunsdr_set_rx1_rf_gain(yunsdr->dev, 0, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[yunsdr] Failed to set RX1 gain\n");
if ((ret = oxgrf_set_rx1_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[oxgrf] Failed to set RX1 gain\n");
} else
printf("[yunsdr] set RX1 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[0]));
printf("[oxgrf] set RX1 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[0]));
if(yunsdr->rx_num_channels > 1) {
if ((ret = yunsdr_set_rx2_rf_gain(yunsdr->dev, 0, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[yunsdr] Failed to set RX2 gain\n");
if(oxgrf->rx_num_channels > 1) {
if ((ret = oxgrf_set_rx2_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[oxgrf] Failed to set RX2 gain\n");
} else
printf("[yunsdr] set RX gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[1]));
printf("[oxgrf] set RX gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[1]));
}
int tx_gain = ((uint32_t)openair0_cfg->tx_gain[0] > 90?90:(uint32_t)openair0_cfg->tx_gain[0]);
if ((ret = yunsdr_set_tx1_attenuation(yunsdr->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[yunsdr] Failed to set TX1 gain\n");
if ((ret = oxgrf_set_tx1_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX1 gain\n");
} else
printf("[yunsdr] set the TX1 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[0]);
printf("[oxgrf] set the TX1 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[0]);
if(yunsdr->tx_num_channels > 1) {
if(oxgrf->tx_num_channels > 1) {
tx_gain = ((uint32_t)openair0_cfg->tx_gain[1] > 90?90:(uint32_t)openair0_cfg->tx_gain[1]);
if ((ret = yunsdr_set_tx2_attenuation(yunsdr->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[yunsdr] Failed to set TX2 gain\n");
if ((ret = oxgrf_set_tx2_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX2 gain\n");
} else
printf("[yunsdr] set the TX2 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[1]);
printf("[oxgrf] set the TX2 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[1]);
}
return(ret);
}
/*! \brief Initialize Openair yunsdr target. It returns 0 if OK
/*! \brief Initialize Openair oxgrf target. It returns 0 if OK
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
* \returns 0 on success
......@@ -403,13 +376,18 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
int status;
yunsdr_state_t *yunsdr = (yunsdr_state_t*)malloc(sizeof(yunsdr_state_t));
memset(yunsdr, 0, sizeof(yunsdr_state_t));
oxgrf_state_t *oxgrf = (oxgrf_state_t*)malloc(sizeof(oxgrf_state_t));
printf("[yunsdr] openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs);
printf("[yunsdr] openair0_cfg[0].rx_num_channels == '%d'\n", openair0_cfg[0].rx_num_channels);
printf("[yunsdr] openair0_cfg[0].tx_num_channels == '%d'\n", openair0_cfg[0].tx_num_channels);
memset(oxgrf, 0, sizeof(oxgrf_state_t));
printf("[oxgrf] openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs);
printf("[oxgrf] openair0_cfg[0].rx_num_channels == '%d'\n", openair0_cfg[0].rx_num_channels);
printf("[oxgrf] openair0_cfg[0].tx_num_channels == '%d'\n", openair0_cfg[0].tx_num_channels);
printf("[oxgrf] oxgrf->sample_rate == '%d'\n", oxgrf->sample_rate);
printf("[oxgrf] openair0_cfg->sample_rate == '%f'\n", openair0_cfg->sample_rate);
oxgrf->sample_rate = (unsigned int)openair0_cfg->sample_rate;
oxgrf->sample_rate = 30720000;
// return 0;
// init required params
switch ((int)openair0_cfg->sample_rate) {
case 122880000:
......@@ -449,17 +427,16 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
openair0_cfg[0].rx_bw = 1.25e6;
break;
default:
printf("[yunsdr] Error: unknown sampling rate %f\n", openair0_cfg->sample_rate);
free(yunsdr);
printf("[oxgrf] Error: unknown sampling rate %f\n", openair0_cfg->sample_rate);
free(oxgrf);
exit(-1);
break;
}
//openair0_cfg->iq_txshift = 2;
//openair0_cfg->iq_rxrescale = 14; /*not sure*/ //FIXME: adjust to yunsdr
yunsdr->sample_rate = (unsigned int)openair0_cfg->sample_rate;
printf("[yunsdr] sampling_rate %d\n", yunsdr->sample_rate);
yunsdr->rx_num_channels = openair0_cfg[0].rx_num_channels;
yunsdr->tx_num_channels = openair0_cfg[0].tx_num_channels;
//openair0_cfg->iq_rxrescale = 14; /*not sure*/ //FIXME: adjust to oxgrf
printf("[oxgrf] sampling_rate %d\n", oxgrf->sample_rate);
oxgrf->rx_num_channels = openair0_cfg[0].rx_num_channels;
oxgrf->tx_num_channels = openair0_cfg[0].tx_num_channels;
int auxdac1 = 0;
char args[64];
......@@ -476,7 +453,7 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
copy_subdev_string(dev_str, dev_ptr + strlen(dev_arg));
remove_substring(args, dev_arg);
remove_substring(args, dev_str);
printf("[yunsdr] Using %s\n", dev_str);
printf("[oxgrf] Using %s\n", dev_str);
}
const char auxdac1_arg[] = "auxdac1=";
......@@ -487,109 +464,109 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
remove_substring(args, auxdac1_arg);
remove_substring(args, auxdac1_str);
auxdac1 = atoi(auxdac1_str);
printf("[yunsdr] Setting auxdac1:%u\n", auxdac1);
printf("[oxgrf] Setting auxdac1:%u\n", auxdac1);
}
if ((yunsdr->dev = yunsdr_open_device(dev_str)) == NULL ) {
printf("[yunsdr] Failed to open yunsdr\n");
free(yunsdr);
if ((oxgrf->dev = oxgrf_open_device(dev_str)) == NULL ) {
printf("[oxgrf] Failed to open oxgrf\n");
free(oxgrf);
return -1;
}
printf("[yunsdr] Initializing openair0_device\n");
printf("[oxgrf] Initializing openair0_device\n");
switch (openair0_cfg[0].clock_source) {
case external:
printf("[yunsdr] clock_source: external\n");
yunsdr_set_ref_clock (yunsdr->dev, 0, EXTERNAL_REFERENCE);
yunsdr_set_pps_select (yunsdr->dev, 0, PPS_EXTERNAL_EN);
printf("[oxgrf] clock_source: external\n");
oxgrf_set_ref_clock (oxgrf->dev, 0, EXTERNAL_REFERENCE);
oxgrf_set_pps_select (oxgrf->dev, 0, PPS_EXTERNAL_EN);
break;
case gpsdo:
printf("[yunsdr] clock_source: gpsdo\n");
printf("[oxgrf] clock_source: gpsdo\n");
break;
case internal:
default:
yunsdr_set_ref_clock (yunsdr->dev, 0, INTERNAL_REFERENCE);
yunsdr_set_pps_select (yunsdr->dev, 0, PPS_INTERNAL_EN);
//yunsdr_set_vco_select (yunsdr->dev, 0, AUXDAC1);
printf("[yunsdr] clock_source: internal\n");
oxgrf_set_ref_clock (oxgrf->dev, 0, INTERNAL_REFERENCE);
oxgrf_set_pps_select (oxgrf->dev, 0, PPS_INTERNAL_EN);
//oxgrf_set_vco_select (oxgrf->dev, 0, AUXDAC1);
printf("[oxgrf] clock_source: internal\n");
break;
}
yunsdr_set_auxdac1 (yunsdr->dev, 0, auxdac1);
yunsdr_set_duplex_select (yunsdr->dev, 0, FDD);
yunsdr_set_trxsw_fpga_enable(yunsdr->dev, 0, 0);
yunsdr_set_rx_ant_enable (yunsdr->dev, 0, 1);
yunsdr_set_tx_fir_en_dis (yunsdr->dev, 0, 0);
yunsdr_set_rx_fir_en_dis (yunsdr->dev, 0, 0);
oxgrf_set_auxdac1 (oxgrf->dev, 0, auxdac1);
oxgrf_set_duplex_select (oxgrf->dev, 0, FDD);
oxgrf_set_trxsw_fpga_enable(oxgrf->dev, 0, 0);
oxgrf_set_rx_ant_enable (oxgrf->dev, 0, 1);
oxgrf_set_tx_fir_en_dis (oxgrf->dev, 0, 0);
oxgrf_set_rx_fir_en_dis (oxgrf->dev, 0, 0);
// RX port Initialize
if ((status = yunsdr_set_rx_lo_freq(yunsdr->dev, 0, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[yunsdr] Failed to set RX frequency\n");
if ((status = oxgrf_set_rx_lo_freq(oxgrf->dev, 0, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[oxgrf] Failed to set RX frequency\n");
} else
printf("[yunsdr] set RX frequency to %lu\n",(uint64_t)(openair0_cfg->rx_freq[0]));
if ((status = yunsdr_set_rx_sampling_freq(yunsdr->dev, 0, (uint32_t)(openair0_cfg->sample_rate))) < 0) {
printf("[yunsdr] Failed to set RX sample rate\n");
printf("[oxgrf] set RX frequency to %lu\n",(uint64_t)(openair0_cfg->rx_freq[0]));
if ((status = oxgrf_set_rx_sampling_freq(oxgrf->dev, 0, (uint32_t)(openair0_cfg->sample_rate))) < 0) {
printf("[oxgrf] Failed to set RX sample rate\n");
} else
printf("[yunsdr] set RX sample rate to %u\n", (uint32_t)(openair0_cfg->sample_rate));
if ((status = yunsdr_set_rx_rf_bandwidth(yunsdr->dev, 0, (uint32_t)(openair0_cfg->rx_bw))) < 0) {
printf("[yunsdr] Failed to set RX bandwidth\n");
printf("[oxgrf] set RX sample rate to %u\n", (uint32_t)(openair0_cfg->sample_rate));
if ((status = oxgrf_set_rx_rf_bandwidth(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_bw))) < 0) {
printf("[oxgrf] Failed to set RX bandwidth\n");
} else
printf("[yunsdr] set RX bandwidth to %u\n",(uint32_t)(openair0_cfg->rx_bw));
printf("[oxgrf] set RX bandwidth to %u\n",(uint32_t)(openair0_cfg->rx_bw));
if ((status = yunsdr_set_rx1_gain_control_mode(yunsdr->dev, 0, 0)) < 0){
printf("[yunsdr] Failed to set RX1 Gain Control Mode\n");
if ((status = oxgrf_set_rx1_gain_control_mode(oxgrf->dev, 0, 0)) < 0){
printf("[oxgrf] Failed to set RX1 Gain Control Mode\n");
} else
printf("[yunsdr] set RX1 Gain Control Mode MGC\n");
printf("[oxgrf] set RX1 Gain Control Mode MGC\n");
if ((status = yunsdr_set_rx1_rf_gain(yunsdr->dev, 0, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[yunsdr] Failed to set RX1 gain\n");
if ((status = oxgrf_set_rx1_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[oxgrf] Failed to set RX1 gain\n");
} else
printf("[yunsdr] set RX1 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[0]));
printf("[oxgrf] set RX1 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[0]));
if(yunsdr->rx_num_channels > 1) {
if ((status = yunsdr_set_rx2_gain_control_mode(yunsdr->dev, 0, 0)) < 0){
printf("[yunsdr] Failed to set RX2 Gain Control Mode\n");
if(oxgrf->rx_num_channels > 1) {
if ((status = oxgrf_set_rx2_gain_control_mode(oxgrf->dev, 0, 0)) < 0){
printf("[oxgrf] Failed to set RX2 Gain Control Mode\n");
} else
printf("[yunsdr] set RX2 Gain Control Mode MGC\n");
printf("[oxgrf] set RX2 Gain Control Mode MGC\n");
if ((status = yunsdr_set_rx2_rf_gain(yunsdr->dev, 0, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[yunsdr] Failed to set RX2 gain\n");
if ((status = oxgrf_set_rx2_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[oxgrf] Failed to set RX2 gain\n");
} else
printf("[yunsdr] set RX2 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[1]));
printf("[oxgrf] set RX2 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[1]));
}
// TX port Initialize
if ((status = yunsdr_set_tx_lo_freq(yunsdr->dev, 0, (uint64_t)openair0_cfg->tx_freq[0])) < 0) {
printf("[yunsdr] Failed to set TX frequency\n");
if ((status = oxgrf_set_tx_lo_freq(oxgrf->dev, 0, (uint64_t)openair0_cfg->tx_freq[0])) < 0) {
printf("[oxgrf] Failed to set TX frequency\n");
} else
printf("[yunsdr] set TX Frequency to %lu\n", (uint64_t)openair0_cfg->tx_freq[0]);
printf("[oxgrf] set TX Frequency to %lu\n", (uint64_t)openair0_cfg->tx_freq[0]);
if ((status = yunsdr_set_tx_sampling_freq(yunsdr->dev, 0, (uint32_t)openair0_cfg->sample_rate)) < 0) {
printf("[yunsdr] Failed to set TX sample rate\n");
if ((status = oxgrf_set_tx_sampling_freq(oxgrf->dev, 0, (uint32_t)openair0_cfg->sample_rate)) < 0) {
printf("[oxgrf] Failed to set TX sample rate\n");
} else
printf("[yunsdr] set TX sampling rate to %u\n", (uint32_t)openair0_cfg->sample_rate);
printf("[oxgrf] set TX sampling rate to %u\n", (uint32_t)openair0_cfg->sample_rate);
if ((status = yunsdr_set_tx_rf_bandwidth(yunsdr->dev, 0, (uint32_t)openair0_cfg->tx_bw)) <0) {
printf("[yunsdr] Failed to set TX bandwidth\n");
if ((status = oxgrf_set_tx_rf_bandwidth(oxgrf->dev, 0, (uint32_t)openair0_cfg->tx_bw)) <0) {
printf("[oxgrf] Failed to set TX bandwidth\n");
} else
printf("[yunsdr] set TX bandwidth to %u\n", (uint32_t)openair0_cfg->tx_bw);
printf("[oxgrf] set TX bandwidth to %u\n", (uint32_t)openair0_cfg->tx_bw);
int tx_gain = ((uint32_t)openair0_cfg->tx_gain[0] > 90?90:(uint32_t)openair0_cfg->tx_gain[0]);
if ((status = yunsdr_set_tx1_attenuation(yunsdr->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[yunsdr] Failed to set TX1 gain\n");
if ((status = oxgrf_set_tx1_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX1 gain\n");
} else
printf("[yunsdr] set the TX1 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[0]);
printf("[oxgrf] set the TX1 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[0]);
if(yunsdr->tx_num_channels > 1) {
if(oxgrf->tx_num_channels > 1) {
tx_gain = ((uint32_t)openair0_cfg->tx_gain[1] > 90?90:(uint32_t)openair0_cfg->tx_gain[1]);
if ((status = yunsdr_set_tx2_attenuation(yunsdr->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[yunsdr] Failed to set TX2 gain\n");
if ((status = oxgrf_set_tx2_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX2 gain\n");
} else
printf("[yunsdr] set the TX2 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[1]);
printf("[oxgrf] set the TX2 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[1]);
}
yunsdr_enable_timestamp(yunsdr->dev, 0, 0);
oxgrf_enable_timestamp(oxgrf->dev, 0, 0);
usleep(5);
yunsdr_enable_timestamp(yunsdr->dev, 0, 1);
oxgrf_enable_timestamp(oxgrf->dev, 0, 1);
for(int i = 0; i < NCHAN_PER_DEV; i++) {
int ret = posix_memalign((void **)&cache_buf[i], 4096, BUFFER_SIZE);
......@@ -605,18 +582,18 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
}
device->Mod_id = num_devices++;
device->type = YUNSDR_DEV;
device->trx_start_func = trx_yunsdr_start;
device->trx_end_func = trx_yunsdr_end;
device->trx_read_func = trx_yunsdr_read;
device->trx_write_func = trx_yunsdr_write;
device->trx_get_stats_func = trx_yunsdr_get_stats;
device->trx_reset_stats_func = trx_yunsdr_reset_stats;
device->trx_stop_func = trx_yunsdr_stop;
device->trx_set_freq_func = trx_yunsdr_set_freq;
device->trx_set_gains_func = trx_yunsdr_set_gains;
device->type = OXGRF_DEV;
device->trx_start_func = trx_oxgrf_start;
device->trx_end_func = trx_oxgrf_end;
device->trx_read_func = trx_oxgrf_read;
device->trx_write_func = trx_oxgrf_write;
device->trx_get_stats_func = trx_oxgrf_get_stats;
device->trx_reset_stats_func = trx_oxgrf_reset_stats;
device->trx_stop_func = trx_oxgrf_stop;
device->trx_set_freq_func = trx_oxgrf_set_freq;
device->trx_set_gains_func = trx_oxgrf_set_gains;
device->openair0_cfg = openair0_cfg;
device->priv = (void *)yunsdr;
device->priv = (void *)oxgrf;
return 0;
}
......
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
/** oxgrf_lib.h
*
* Author: openxg
*/
#ifndef YUNSDR_RF_HELPER_H_
#define YUNSDR_RF_HELPER_H_
// A bunch of helper functions to process device arguments
#include "oxgrf_api_ss.h"
#include "common_lib.h"
/** @addtogroup _OXGRF_PHY_RF_INTERFACE_
* @{
*/
typedef struct
{
OXGRF_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
int a;
} test_t;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*! \brief OXGRF specific data structure */
typedef struct {
//! opaque OXGRF device struct. An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
OXGRF_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
unsigned int sample_rate;
int rx_num_channels;
int tx_num_channels;
// --------------------------------
// Debug and output control
// --------------------------------
//! Number of underflows
int num_underflows;
//! Number of overflows
int num_overflows;
//! number of RX errors
int num_rx_errors;
//! Number of TX errors
int num_tx_errors;
//! timestamp of current TX
uint64_t tx_current_ts;
//! timestamp of current RX
uint64_t rx_current_ts;
//! number of TX samples
uint64_t tx_nsamps;
//! number of RX samples
uint64_t rx_nsamps;
//! number of TX count
uint64_t tx_count;
//! number of RX count
uint64_t rx_count;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
} oxgrf_state_t;
/*! \brief get current timestamp
*\param device the hardware to use
*/
openair0_timestamp trx_get_timestamp(openair0_device *device);
#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \
remove_substring(S, TOREMOVE ","); \
......@@ -53,4 +93,11 @@ static inline void copy_subdev_string(char* dst, char* src)
dst[n] = '\0';
}
#endif /* YUNSDR_RF_HELPER_H_ */
/*! \brief Initialize Openair oxgrf target. It returns 0 if OK
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
* \returns 0 on success
*/
int device_init(openair0_device *device, openair0_config_t *openair0_cfg);
/*@}*/
BUILD:
x86
sudo gcc -o trx trx_test.c yunsdr_lib.c -march=knl -lyunsdr_ss -g
sudo gcc -o trx trx_test.c oxgrf_lib.c -march=native -loxgrf_ss -g
arm
sudo gcc -o trx trx_test.c yunsdr_lib.c -lyunsdr_ss -g
......
File deleted
......@@ -39,6 +39,15 @@ struct timespec nr_get_timespec_diff(
}
int main( int argc, char **argv ) {
// test_t *t1=malloc(sizeof(test_t));
test_t t2[4];
// t2[0].b = 30720 * 1e3;
// t1->a = t2[0].b;
// printf("test\n");
// return 0;
struct sched_param rr_param;
rr_param.sched_priority = 90;
sched_setscheduler(getpid(), SCHED_RR, &rr_param);
......@@ -128,9 +137,9 @@ int main( int argc, char **argv ) {
readBlockSize = samples_per_subframe/2;
writeBlockSize = readBlockSize;
device_init(&(rfdevice), &openair0_cfg[0]);
rfdevice.trx_start_func(&rfdevice);
//first time is very long, don't know why.
......@@ -183,6 +192,5 @@ int main( int argc, char **argv ) {
} // while !oai_exit
return 0;
}
......@@ -6,7 +6,7 @@
#include <string.h>
//#include "T.h"
#include "common_lib.h"
#include "yunsdr_lib.h"
#include "oxgrf_lib.h"
#include "utils.h"
typedef long int openair0_timestamp;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/** yunsdr_lib.h
*
* Author: eric
* base on bladerf_lib.h
*/
#include "yunsdr_api_ss.h"
#include "common_lib.h"
/** @addtogroup _YUNSDR_PHY_RF_INTERFACE_
* @{
*/
/*! \brief YunSDR specific data structure */
typedef struct {
//! opaque YunSDR device struct. An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
YUNSDR_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
unsigned int sample_rate;
int rx_num_channels;
int tx_num_channels;
uint64_t tx_lo_freq;
uint64_t rx_lo_freq;
// --------------------------------
// Debug and output control
// --------------------------------
//! Number of underflows
int num_underflows;
//! Number of overflows
int num_overflows;
//! number of RX errors
int num_rx_errors;
//! Number of TX errors
int num_tx_errors;
//! timestamp of current TX
uint64_t tx_current_ts;
//! timestamp of current RX
uint64_t rx_current_ts;
//! number of TX samples
uint64_t tx_nsamps;
//! number of RX samples
uint64_t rx_nsamps;
//! number of TX count
uint64_t tx_count;
//! number of RX count
uint64_t rx_count;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
} yunsdr_state_t;
/*! \brief get current timestamp
*\param device the hardware to use
*/
openair0_timestamp trx_get_timestamp(openair0_device *device);
int device_init(openair0_device *device, openair0_config_t *openair0_cfg);
/*@}*/
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