예제 #1
0
void main()					//主函数
{
	init_dsp(); 			//dsp初始化

	zhiling();				//学习指令

	while(1)				//大循环
	{
		LED_flash();       	//灯闪烁
	}
}  
예제 #2
0
void main()
{
	/* configures the function of the A/D port pins
	 * (ports A and E to digital I/Os) */
	ADCON1=7;		

	TRISD=0x0f;	/* 00001111 -> RD4:RD7 as outputs */
	TRISE=3;	/* 111 -> RE0:RE2 outputs */
	PORTE=4;
	PORTD=0;
	
	/* set the activity LED bit as an output */
	TRISC&=0xf7;
	/* make sure LED is off	*/
	LEDPORT|=0x08;
	/* then flash it 3 times */
	LED_flash(3);
	/* initialise USART interrupts */
	SerIntInit();

	/* enter main program loop */
	while(1)
	{
		/* There's a packet waiting in the buffer.. IP layer
		 * flag is set so we can return up the stack, rather than processing
		 * the packet within the interrupt routine */
		if (rxstate == RXDONE)
		{
			/* call on the IP layer to process awaiting packet */
			ip_receive();
			/* serial line IDLE again */
			rxstate=RXIDLE;
			/* packet has been sent */
			txpos=0;
		}

		/* Interrrupt routine has been trggered since last here, 
		 * there is at least one byte waiting in the USART receive
		 * buffer - call on the SLIP layer to process and add to
		 * stack buffer */
		if (GetRxSize()) slip_recv();
		
		/* ensure activity LED is off */
		LEDPORT|=0x08;
		
		/* TCP counter, used for Initial Sequence Numbers */
		if (tcpcounter == 2147483646) {
			tcpcounter=0;
		}
		tcpcounter++;
	}
}