// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : ape_test_case3.s.c
// Author        : 
// Created On    : 2022-11-02
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

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

/**************************************************************************/
/*                                 APE0                                   */
void ape0_test_timer0(void);

void ape0_event_task1(uint32_t address, uint32_t size);
void ape0_event_task2(uint32_t address, uint32_t size);
void ape0_event_task3(uint32_t address, uint32_t size);
void ape0_event_task4(uint32_t address, uint32_t size);
void ape0_event_task5(uint32_t address, uint32_t size);

/********************************************/
/* APE0: 每个时隙1个定时点任务，5个事件任务 */
/* 优先级：Timer0 > Event1 > Event2 > Event3 > Event4 > Event5 */
void ape0_test_task_reg(void)
{
    osp_task_info_ex ape0_timer_0 = {40, (int8_t*)"ape0_test_timer0", 40, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 10,   NULL, (OSP_TASKENTRY_FUNC)ape0_test_timer0};
    osp_task_info_ex ape0_event_1 = {41, (int8_t*)"ape0_test_event1", 41, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task1};
    osp_task_info_ex ape0_event_2 = {42, (int8_t*)"ape0_test_event2", 42, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task2};
    osp_task_info_ex ape0_event_3 = {43, (int8_t*)"ape0_test_event3", 43, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task3};
    osp_task_info_ex ape0_event_4 = {44, (int8_t*)"ape0_test_event4", 44, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task4};
    osp_task_info_ex ape0_event_5 = {45, (int8_t*)"ape0_test_event5", 45, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape0_event_task5};

    osp_task_create(&ape0_timer_0);
    osp_task_create(&ape0_event_1);
    osp_task_create(&ape0_event_2);
    osp_task_create(&ape0_event_3);
    osp_task_create(&ape0_event_4);
    osp_task_create(&ape0_event_5);

    osp_timer_sync(1);
    return;
}

/**************************************************************************/
/*                                 APE1                                   */
void ape1_test_timer0(void);

void ape1_event_task1(uint32_t address, uint32_t size);
void ape1_event_task2(uint32_t address, uint32_t size);
void ape1_event_task3(uint32_t address, uint32_t size);
void ape1_event_task4(uint32_t address, uint32_t size);
void ape1_event_task5(uint32_t address, uint32_t size);

/********************************************/
/* APE1: 每个时隙1个定时点任务，5个事件任务 */
/* 优先级：Timer0 > Event1 > Event2 > Event3 > Event4 > Event5 */
void ape1_test_task_reg(void)
{
    osp_task_info_ex ape1_timer_0 = {40, (int8_t*)"ape1_test_timer0", 40, 1024, OSP_TIMER_TYPE, 0, 0x3FF, 10,   NULL, (OSP_TASKENTRY_FUNC)ape1_test_timer0};
    osp_task_info_ex ape1_event_1 = {41, (int8_t*)"ape1_test_event1", 41, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task1};
    osp_task_info_ex ape1_event_2 = {42, (int8_t*)"ape1_test_event2", 42, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task2};
    osp_task_info_ex ape1_event_3 = {43, (int8_t*)"ape1_test_event3", 43, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task3};
    osp_task_info_ex ape1_event_4 = {44, (int8_t*)"ape1_test_event4", 44, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task4};
    osp_task_info_ex ape1_event_5 = {45, (int8_t*)"ape1_test_event5", 45, 1024, OSP_EVENT_TYPE, 0, 0,     0,   NULL, (OSP_TASKENTRY_FUNC)ape1_event_task5};

    osp_task_create(&ape1_timer_0);
    osp_task_create(&ape1_event_1);
    osp_task_create(&ape1_event_2);
    osp_task_create(&ape1_event_3);
    osp_task_create(&ape1_event_4);
    osp_task_create(&ape1_event_5);

    osp_timer_sync(1);
    return;
}

