libstc.a与libmsgtransfer.a解耦

This commit is contained in:
liweihua 2023-12-29 16:48:28 +08:00
parent ad9959e0b0
commit 6719f4cde9
20 changed files with 72 additions and 54 deletions

View File

@ -26,6 +26,7 @@
#include "ospShell.h" #include "ospShell.h"
#include "ucp_printf.h" #include "ucp_printf.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
int32_t test_case(uint32_t argc, int32_t* argvp); int32_t test_case(uint32_t argc, int32_t* argvp);
@ -130,6 +131,7 @@ int32_t main(int32_t argc, char* argvp[])
osp_init(); osp_init();
osp_set_taskcpu(7, 95); osp_set_taskcpu(7, 95);
drv_init(); drv_init();
init_stc();
#ifdef PALLADIUM_TEST #ifdef PALLADIUM_TEST
UCP_PRINT_DEBUG("entered testmode."); UCP_PRINT_DEBUG("entered testmode.");

View File

@ -72,6 +72,12 @@ if [[ "${fronthaul_option}" == "jesd" ]]; then
make make
fi fi
cd ${DIR_ROOT}/driver/tfu
source ./build.sh
cp build/libstc.a ${DIR_ROOT}/lib
cp build/libstc.a ${BUILD_DIR}
cp stc/inc/stc_drv_api.h ${DIR_ROOT}/interface
echo -e "\n" echo -e "\n"
echo "###### start building msgTransfer.out and libmsgTransfer.a ######" echo "###### start building msgTransfer.out and libmsgTransfer.a ######"
cd ${DIR_ROOT}/ cd ${DIR_ROOT}/

View File

@ -32,11 +32,11 @@
uint8_t* virMemAddr = NULL; uint8_t* virMemAddr = NULL;
int arm_csu_init() int arm_csu_init()
{ {
if (-1 == g_drv_mem_fd) if (-1 == g_drv_mem_fd0)
{ {
// printf("open dev mem. \r\n"); // printf("open dev mem. \r\n");
g_drv_mem_fd = open("/dev/mem", O_RDWR|O_SYNC); g_drv_mem_fd0 = open("/dev/mem", O_RDWR|O_SYNC);
if (0 > g_drv_mem_fd) if (0 > g_drv_mem_fd0)
{ {
UCP_PRINT_ERROR("open /dev/mem error\n"); UCP_PRINT_ERROR("open /dev/mem error\n");
return -1; return -1;
@ -44,7 +44,7 @@ int arm_csu_init()
} }
// printf("start mmap. \r\n"); // printf("start mmap. \r\n");
virMemAddr = (uint8_t*)mmap(NULL, CSU_DEV_MAP_LEN, PROT_READ|PROT_WRITE, MAP_SHARED, g_drv_mem_fd, AP_CSU_BASE); virMemAddr = (uint8_t*)mmap(NULL, CSU_DEV_MAP_LEN, PROT_READ|PROT_WRITE, MAP_SHARED, g_drv_mem_fd0, AP_CSU_BASE);
if ((uint8_t*)(-1) == virMemAddr) if ((uint8_t*)(-1) == virMemAddr)
{ {
UCP_PRINT_ERROR("mmap error!!"); UCP_PRINT_ERROR("mmap error!!");

View File

@ -3,7 +3,7 @@
#include "typedef.h" #include "typedef.h"
extern int32_t g_drv_mem_fd; extern int32_t g_drv_mem_fd0;
#define STC_REG_BASE_ADDR (0x08568000) #define STC_REG_BASE_ADDR (0x08568000)
#define STC_REG_LEN (0x08000) #define STC_REG_LEN (0x08000)
@ -11,7 +11,7 @@ extern int32_t g_drv_mem_fd;
int32_t drv_init(void); int32_t drv_init(void);
uint64_t get_arm_cycle(); uint64_t get_arm_cycle();
uint32_t read_stc_local_timer(); //uint32_t read_stc_local_timer();
#endif #endif

View File

@ -9,8 +9,7 @@
#include "arm_csu.h" #include "arm_csu.h"
#include "ucp_printf.h" #include "ucp_printf.h"
int32_t g_drv_mem_fd = -1; int32_t g_drv_mem_fd0 = -1;
uint32_t *g_stc_regs_ptr = NULL; //0x08568000
uint64_t get_arm_cycle() uint64_t get_arm_cycle()
{ {
@ -21,52 +20,14 @@ uint64_t get_arm_cycle()
return cycle; return cycle;
} }
uint32_t read_stc_local_timer()
{
return *(g_stc_regs_ptr + STC_LTBG_REG_OFFSET);
}
int32_t init_stc()
{
if(g_drv_mem_fd < 0)
{
g_drv_mem_fd = open("/dev/mem", O_RDWR|O_SYNC);
if(g_drv_mem_fd < 0)
{
UCP_PRINT_ERROR("open /dev/mem error");
return -1;
}
}
if(g_stc_regs_ptr == NULL)
{
g_stc_regs_ptr = mmap(NULL, STC_REG_LEN, PROT_READ|PROT_WRITE, MAP_SHARED,
g_drv_mem_fd, STC_REG_BASE_ADDR);
if(-1 == (int64_t)g_stc_regs_ptr)
{
UCP_PRINT_ERROR("mmap stc regs error!! return = %ld\n",(uint64_t)g_stc_regs_ptr);
return -2;
}
}
return 0;
}
int32_t drv_init(void) int32_t drv_init(void)
{ {
if(0 != arm_csu_init()) if(0 != arm_csu_init())
{ {
UCP_PRINT_ERROR("Init arm csu error!!"); UCP_PRINT_ERROR("Init arm csu error!!");
return -1; return -1;
} }
if(0 != init_stc())
{
UCP_PRINT_ERROR("Init stc error!!");
return -3;
}
return 0; return 0;
} }

@ -1 +1 @@
Subproject commit 85a547fe18f6645a03489124eec040ad20ef116a Subproject commit 59d436372f6d310f582c10c62c709c26e488d0c8

@ -1 +1 @@
Subproject commit 7bd0c4a6b87b70cf28b0c47eea74b731c9e90e38 Subproject commit 81b543d4ec66acdde54865eec21a3b3a863520fe

View File

@ -70,16 +70,24 @@ typedef enum ucp_jesd_gpioEnableLevel
uint8_t enableLevel; uint8_t enableLevel;
} ucp_jesd_gpio_t; } ucp_jesd_gpio_t;
typedef struct ucp_jesd_tr_gpio {
ucp_jesd_gpio_t trx;
ucp_jesd_gpio_t rf;
ucp_jesd_gpio_t sw;
} ucp_jesd_tr_gpio_t;
typedef struct ucp_jesd_TrxGpio { typedef struct ucp_jesd_TrxGpio {
ucp_jesd_gpio_t tx; ucp_jesd_tr_gpio_t tx;
ucp_jesd_gpio_t rx; ucp_jesd_tr_gpio_t rx;
ucp_jesd_gpio_t orx; ucp_jesd_tr_gpio_t orx;
} ucp_jesd_TrxGpio_t; } ucp_jesd_TrxGpio_t;
/** /**
* \brief Data structure to configure of trx's contrl pins * \brief Data structure to configure of trx's contrl pins
*/ */
typedef struct ucp_jesd_TrxGpioCfg { typedef struct ucp_jesd_TrxGpioCfg {
char board[16];
uint32_t version;
uint8_t maxCh; uint8_t maxCh;
uint8_t devClkSrc; uint8_t devClkSrc;
int32_t uldelay; int32_t uldelay;
@ -93,8 +101,7 @@ typedef struct ucp_jesd_TrxGpioCfg {
*/ */
typedef struct ucp_jesd_CommonSettings typedef struct ucp_jesd_CommonSettings
{ {
uint32_t devClock_kHz; /*!< Device clock frequency in kHz */ uint32_t devClock_kHz; /*!< Device clock frequency in kHz */
uint32_t sampleClock_kHz; /*!< Sample clock frequency in kHz */
uint8_t enableJesd204C; /*!< 1= Enable JESD204C framer, 0 = use JESD204B framer */ uint8_t enableJesd204C; /*!< 1= Enable JESD204C framer, 0 = use JESD204B framer */
uint8_t jesdSubClass; uint8_t jesdSubClass;
} ucp_jesd_CommonSettings_t; } ucp_jesd_CommonSettings_t;
@ -105,6 +112,7 @@ typedef struct ucp_jesd_CommonSettings
typedef struct ucp_jesd_FrmCfg typedef struct ucp_jesd_FrmCfg
{ {
uint8_t enable; uint8_t enable;
uint32_t sampleClock_kHz; /*!< Sample clock frequency in kHz */
uint8_t jesd204M; /*!< Number of ADCs (0, 2, or 4) where 2 ADCs are required per receive chain (I and Q). */ uint8_t jesd204M; /*!< Number of ADCs (0, 2, or 4) where 2 ADCs are required per receive chain (I and Q). */
uint16_t jesd204K; /*!< Number of frames in a multiframe. Default = 32, F*K must be modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C). */ uint16_t jesd204K; /*!< Number of frames in a multiframe. Default = 32, F*K must be modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C). */
uint8_t jesd204F; /*!< Number of bytes(octets) per frame (Valid 1, 2, 4, 8). */ uint8_t jesd204F; /*!< Number of bytes(octets) per frame (Valid 1, 2, 4, 8). */
@ -122,6 +130,7 @@ typedef struct ucp_jesd_FrmCfg
typedef struct ucp_jesd_DfrmCfg typedef struct ucp_jesd_DfrmCfg
{ {
uint8_t enable; uint8_t enable;
uint32_t sampleClock_kHz; /*!< Sample clock frequency in kHz */
uint8_t jesd204M; /*!< Number of DACs (0, 2, or 4) - 2 DACs per transmit chain (I and Q) */ uint8_t jesd204M; /*!< Number of DACs (0, 2, or 4) - 2 DACs per transmit chain (I and Q) */
uint16_t jesd204K; /*!< Number of frames in a multiframe. Default = 32, F*K = modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C) */ uint16_t jesd204K; /*!< Number of frames in a multiframe. Default = 32, F*K = modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C) */
uint8_t jesd204F; /*!< Number of bytes(octets) per frame . */ uint8_t jesd204F; /*!< Number of bytes(octets) per frame . */
@ -172,6 +181,16 @@ extern void UCP_API_JESD_ApeWorkStep(ucp_jesd_ApeWorkStep_e step);
*/ */
extern void UCP_API_JESD_TrxGpioSetup (const char *trxGpioConfigFile); extern void UCP_API_JESD_TrxGpioSetup (const char *trxGpioConfigFile);
/**
* \brief Gets the gpio's inf of tx and rx
*
* \param void
*
* \retval TrxGpioCfg point.
*/
extern ucp_jesd_TrxGpioCfg_t* UCP_API_JESD_TrxGpioGet (void);
/** /**
* \brief Sets up the ucp4008 jesd's para setting * \brief Sets up the ucp4008 jesd's para setting
* *
@ -199,6 +218,22 @@ extern ucp_jesd_States_e UCP_API_JESD_CellSetup (ucp_jesd_Init_t *setting);
*/ */
extern void UCP_API_JESD_CellDelete (void); extern void UCP_API_JESD_CellDelete (void);
/**
* \brief gpio of rf controlling
*
* \param setting
*
* \retval none.
*/
extern void UCP_API_GPIO_Tx (void);
extern void UCP_API_GPIO_Rx (void);
extern void UCP_API_GPIO_On (void);
extern void UCP_API_GPIO_Off (void);
extern void UCP_API_GPIO_OrxOn (void);
extern void UCP_API_GPIO_OrxOff (void);
extern void UCP_API_GPIO_TrigOn (void);
extern void UCP_API_GPIO_TrigOff (void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -46,6 +46,7 @@ INCLUDE_DIRS ?= ./app/inc
INCLUDE_DIRS += ./osp/inc INCLUDE_DIRS += ./osp/inc
INCLUDE_DIRS += ./driver/arm_csu/inc INCLUDE_DIRS += ./driver/arm_csu/inc
INCLUDE_DIRS += ./driver/init/inc INCLUDE_DIRS += ./driver/init/inc
INCLUDE_DIRS += ./driver/tfu/stc/inc
test ?= $(test_option) test ?= $(test_option)
case ?= $(test_id) case ?= $(test_id)
ifeq ($(test),yes) ifeq ($(test),yes)
@ -67,8 +68,9 @@ LD_FLAGS += -lm -ldl -Wl,-rpath=./
LD_FLAGS += -lpthread LD_FLAGS += -lpthread
LD_FLAGS += -rdynamic -funwind-tables -ffunction-sections LD_FLAGS += -rdynamic -funwind-tables -ffunction-sections
ifeq ($(fronthaul_option),jesd) ifeq ($(fronthaul_option),jesd)
LD_FLAGS += -lrfic LD_FLAGS += -lrfic -lstc
endif endif
LD_FLAGS += -lstc
$(info "DEFINES=" $(DEFINES)) $(info "DEFINES=" $(DEFINES))
#Flatten files and remove the duplicate by sort #Flatten files and remove the duplicate by sort

View File

@ -26,6 +26,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -10,6 +10,8 @@
#include "typedef.h" #include "typedef.h"
#include "ospHeap.h" #include "ospHeap.h"
#include "ucp_printf.h" #include "ucp_printf.h"
#include "ospTypes.h"
/*typedef unsigned char uint8_t; /*typedef unsigned char uint8_t;
typedef signed char int8_t; typedef signed char int8_t;

View File

@ -12,6 +12,7 @@
#include "ucp_printf.h" #include "ucp_printf.h"
#include "arm_csu.h" #include "arm_csu.h"
#include "memcpy_csu.h" #include "memcpy_csu.h"
#include "ospTypes.h"
extern int32_t g_dev_mem_fd; extern int32_t g_dev_mem_fd;

View File

@ -26,6 +26,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -27,6 +27,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -26,6 +26,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -26,6 +26,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -33,6 +33,7 @@
#include "ospTask.h" #include "ospTask.h"
#include "drv_init.h" #include "drv_init.h"
#include "ospSwTimer.h" #include "ospSwTimer.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -33,6 +33,7 @@
#include "ospTask.h" #include "ospTask.h"
#include "drv_init.h" #include "drv_init.h"
#include "ospSwTimer.h" #include "ospSwTimer.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -33,6 +33,7 @@
#include "ospTask.h" #include "ospTask.h"
#include "drv_init.h" #include "drv_init.h"
#include "ospSwTimer.h" #include "ospSwTimer.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;

View File

@ -26,6 +26,7 @@
#include "ospLog.h" #include "ospLog.h"
#include "ospCfgToBin.h" #include "ospCfgToBin.h"
#include "drv_init.h" #include "drv_init.h"
#include "stc_drv_api.h"
uint32_t slot_ind_flag = 0; uint32_t slot_ind_flag = 0;
uint32_t slot_ind_time_flag = 0; uint32_t slot_ind_time_flag = 0;