/*
 * MP3/AAC/WAV audio file player for LPC2388
 *   Written by Toshiharu Ohno
 */
#define _MACRO_ONLY
#include "nxpmp3.h"
#include "touch.h"
#include "gpdma.h"

INCLUDE("\"nxpmp3.h\"");
INCLUDE("\"touch.h\"");
CRE_TSK(MAIN_TASK, { TA_HLNG|TA_ACT, 0, main_task, 4,
			512, NULL });
CRE_TSK(WATCH_TASK, { TA_HLNG|TA_ACT, 0, ev_watcher, MAIN_PRIORITY,
			256, NULL });
CRE_TSK(TOUCH_TASK, { TA_HLNG|TA_ACT, 0, touch_task, MAIN_PRIORITY,
			384, NULL });
CRE_TSK(PCM_TASK,  {
	TA_HLNG | TA_ACT, 0,
	pcmsender_task,
	3,
	384,
	NULL
	});
CRE_TSK(TUNER_TASK,  {
	TA_HLNG, 0,
	tuner_listener,
	3,
	384,
	NULL
	});
/*
 * WARNING!!  DO NOT CHANGE LISTED ORDER OF BELOW THREE DECODER TASKS!!
 *   Three decoder tasks are intentionally listed in this order to
 *   reduce required stack size.
 */
CRE_TSK(WAVE_DECODER_TASK,  {
	TA_HLNG, 0,
	wavdecoder_task,
	4,
	512,
	NULL
	});
CRE_TSK(AAC_DECODER_TASK,  {
	TA_HLNG, 0,
	aacdecoder_task,
	4,
	384,
	NULL
	});
CRE_TSK(MP3_DECODER_TASK,  {
	TA_HLNG, 0,
	mp3decoder_task,
	4,
	256,
	NULL
	});
CRE_TSK(PLAYER_TASK,  {
	TA_HLNG | TA_ACT, 0,
	player_task,
	4,
	2048,
	NULL
	});
CRE_TSK(HOST_TASK,  {
	TA_HLNG | TA_ACT, 0,
	host_task,
	4,
	512,
	NULL
	});
CRE_TSK(CONSOLE_TASK,  {
	TA_HLNG | TA_ACT, 0,
	console_task,
	5,
	1024,
	NULL
	});

#include "./mci.cfg"
#include "../jsp/systask/timer.cfg"
#include "../jsp/systask/serial.cfg"
#include "../jsp/systask/logtask.cfg"

CRE_SEM(SEM_I2SIN,    {TA_TFIFO, 0, DMA_NBUF});
CRE_SEM(SEM_I2SOUT,   {TA_TFIFO, DMA_NBUF, DMA_NBUF});
CRE_SEM(SEM_PCMISO,   {TA_TFIFO, NUM_TD-1, NUM_TD-1});
CRE_SEM(SEM_LCD,      {TA_TFIFO, 1, 1});
CRE_MPF(MPF_PCM,      {TA_TFIFO, NPCMBUF, PCM_BSIZE*2+12, NULL});
CRE_SEM(SEM_SSP0,     {TA_TFIFO, 0, 1});
CRE_DTQ(DTQ_PCOM,     {TA_TFIFO, 2, NULL});
CRE_DTQ(DTQ_PCM,      {TA_TFIFO, NPCMBUF, NULL});
CRE_DTQ(DTQ_TUNER,    {TA_TFIFO, NPCMBUF, NULL});
CRE_FLG(FLG_EVENT,    {TA_TFIFO | TA_CLR, 0});
CRE_SEM(SEM_USBHOST,  {TA_TFIFO, 0, 1});
DEF_INH(INHNO_RTC,    {TA_HLNG, rtc_handler});
DEF_INH(INHNO_USB,    {TA_HLNG, Host_Isr});
DEF_INH(INHNO_EINT3,  {TA_HLNG, ads7846_handler});
DEF_INH(INHNO_SSP0,   {TA_HLNG, spi_handler});
DEF_INH(INHNO_TIMER0, {TA_HLNG, ir_handler});
CRE_CYC(CYCFATFS,     {TA_HLNG | TA_STA, 0, disk_timerproc, 100, 0 });
CRE_CYC(CYCBLIGHT,    {TA_HLNG | TA_STA, 0, s9705_restart, 500, 0 });
CRE_FLG(FLG_STOP_REQ, {TA_TFIFO | TA_CLR, 0});
CRE_FLG(FLG_STOP_RES, {TA_TFIFO | TA_CLR, 0});
CRE_FLG(FLG_USBHUB,   {TA_TFIFO | TA_CLR, 0});
CRE_MPF(MPF_TOUCH,    {TA_TFIFO, TOUCHQ_LEN+2, TOUCHEV_SIZE, NULL});
CRE_DTQ(DTQ_TOUCH,    {TA_TFIFO, TOUCHQ_LEN, NULL});
CRE_DTQ(DTQ_EVENT,    {TA_TFIFO, TOUCHQ_LEN, NULL});
/*
 * Initializations. Called before task starts.
 */
ATT_INI({TA_HLNG, 0, user_config});
