// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : ape_test_case1.s.c
// Author        : 
// Created On    : 2022-10-26
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

#include "typedef.h"
#include "osp_task.h"
#include "osp_timer.h"
#include "ucp_printf.h"

/**************************************************************************/
/*                                 APE0                                   */
//void ape0_event_task(uint32_t addr, uint32_t size);
void ape0_event_task1(uint32_t address, uint32_t size);
void ape0_event_task2(uint32_t address, uint32_t size);

void ape0_test_timer0(void);
void ape0_test_timer80(void);
void ape0_test_timer100(void);
void ape0_test_timer150(void);
void ape0_test_timer200(void);
void ape0_test_timer300(void);
void ape0_test_timer400(void);

/********************************************/
/* APE0: 每个时隙5个定时点任务，2个事件任务 */
/* 优先级：Timer0 > Timer80 > Timer100 > Timer150 > Timer200 > Timer300 > Event0 > Event1 > Timer400 */
void ape0_test_task_reg(void)
{
    osp_task_info_ex ape0_timer_0      = {41, (int8_t*)"ape0_test_timer0",   41, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 0,   NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer0};
    osp_task_info_ex ape0_timer_80     = {42, (int8_t*)"ape0_test_timer80",  42, 1024, OSP_TIMER_TYPE, 0, 0x1,   50,  NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer80};
    osp_task_info_ex ape0_timer_100    = {43, (int8_t*)"ape0_test_timer100", 43, 1024, OSP_TIMER_TYPE, 0, 0x3FE, 100, NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer100};
    osp_task_info_ex ape0_timer_150    = {44, (int8_t*)"ape0_test_timer150", 44, 1024, OSP_TIMER_TYPE, 0, 0x1,   150, NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer150};
    osp_task_info_ex ape0_timer_200    = {45, (int8_t*)"ape0_test_timer200", 45, 1024, OSP_TIMER_TYPE, 0, 0x3FE, 200, NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer200};
    osp_task_info_ex ape0_timer_300    = {46, (int8_t*)"ape0_test_timer300", 46, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 300, NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer300};
    osp_task_info_ex ape0_event_resend = {47, (int8_t*)"ape0_test_event1",   47, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task1};
    osp_task_info_ex ape0_event_recv   = {48, (int8_t*)"ape0_test_event2",   48, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task2};
    osp_task_info_ex ape0_timer_400    = {49, (int8_t*)"ape0_test_timer400", 49, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 400, NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer400};

    osp_task_create(&ape0_timer_0);
    osp_task_create(&ape0_timer_80);
    osp_task_create(&ape0_timer_100);
    osp_task_create(&ape0_timer_150);
    osp_task_create(&ape0_timer_200);
    osp_task_create(&ape0_timer_300);
    osp_task_create(&ape0_event_resend);
    osp_task_create(&ape0_event_recv);
    osp_task_create(&ape0_timer_400);

    osp_timer_sync(1);
    return;
}

/**************************************************************************/
/*                                 APE1                                   */
void ape1_event_task1(uint32_t address, uint32_t size);
void ape1_event_task2(uint32_t address, uint32_t size);

void ape1_test_timer0(void);
void ape1_test_timer80(void);
void ape1_test_timer100(void);
void ape1_test_timer150(void);
void ape1_test_timer200(void);
void ape1_test_timer300(void);
void ape1_test_timer400(void);

/********************************************/
/* APE1: 每个时隙5个定时点任务，2个事件任务 */
/* 优先级：Timer0 > Timer80 > Timer100 > Timer150 > Timer200 > Timer300 > Event0 > Event1 > Timer400 */
void ape1_test_task_reg(void)
{
    osp_task_info_ex ape1_timer_0      = {41, (int8_t*)"ape1_test_timer0",   41, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 0,   NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer0};
    osp_task_info_ex ape1_timer_80     = {42, (int8_t*)"ape1_test_timer80",  42, 1024, OSP_TIMER_TYPE, 0, 0x1,   50,  NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer80};
    osp_task_info_ex ape1_timer_100    = {43, (int8_t*)"ape1_test_timer100", 43, 1024, OSP_TIMER_TYPE, 0, 0x3FE, 100, NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer100};
    osp_task_info_ex ape1_timer_150    = {44, (int8_t*)"ape1_test_timer150", 44, 1024, OSP_TIMER_TYPE, 0, 0x1,   150, NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer150};
    osp_task_info_ex ape1_timer_200    = {45, (int8_t*)"ape1_test_timer200", 45, 1024, OSP_TIMER_TYPE, 0, 0x3FE, 200, NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer200};
    osp_task_info_ex ape1_timer_300    = {46, (int8_t*)"ape1_test_timer300", 46, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 300, NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer300};
    osp_task_info_ex ape1_event_resend = {47, (int8_t*)"ape1_test_event1",   47, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task1};
    osp_task_info_ex ape1_event_recv   = {48, (int8_t*)"ape1_test_event2",   48, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task2};
    osp_task_info_ex ape1_timer_400    = {49, (int8_t*)"ape1_test_timer400", 49, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 400, NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer400};

    osp_task_create(&ape1_timer_0);
    osp_task_create(&ape1_timer_80);
    osp_task_create(&ape1_timer_100);
    osp_task_create(&ape1_timer_150);
    osp_task_create(&ape1_timer_200);
    osp_task_create(&ape1_timer_300);
    osp_task_create(&ape1_event_resend);
    osp_task_create(&ape1_event_recv);
    osp_task_create(&ape1_timer_400);

    osp_timer_sync(1);
    return;
}

