示例#1
0
void Network::Spin()
{
	if(!active)
	{
		//ResetEther();
		return;
	}

	// Keep the Ethernet running

	ethernet_task();

	// Anything come in from the network to act on?

	if(!netRingGetPointer->Active())
		return;

	// Finished reading the active ring element?

	if(!netRingGetPointer->ReadFinished())
	{
		// No - Finish reading any data that's been received.

		if(inputPointer < inputLength)
			return;

		// Haven't started reading it yet - set that up.

		inputPointer = 0;
		inputLength = netRingGetPointer->Length();
		inputBuffer = netRingGetPointer->Data();
	}
}
示例#2
0
void Network::Spin()
{
	if (active)
	{
//		++inLwip;
		ethernet_task();			// keep the Ethernet running
//		--inLwip;

		// See if we can send anything
		RequestState* r = writingTransactions;
		if (r != NULL)
		{
			bool finished = r->Send();

			// Disable interrupts while we mess around with the lists in case we get a callback from a network ISR
			irqflags_t flags = cpu_irq_save();
			writingTransactions = r->next;

			if (finished)
			{
				RequestState *rn = r->nextWrite;
				r->nextWrite = NULL;
				HttpState *hs = r->hs;
				AppendTransaction(&freeTransactions, r);
				if (rn != NULL)
				{
					if (hs != NULL)
					{
						hs->sendingRs = (rn->hs == hs) ? rn : NULL;
					}
					AppendTransaction(&writingTransactions, rn);
				}
				else if (hs != NULL)
				{
					hs->sendingRs = NULL;
				}
			}
			else
			{
				AppendTransaction(&writingTransactions, r);
			}
			cpu_irq_restore(flags);
		}
	}
	else if (establish_ethernet_link())
	{
		start_ethernet(reprap.GetPlatform()->IPAddress(), reprap.GetPlatform()->NetMask(), reprap.GetPlatform()->GateWay());
		httpd_init();
		active = true;
	}
}
/**
 * \brief Main program function. Configure the hardware, initialize lwIP
 * TCP/IP stack, and start HTTP service.
 */
int main(void)
{
	/* Initialize the SAM system. */
	system_init();
	delay_init();

	/* Setup USART module to output results */
	setup_usart_channel();

	/* Print example information. */
	puts(STRING_HEADER);

	/* Bring up the ethernet interface & initialize timer0, channel0. */
	init_ethernet();

	/* Bring up the web server. */
	httpd_init();

	/* Program main loop. */
	while (1) {
		/* Check for input packet and process it. */
		ethernet_task();
	}
}
示例#4
0
/**
 * \brief Main program function. Configure the hardware, initialize lwIP
 * TCP/IP stack, and start HTTP service.
 */
int main(void)
{
	/* Initialize the SAM system. */
	sysclk_init();
	board_init();

	/* Configure debug UART */
	configure_console();

	/* Print example information. */
	puts(STRING_HEADER);

	/* Bring up the ethernet interface & initialize timer0, channel0. */
	init_ethernet();

	/* Bring up the web server. */
	httpd_init();

	/* Program main loop. */
	while (1) {
		/* Check for input packet and process it. */
		ethernet_task();
	}
}