/***********************************************************************/
/*                                                                     */
/*  FILE        :player.c                                              */
/*  DATE        :Tue, Nov 09, 2010                                     */
/*  DESCRIPTION :Main Program                                          */
/*  CPU TYPE    :SH7262                                                */
/*                                                                     */
/*  This file is generated by KPIT GNU Project Generator.              */
/*                                                                     */
/***********************************************************************/
         
#include "iodefine.h"
#include "intrinsics.h"
#include "ff.h"
#include "diskio.h"
#include "sys_ctrl.h"
#include "led_ctrl.h"
#include "cmt_ctrl.h"
#include "key_ctrl.h"
#include "ui.h"
#include "dma_ctrl.h"
#include "src_ctrl.h"
#include "ssif_ctrl.h"
#include "shuffle_play.h"
#ifdef USE_PRINTF
#include "scif_ctrl.h"
#endif

int main(void)
{
	set_vbr((void *)0x1c000000);
	init_clk();
	cache_enable();
	resbank_enable();	/* HEWデバッガのモニタROMで設定済みだがROMブートのため */

	init_led();
	init_cmt1();
	init_key();
	init_dma();
	init_src();
	init_ssif();
	init_ui();
	irq_enable();
	#ifdef USE_PRINTF
	init_scif();
	#endif

	printf("MP3 player SH-2A/CQ-Interface-2012\r\n");
	while(1)
	{
		if(0 == (disk_initialize(0) & (STA_NOINIT | STA_NODISK)))
		{
			FATFS fatfs;
			if(FR_OK == f_mount(0, &fatfs))
			{
				led_on();
				while(1)
				{
					if(shuffle_play("\0"))break;
				}
			}
			init_ui_disp();
		}
		printf("disk error\r\n");
		delay_ms(1000);
		led_toggle();
	}
}
