#include <xdc/std.h>

#include <xdc/runtime/System.h>
#include <xdc/runtime/Types.h>
#include <xdc/runtime/Timestamp.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/hal/Hwi.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Swi.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/utils/Load.h>
#include <ti/sysbios/knl/Event.h>
#include <ti/sysbios/knl/Semaphore.h>

#include <xdc/cfg/global.h>

volatile uint64_t taskn0_Cnt = 0;
volatile uint64_t taskn1_Cnt = 0;
volatile uint64_t task_idle_Cnt = 0;

/*
 *  ======== taskFxn1 ========
 */
Void taskFxn_1(UArg a0, UArg a1)
{
    while(1)
    {
        taskn1_Cnt++;
        Task_sleep(20);
    }
}

/*
 *  ======== taskFxn ========
 */
Void taskFxn(UArg a0, UArg a1)
{
    while(1)
    {
        taskn0_Cnt++;
        Task_sleep(10);
    }
}


/* Global Variables */
Task_Handle tsk0, tsk1;

/*
 *  ======== main ========
 */
Int main()
{
    Task_Params taskParams;
    Task_Params taskParams1;

    Task_Params_init(&taskParams);

    taskParams.priority = 2;
    taskParams.affinity = 0;
    tsk0 = Task_create(taskFxn, &taskParams, NULL);

    Task_Params_init(&taskParams1);
    taskParams1.priority = 2;
    taskParams1.affinity = 1;
    tsk1 = Task_create(taskFxn_1, &taskParams1, NULL);

    BIOS_start();

    return (0);
}

/*
 *  ======== idle_func ========
 */
Void idle_func(UArg a0, UArg a1)
{
    task_idle_Cnt++;
    while(1){}
}

