#include <tk/tkernel.h>
#include <tm/tmonitor.h>

#include "fsl_debug_console.h"

LOCAL void task_1(INT stacd, void *exinf);	// task execution function
LOCAL ID	tskid_1;			// Task ID number
LOCAL T_CTSK ctsk_1 = {				// Task creation information
	.itskpri	= 10,
	.stksz		= 1024,
	.task		= task_1,
	.tskatr		= TA_HLNG | TA_RNG3,
};

LOCAL void task_1(INT stacd, void *exinf)
{
	INT	cnt = 0;
	while(1) {
		switch (cnt++) {
		case 0:
			out_w(GPIO_PCOR(0), (1<<10));
			out_w(GPIO_PSOR(0), (1<<27));
			out_w(GPIO_PSOR(1), (1<<2));
			break;
		case 1:
			out_w(GPIO_PSOR(0), (1<<10));
			out_w(GPIO_PCOR(0), (1<<27));
			out_w(GPIO_PSOR(1), (1<<2));
			break;
			
		case 2:
			out_w(GPIO_PSOR(0), (1<<10));
			out_w(GPIO_PSOR(0), (1<<27));
			out_w(GPIO_PCOR(1), (1<<2));
			cnt = 0;
			break;
		}
		tk_dly_tsk(500);
	}
}

/* usermain関数 */
EXPORT INT usermain(void)
{
	tskid_1 = tk_cre_tsk(&ctsk_1);		// Create Task
	tk_sta_tsk(tskid_1, 0);			// Start Task

	tk_slp_tsk(TMO_FEVR);

	return 0;
}
