Commit a491fbb1 authored by knopp's avatar knopp

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5493 818b1a75-f10b-46b9-bf7c-635c3b92a50f

parent 752cb8a7
/** usrp_lib.h /** common_lib.h
* *
* Author: HongliangXU : hong-liang-xu@agilent.com * Author: HongliangXU : hong-liang-xu@agilent.com
*/ */
#ifndef USRP_LIB_H #ifndef COMMON_LIB_H
#define USRP_LIB_H #define COMMON_LIB_H
#include <stdint.h>
typedef int64_t openair0_timestamp; typedef int64_t openair0_timestamp;
typedef struct openair0_device_t openair0_device; typedef struct openair0_device_t openair0_device;
/* structrue holds the parameters to configure USRP devices /* structrue holds the parameters to configure USRP devices
*/ */
typedef enum {
max_gain=0,med_gain,byp_gain
} rx_gain_t;
typedef struct { typedef struct {
/* the sample rate for both transmit and receive. */ /* the sample rate for both transmit and receive. */
double sample_rate; double sample_rate;
...@@ -17,13 +24,15 @@ typedef struct { ...@@ -17,13 +24,15 @@ typedef struct {
/* number of TX channels (=TX antennas) */ /* number of TX channels (=TX antennas) */
int tx_num_channels; int tx_num_channels;
/* center frequency in Hz for RX */ /* center frequency in Hz for RX */
double rx_freq; double rx_freq[4];
/* center frequency in Hz for TX */ /* center frequency in Hz for TX */
double tx_freq; double tx_freq[4];
/* mode for rxgain (ExpressMIMO2)*/
rx_gain_t rxg_mode[4];
/* gain for RX in dB */ /* gain for RX in dB */
double rx_gain; double rx_gain[4];
/* gain for TX in dB */ /* gain for TX in dB */
double tx_gain; double tx_gain[4];
/* RX bandwidth in Hz */ /* RX bandwidth in Hz */
double rx_bw; double rx_bw;
/* TX bandwidth in Hz */ /* TX bandwidth in Hz */
...@@ -65,6 +74,8 @@ extern "C" ...@@ -65,6 +74,8 @@ extern "C"
/* return 0 if OK, < 0 if error */ /* return 0 if OK, < 0 if error */
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg); int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg);
} }
#else
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg);
#endif #endif
#endif // USRP_LIB_H #endif // COMMON_LIB_H
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
#include "openair0_lib.h" #include "openair0_lib.h"
#include "openair_device.h" #include "openair_device.h"
#include "common_lib.h"
#define max(a,b) ((a)>(b) ? (a) : (b))
exmimo_pci_interface_bot_virtual_t openair0_exmimo_pci[MAX_CARDS]; // contains userspace pointers for each card exmimo_pci_interface_bot_virtual_t openair0_exmimo_pci[MAX_CARDS]; // contains userspace pointers for each card
char *bigshm_top[MAX_CARDS] = INIT_ZEROS; char *bigshm_top[MAX_CARDS] = INIT_ZEROS;
...@@ -42,7 +43,8 @@ int openair0_open(void) ...@@ -42,7 +43,8 @@ int openair0_open(void)
int card; int card;
int ant; int ant;
int openair0_num_antennas[4];
PAGE_SHIFT = log2_int( sysconf( _SC_PAGESIZE ) ); PAGE_SHIFT = log2_int( sysconf( _SC_PAGESIZE ) );
if ((openair0_fd = open("/dev/openair0", O_RDWR,0)) <0) if ((openair0_fd = open("/dev/openair0", O_RDWR,0)) <0)
...@@ -187,3 +189,93 @@ int openair0_stop_without_reset(int card) ...@@ -187,3 +189,93 @@ int openair0_stop_without_reset(int card)
{ {
return ioctl(openair0_fd, openair_STOP_WITHOUT_RESET, card); return ioctl(openair0_fd, openair_STOP_WITHOUT_RESET, card);
} }
static exmimo_config_t *p_exmimo_config;
static exmimo_id_t *p_exmimo_id;
#define MY_RF_MODE (RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX)
#define RF_MODE_BASE (TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM)
int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// Initialize card
int ret;
int ant;
ret = openair0_open();
if ( ret != 0 ) {
if (ret == -1)
printf("Error opening /dev/openair0");
if (ret == -2)
printf("Error mapping bigshm");
if (ret == -3)
printf("Error mapping RX or TX buffer");
return(ret);
}
printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[0]);
p_exmimo_config = openair0_exmimo_pci[0].exmimo_config_ptr;
p_exmimo_id = openair0_exmimo_pci[0].exmimo_id_ptr;
printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", 0, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev);
// check if the software matches firmware
if (p_exmimo_id->board_swrev!=BOARD_SWREV_CNTL2) {
printf("Software revision %d and firmware revision %d do not match. Please update either the firmware or the software!\n",BOARD_SWREV_CNTL2,p_exmimo_id->board_swrev);
exit(-1);
}
if (p_exmimo_id->board_swrev>=9)
p_exmimo_config->framing.eNB_flag = 0;
else
p_exmimo_config->framing.eNB_flag = 1;//!UE_flag;
p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
#if (BOARD_SWREV_CNTL2>=0x0A)
for (ant=0; ant<4; ant++)
p_exmimo_config->framing.resampling_factor[ant] = 2;
#else
p_exmimo_config->framing.resampling_factor = 2;
#endif
for (ant=0;ant<max(openair0_cfg->tx_num_channels,openair0_cfg->rx_num_channels);ant++)
p_exmimo_config->rf.rf_mode[ant] = RF_MODE_BASE;
for (ant=0;ant<openair0_cfg->tx_num_channels;ant++)
p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX);
for (ant=0;ant<openair0_cfg->rx_num_channels;ant++) {
p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX);
switch (openair0_cfg->rxg_mode[ant]) {
default:
case max_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMax;
break;
case med_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAMed;
break;
case byp_gain:
p_exmimo_config->rf.rf_mode[ant] = (p_exmimo_config->rf.rf_mode[ant]&(~LNAGAINMASK))|LNAByp;
break;
}
}
for (ant=max(openair0_cfg->tx_num_channels,openair0_cfg->rx_num_channels);ant<4;ant++) {
p_exmimo_config->rf.rf_mode[ant] = 0;
}
for (ant = 0; ant<openair0_cfg->rx_num_channels; ant++) {
p_exmimo_config->rf.do_autocal[ant] = 1;
p_exmimo_config->rf.rf_freq_rx[ant] = (unsigned int)openair0_cfg->rx_freq[ant];
p_exmimo_config->rf.tx_gain[ant][0] = (unsigned int)openair0_cfg->rx_gain;
}
for (ant = 0; ant<openair0_cfg->tx_num_channels; ant++) {
p_exmimo_config->rf.do_autocal[ant] = 1;
p_exmimo_config->rf.rf_freq_tx[ant] = (unsigned int)openair0_cfg->tx_freq[ant];
p_exmimo_config->rf.tx_gain[ant][0] = (unsigned int)openair0_cfg->tx_gain;
}
}
unsigned int *openair0_daq_cnt() {
return((unsigned int *)openair0_exmimo_pci[0].rxcnt_ptr[0]);
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "pcie_interface.h" #include "pcie_interface.h"
#include "openair_device.h" #include "openair_device.h"
#include "common_lib.h"
// Use this to access shared memory (configuration structures, adc/dac data buffers, ...) // Use this to access shared memory (configuration structures, adc/dac data buffers, ...)
// contains userspace pointers // contains userspace pointers
...@@ -53,5 +54,7 @@ int openair0_stop(int card); ...@@ -53,5 +54,7 @@ int openair0_stop(int card);
// return 0 on success // return 0 on success
int openair0_stop_without_reset(int card); int openair0_stop_without_reset(int card);
// return the DAQ block counter
unsigned int *openair0_daq_cnt();
#endif #endif
USRP_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.o USRP_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.o
USRP_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp USRP_FILE_OBJ += $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
USRP_CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/ USRP_CFLAGS += -I$(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/COMMON
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <complex> #include <complex>
#include <fstream> #include <fstream>
#include <cmath> #include <cmath>
#include "usrp_lib.h" #include "common_lib.h"
typedef struct typedef struct
{ {
......
...@@ -18,12 +18,13 @@ ifeq "$(GCCVERSION)" "4.6.1" ...@@ -18,12 +18,13 @@ ifeq "$(GCCVERSION)" "4.6.1"
endif endif
CFLAGS += -O2 CFLAGS += -O2
CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/COMMON -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO
ifdef DEBUG ifdef DEBUG
CFLAGS += -g -ggdb CFLAGS += -g -ggdb
endif endif
SRC = synctest.c condtest.c #lte-softmodem.c SRC = synctest.c condtest.c #lte-softmodem.c
ifndef RTAI ifndef RTAI
RTAI=1 RTAI=1
endif endif
...@@ -55,24 +56,14 @@ endif ...@@ -55,24 +56,14 @@ endif
ifeq ($(RTAI),1) ifeq ($(RTAI),1)
CFLAGS += -DENABLE_RTAI_CLOCK CFLAGS += -DENABLE_RTAI_CLOCK
CFLAGS += -DCONFIG_RTAI_LXRT_INLINE #remend the RTAI warning CFLAGS += -DCONFIG_RTAI_LXRT_INLINE #remend the RTAI warning
RTAI_OBJ = sched_dlsch.o sched_ulsch.o sched_rx_pdsch.o rt_wrapper.o RTAI_OBJ = sched_dlsch.o sched_rx_pdsch.o rt_wrapper.o
ifeq ($(USRP),1)
RTAI_OBJ += lte-softmodem-usrp.o
endif
else #RTAI else #RTAI
CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME CFLAGS += -DENABLE_USE_CPU_EXECUTION_TIME
OBJ += sched_dlsch.o sched_ulsch.o sched_rx_pdsch.o rt_wrapper.o OBJ += sched_dlsch.o sched_rx_pdsch.o rt_wrapper.o
ifeq ($(USRP),1)
OBJ += lte-softmodem-usrp.o
endif
endif endif
OBJ += $(OPENAIR1_DIR)/SIMULATION/TOOLS/taus.o $(OPENAIR_TARGETS)/SIMU/USER/init_lte.o #$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o OBJ += $(OPENAIR1_DIR)/SIMULATION/TOOLS/taus.o $(OPENAIR_TARGETS)/SIMU/USER/init_lte.o #$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o
ifeq ($(USRP),1)
include $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/Makefile.inc
endif
OBJ += $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/gain_control.o OBJ += $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/openair0_lib.o $(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/gain_control.o
CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO CFLAGS += -DDRIVER2013 -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/USERSPACE/LIB/ -I$(OPENAIR_TARGETS)/ARCH/EXMIMO/DEFS -DENABLE_VCD_FIFO
...@@ -94,6 +85,14 @@ include $(OPENAIR2_DIR)/RRC/NAS/Makefile.inc ...@@ -94,6 +85,14 @@ include $(OPENAIR2_DIR)/RRC/NAS/Makefile.inc
include $(OPENAIR2_DIR)/ENB_APP/Makefile.inc include $(OPENAIR2_DIR)/ENB_APP/Makefile.inc
include $(OPENAIR3_DIR)/RAL-LTE/Makefile.inc include $(OPENAIR3_DIR)/RAL-LTE/Makefile.inc
ifeq ($(USRP),1)
include $(OPENAIR_TARGETS)/ARCH/USRP/USERSPACE/LIB/Makefile.inc
CFLAGS += -I/opt/uhd/include -L/opt/uhd/lib -luhd -lpthread -lstdc++
CFLAGS += -DUSRP
LDFLAGS += -L/opt/uhd/lib -luhd -lpthread -lstdc++
endif
OBJ += $(ENB_APP_OBJS) OBJ += $(ENB_APP_OBJS)
ifeq ($(RTAI),1) ifeq ($(RTAI),1)
...@@ -119,6 +118,8 @@ endif ...@@ -119,6 +118,8 @@ endif
RTAI_OBJ += $(UTILS_OBJS) RTAI_OBJ += $(UTILS_OBJS)
ifdef ENABLE_ITTI ifdef ENABLE_ITTI
CFLAGS += -DEXMIMO_IOT CFLAGS += -DEXMIMO_IOT
endif endif
...@@ -205,8 +206,12 @@ $(LFDS_LIB): ...@@ -205,8 +206,12 @@ $(LFDS_LIB):
@if [ ! -d $(LFDS_OBJ_DIR)/obj ]; then mkdir -p $(LFDS_OBJ_DIR)/obj; fi; @if [ ! -d $(LFDS_OBJ_DIR)/obj ]; then mkdir -p $(LFDS_OBJ_DIR)/obj; fi;
$(MAKE) -C $(LFDS_DIR) -f makefile.linux OUTDIR=$(LFDS_OBJ_DIR) $(MAKE) -C $(LFDS_DIR) -f makefile.linux OUTDIR=$(LFDS_OBJ_DIR)
$(USRP_OBJ):$(USRP_FILE_OBJ)
@echo Compiling $<
@$(CXX) -c $(USRP_CFLAGS) $(USRP_FILE_OBJ) -o $(USRP_OBJ)
ifeq ($(RTAI),1) ifeq ($(RTAI),1)
$(RTAI_OBJ) lte-enb.o lte-softmodem.o: %.o : %.c $(RTAI_OBJ) lte-softmodem.o: %.o : %.c
else else
$(RTAI_OBJ): %.o : %.c $(RTAI_OBJ): %.o : %.c
endif endif
...@@ -256,18 +261,10 @@ synctest: $(OBJ_SYNC) $(SHARED_DEPENDENCIES) synctest.c ...@@ -256,18 +261,10 @@ synctest: $(OBJ_SYNC) $(SHARED_DEPENDENCIES) synctest.c
sleeptest: rt_wrapper.o sleeptest.c sleeptest: rt_wrapper.o sleeptest.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) rt_wrapper.o -o sleeptest sleeptest.c $(LDFLAGS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) rt_wrapper.o -o sleeptest sleeptest.c $(LDFLAGS)
lte-softmodem: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) lte-softmodem.o $(SHARED_DEPENDENCIES) lte-softmodem: $(OBJ) $(USRP_OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) lte-softmodem.o $(SHARED_DEPENDENCIES)
@echo Linking $@ @echo Linking $@
@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) lte-softmodem.o -o lte-softmodem $(LDFLAGS) $(LIBS) @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) lte-softmodem.o -o lte-softmodem $(LDFLAGS) $(LIBS)
lte-enb: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) lte-enb.o $(SHARED_DEPENDENCIES)
@echo Linking $@
@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) lte-enb.o -o lte-enb $(LDFLAGS) $(LIBS)
lte-softmodem-usrp: $(OBJ) $(ASN1_MSG_OBJS1) $(RTAI_OBJ) $(USRP_OBJ) $(SHARED_DEPENDENCIES)
@echo Linking $@
@$(CC) $(USRP_OBJ) $(CFLAGS) $(OBJ) $(RTAI_OBJ) $(ASN1_MSG_OBJS1) -o lte-softmodem-usrp $(LDFLAGS) $(LIBS)
emos-raw: $(SHARED_DEPENDENCIES) $(OBJ_EMOS) emos-raw.c emos-raw: $(SHARED_DEPENDENCIES) $(OBJ_EMOS) emos-raw.c
@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $(OBJ_EMOS) -o emos-raw emos-raw.c $(LDFLAGS) $(LIBS) @$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(RTAI_CFLAGS) $(OBJ_EMOS) -o emos-raw emos-raw.c $(LDFLAGS) $(LIBS)
......
This diff is collapsed.
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