// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : main.c
// Author        : xianfeng.du
// Created On    : 2022-06-25
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

#include "ucp_drv_common.h"
#include "pet_rfm_spu0_top.h"
#include "msg_transfer_host.h"
#include "msg_transfer_layer.h"
#include "ucp_pcie_traffic.h"
#include "ucp_printf.h"
#include "testcase.h"
#include "phy_para.h"
#include "lib_debug_init.h"

//#include "stc_timer.h"

int32_t main(int32_t argc, char* argv[])
{
    //SET_CLK_CFG_EMU();
    int32_t core_id = 0;
    int ret = FAILURE;
    UCP_PRINT_LOG("Hello world from PET RFM SPU0,coreId[0x%x]",  get_core_id());

    core_id = get_core_id();
    debug_write(DBG_DDR_COMMON_IDX(core_id, 0), PLATFORM_BUILD_DATA);

    ret = spu_lib_debug_init(core_id);
    debug_write(DBG_DDR_COMMON_IDX(core_id, 1), ret);

    pet_rfm_spu0_drv_init();

    //ucp_pcie_reset();

    pet_rfm_spu0_msg_transfer_init();

    /*********test code************/
    //test_case_cfgpar_pcie();
    /******************************/
    //ape_stc_init();

#if 1
    while(1) {

        /*********test code************/
        //test_case_sendmsg_pcie();
        /******************************/
        //ucp_pcie_reset();
        #if 1
        ret = ucp_pcie_recfg_reset();
		if(SUCCESS == ret)
		{
        	ucp_pcie_worker();
		}
		#endif
        //msg_transfer_recfg();
        /*********test code************/
        //test_case_recv_msg_pcie();
        /******************************/
        //heart_beat_write();
    }
#endif

#if 0
        while(1) {

            /*********test code************/
            //test_speed_sendmsg_pcie();
            /******************************/
            ucp_testSpeed_pcie_worker();
            /*********test code************/
            test_speed_recv_msg_pcie();
            /******************************/
        }
#endif

    return 0;
}

