/*
 *  ======== main.c ========
 */

#include <xdc/std.h>
#include <xdc/cfg/global.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Task.h>

#include "stdio.h"
#include "stdint.h"
#include "stdlib.h"
#include "string.h"

/* BOARD */
#include <ti/board/board.h>

/* UART Header files */
#include <ti/drv/uart/UART.h>
#include <ti/drv/uart/UART_stdio.h>
#include <ti/drv/uart/test/src/UART_board.h>

void taskFxn(UArg a0, UArg a1)
{
    System_printf("enter taskFxn()\n");
    UART_printf("Entra task\n");

    Task_sleep(10);

    System_printf("exit taskFxn()\n");
    UART_printf("Sale task\n");

    System_flush(); /* force SysMin output to console */
    return;
}

void Tempo1S(UArg a0)
{
    System_printf("Entra tempo\n");
    System_flush(); /* force SysMin output to console */
    UART_printf("Entra Tempo\n");
    return;
}

void Board_initUART(void)
{
    Board_initCfg boardCfg;

    boardCfg = BOARD_INIT_PINMUX_CONFIG |
               BOARD_INIT_MODULE_CLOCK  |
               BOARD_INIT_UART_STDIO;

    Board_init(boardCfg);
    return;
}

/*
 *  ======== main ========
 */
Int main()
{ 
    Task_Handle task;
    Error_Block eb;

    Board_initUART();

    System_printf("enter main()\n");

    Error_init(&eb);
    task = Task_create(taskFxn, NULL, &eb);
    if (task == NULL) {
        System_printf("Task_create() failed!\n");
        UART_printf("Task create() failed\n");
        BIOS_exit(0);
    }

    BIOS_start();    /* does not return */
    return(0);
}
