/************************************************/
/*      TASK02			task_m01.c	*/
/*	Rotary Encodor and Touch Sensor		*/
/*				mirs9503	*/
/************************************************/

#include"hard.h"

long lre_r, lre_l;

void inzt02()
{
	sys0(2, 0x1010);
	sys1(2, 4, 0, 0);
	sys2(2, 10, 0, 0);
	re_ts_init();

	lre_r = lre_l = 0;
	sys8(2, 1, 0);		/* re_r */
	sys8(2, 2, 0);		/* re_l */
	sys8(2, 3, 0);		/* RE_TS_DATA */
}

void nrmt02(a, b)
int a, b;
{}

void timt02(a, b)
int a, b;
{
	RE_TS_DATA re_ts;
	int re_r, re_l;
	int ts;

	re_ts = re_ts_data();
	lre_r += re_ts.r;
	lre_l -= re_ts.l;
	ts = re_ts.ts;

	re_r = lre_r / 255;		/* re_r [cm] */
	re_l = lre_l / 255;		/* re_l [cm] */

	sys8(2, 1, re_r);
	sys8(2, 2, re_l);
	sys8(2, 3, ts);
}

interrupt void intt02()
{}