//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : ape1_recv_task.s.c
// Author        : 
// Created On    : 2022-10-24
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------
#include "ucp_utility.h"
#include "phy_para.h"
#include "osp_task.h"
#include "osp_timer.h"

uint32_t g_u32_recv_num = 0;
uint32_t g_u32_recv_by_ape_num = 0;

void ape1_recv_task(uint32_t addr, uint32_t size)
{
    uint32_t ape_id = get_core_id();
    debug_write(DBG_DDR_COMMON_IDX(ape_id, 13), ++g_u32_recv_num);
    debug_write(DBG_DDR_COMMON_IDX(ape_id, 14), addr);
    debug_write(DBG_DDR_COMMON_IDX(ape_id, 15), size);
    return ;
}

void ape1_recvbyape_task(uint32_t addr, uint32_t size)
{
    uint32_t ape_id = get_core_id();
    debug_write(DBG_DDR_COMMON_IDX(ape_id, 16), ++g_u32_recv_by_ape_num);
    return ;
}

/*************************************************************************/
/* 收到消息后创建任务 */
void ape1_recv_task(uint32_t addr, uint32_t size);  // D
void ape1_stc_timer_task(void);                          // E
void ape1_cpri_time_task(void);                          // F
void ape1_recvbyape_task(uint32_t addr, uint32_t size);  // G

void ape1_event_task(uint32_t addr, uint32_t size)
{
    uint32_t ape_id = get_core_id();
    debug_write(DBG_DDR_COMMON_IDX(ape_id, 29), 0x01010101);
    osp_task_info_ex ape1_event_task_recv = {40, (int8_t*)"ape1_test_taskd", 40, 1024, OSP_EVENT_TYPE, 0, 0    , 0,   NULL, (OSP_TASKENTRY_FUNC)ape1_recv_task};
    osp_task_info_ex ape1_timer_task_stc  = {41, (int8_t*)"ape1_test_taske", 41, 2048, OSP_TIMER_TYPE, 0, 0x3ff, 0,   NULL, (OSP_TASKENTRY_FUNC)ape1_stc_timer_task};
    osp_task_info_ex ape1_timer_task_cpri = {42, (int8_t*)"ape1_test_taskf", 42, 2048, OSP_TIMER_TYPE, 0, 0x3ff, 200, NULL, (OSP_TASKENTRY_FUNC)ape1_cpri_time_task};
    osp_task_info_ex ape1_event_task_rec2 = {43, (int8_t*)"ape1_test_taskg", 43, 1024, OSP_EVENT_TYPE, 0, 0    , 0,   NULL, (OSP_TASKENTRY_FUNC)ape1_recvbyape_task};

    osp_task_create(&ape1_event_task_recv);
    osp_task_create(&ape1_timer_task_stc);
    osp_task_create(&ape1_timer_task_cpri);
    osp_task_create(&ape1_event_task_rec2);

    osp_timer_sync(LTE_SCS_ID);

    debug_write(DBG_DDR_COMMON_IDX(ape_id, 29), 0x03030303);
    return;
}

