/*
 * "Hello World" example.
 *
 * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
 * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
 * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
 * device in your system's hardware.
 * The memory footprint of this hosted application is ~69 kbytes by default
 * using the standard reference design.
 *
 * For a reduced footprint version of this template, and an explanation of how
 * to reduce the memory footprint for a given application, see the
 * "small_hello_world" template.
 *
 */

#include <io.h>
#include <stdio.h>
#include <system.h>

#include "back.h"



	int vadd = 0;
void newBackGroundMusic ()
	{
	  int i =1;
	  while (i < 32){
	        IOWR_16DIRECT (AUDIO_BASE, i*2  , value[vadd]);
	        vadd++;
	        if (vadd >= 29985){
	            vadd = 0;
	        }
	    i++;
	  }
	}




int main()
{

	alt_irq_register(AUDIO_IRQ, NULL, (void*)newBackGroundMusic );
	printf("Hello from Nios II!\n");
	int i = 0;

 //while(1)
 //{
	for ( i = 0; i < 100000; i ++)
		  i =i+1;
	 IOWR_16DIRECT (AUDIO_BASE, 0 , 0);
	 IOWR_16DIRECT (AUDIO_BASE, 0 , 1);
	 IOWR_16DIRECT (AUDIO_BASE, 0 , 2);
	 printf("Hello from Nios II!\n");
//		for ( i = 0; i < 1000000; i ++)
//			  i =i+1;
//		IOWR_16DIRECT (AUDIO_BASE, 0 , 3);
//			 IOWR_16DIRECT (AUDIO_BASE, 0 , 4);
			 printf("Hello from Nios II!\n");
//					for ( i = 0; i < 1000000; i ++)
//						  i =i+1;
//					IOWR_16DIRECT (AUDIO_BASE, 0 , 5);
//						 IOWR_16DIRECT (AUDIO_BASE, 0 , 6);
//						 for ( i = 0; i < 1000000; i ++)
//						 						  i =i+1;
// }

	  return 0;
}
