// +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_printf.h"
#include "ecs_rfm_spu0_top.h"
#include "msg_transfer_queue.h"
#include "log_client.h"
#include "ucp_utility.h"
#include "spu_shell.h"
#include "hwque.h"
#include "phy_para.h"
#include "ecpri_queue_proc.h"
#include "ecpri_csu.h"
#include "lib_debug_init.h"


int32_t main(int32_t argc, char* argv[])
{
    int32_t core_id = 0;
    int32_t ret = 0;

    UCP_PRINT_EMPTY("Hello world from ECS 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);

    spu_log_client_init();

    ecs_rfm_spu0_drv_init();

    ecs_rfm_spu0_msg_transfer_init();

    spu_shell_init();

    while (1)
    {
        if (PROTOCOL_ECPRI == get_protocol_sel())
        {
            /* eCPRI循环队列轮询处理 */
            ecpri_queue_proc();

            /* 手动触发eCPRI CSU发送数据测试 */
            if (1 == do_read_volatile(ECPRI_DBG_BUF_ADDR + 0x0C))
            {
                ecpri_csu_send_test();

                do_write(ECPRI_DBG_BUF_ADDR + 0x0C, 0x00);
            }
        }
    }

    return 0;
}

