#include "libsys.h"


int g_cnt;
void handler7(void)
{
	UINT32 *pGPIO0 = (UINT32*)SYS_GPIO0;
	UINT32 *pTim_stat = (UINT32*)SYS_ITIM_STAT;
	if (*pTim_stat & 1)
	{
		*pTim_stat = 1;
		*pGPIO0 = g_cnt++;
	}

}

int main (void)
{
	UINT32 *pTim_ctrl = (UINT32*)SYS_ITIM_CTRL;
	UINT32 *pTim_stat = (UINT32*)SYS_ITIM_STAT;
	UINT32 *pTim_cnt = (UINT32*)SYS_ITIM_CNT;
	UINT32 *pTim_cmp = (UINT32*)SYS_ITIM_CMP;
	UINT32 *pGPIO0 = (UINT32*)SYS_GPIO0;

	g_cnt = 1;
	*pGPIO0 = 0;

	interrupt_register(7, handler7);
	interrupt_enable(7);

	*pTim_cnt = 0;
	*pTim_cmp = 2000;
	*pTim_stat = 1;
	*pTim_ctrl = 3;

	while(1);

	return 0;
}

