/*
 *  Copyright 2010 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *
 */
/***************************************************************************/
/*                                                                         */
/*     H E L L O . C                                                       */
/*                                                                         */
/*     Basic LOG event operation from main.                                */
/*                                                                         */
/***************************************************************************/

#include <std.h>

#include <log.h>
#include <clk.h>
#include "hellocfg.h"
unsigned int sum_loop(unsigned int N){
	unsigned int i = 0, sum = 0;
	sum = 0;
	for(i = 0; i <= N; i ++){
		sum = sum + i;
	}
	return sum;
}

/*
 *  ======== main ========
 */
void main()
{
	int i = 0;
	unsigned int cur_time = 0, sum = 0;
	unsigned int ncycles ;
	ncycles = CLK_cpuCyclesPerHtime();
	LOG_printf(&trace, "Cpu cycles per Htime is %d",ncycles);
	for(i = 0; i < 32; i ++){
		cur_time = CLK_gethtime();
		LOG_printf(&trace, "Time is 0x%x", cur_time);

		sum = sum_loop(i);
		LOG_printf(&trace, "No. %d, sum val is %d", i,  sum);

		cur_time = CLK_gethtime();
		LOG_printf(&trace, "Time is 0x%x", cur_time);
	}
	while(1);

    /* fall into DSP/BIOS idle loop */
    return;
}
