Exemple #1
0
static int serialtest()
{
	int i,j;

	printf("serial test\n");
	initserial(0);
	initserial(1);
	
	for(i=0;i<16;i++)
	{
	if(testDebugChar(0))getDebugChar(0);
	else break;
	}

	for(i=0;i<16;j++)
	{
	if(testDebugChar(1))getDebugChar(1);
	else break;
	}

	printf("serial 0 send data to serial 1...");
	for(i=0;i<10;i++)
	{
	putDebugChar(0,'a'+i);
	for(j=0;j<TIMEOUT;j++)
	{
	if(testDebugChar(1))break;
	}
	if(j==TIMEOUT){printf("timeout");break;}
	printf("%c",getDebugChar(1));
	}
	printf("\n");

	for(i=0;i<16;i++)
	{
	if(testDebugChar(0))getDebugChar(0);
	else break;
	}

	for(i=0;i<16;j++)
	{
	if(testDebugChar(1))getDebugChar(1);
	else break;
	}
	printf("serial 1 send data to serial 0...");

	for(i=0;i<10;i++)
	{
	putDebugChar(1,'a'+i);
	for(j=0;j<TIMEOUT;j++)
	{
	if(testDebugChar(0))break;
	}
	if(j==TIMEOUT){printf("timeout");break;}
	printf("%c",getDebugChar(0));
	}
	printf("\n");
	return 0;
}
Exemple #2
0
int main() {
	bool newreadings;
	bool buttonschanged;

	load_init();
	initsystem();
	watchdog_init();
	initserial();
	timer_init();
	display_init();
	initfan();
	adc_init();

	buttons_init();

	enableInterrupts();

	protocol_onbooted();

	while (1) {
		watchdog_kick();
		newreadings = adc_updatereadings();
		if (newreadings) {
			checkstate();
		}
		buttonschanged = buttons_check();
		if (newreadings || buttonschanged) {
			protocol_sendstate();
			display_update();
		}

		protocol_checkcommand();
	}
}
Exemple #3
0
static int cmd_serial(int argc,char **argv)
{
int line;
if(argc!=3)return -1;
line=argv[2][0]-'0';

switch(argv[1][0])
{
case 'i':
	initserial(line);
	break;
case 'r':
	printf("%c\n",getDebugChar(line));break;
case 'w':
	putDebugChar(line,'a');
	break;
case 't':
	printf("%d\n",testDebugChar(line));
	break;
}
return 0;	
	
}