示例#1
0
/**
 * In this function, the hardware should be initialized.
 * Called from ethernetif_init().
 *
 * @param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void
low_level_init(struct netif *netif)
{
    portBASE_TYPE result;
//  struct ethernetif *ethernetif = netif->state;

    /* set MAC hardware address length */
    netif->hwaddr_len = ETHARP_HWADDR_LEN;

    /* set MAC hardware address */
    netif->hwaddr[5] = MYMAC_1;
    netif->hwaddr[4] = MYMAC_2;
    netif->hwaddr[3] = MYMAC_3;
    netif->hwaddr[2] = MYMAC_4;
    netif->hwaddr[1] = MYMAC_5;
    netif->hwaddr[0] = MYMAC_6;

    /* maximum transfer unit */
    netif->mtu = ETH_MTU;

    /* device capabilities */
    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
    netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
    /* Do whatever else is needed to initialize interface. */
    semEthTx = xSemaphoreCreateCounting((unsigned portBASE_TYPE) NUM_TX_FRAG,(unsigned portBASE_TYPE) NUM_TX_FRAG);
    semEthRx = xSemaphoreCreateCounting((unsigned portBASE_TYPE) NUM_RX_FRAG,(unsigned portBASE_TYPE) 0);

    if(semEthTx == NULL) {
        LWIP_DEBUGF(NETIF_DEBUG,("Semaphore for ETH transmit created failed !\n\r"));
    };
    if(semEthRx == NULL) {
        LWIP_DEBUGF(NETIF_DEBUG,("Semaphore for ETH recive created failed !\n\r"));
    };

    result = xTaskCreate( ethernetif_input, ( signed portCHAR * ) "EhtTsk", sizeEthif, (void *)netif, prioEthif, &xETHTsk );

    if(result != pdPASS) {
        LWIP_DEBUGF(NETIF_DEBUG,("Task for ETH recive created failed !\n\r "));
    };

    Init_EMAC();
}
示例#2
0
文件: init.c 项目: rngadam/mboot
int main(void)
{
	BTNDIS_P();
	Init_EMIF();
	Init_LEDS();
	Init_TIMER();
	Init_FPGA();
	Init_UART();
	Init_TWI(100000);
	
	mbootBanner();
	
	Init_RTC();
	Init_Media();
	Init_SHA204();
	Init_EMAC();
	SYS_UNRESET();
	
	mboot();

	while(1);
	// return 0;
}
示例#3
0
void vuIP_Task( void *pvParameters )
{
portBASE_TYPE i;
uip_ipaddr_t xIPAddr;
struct timer periodic_timer, arp_timer;
extern void ( vEMAC_ISR_Wrapper )( void );

	/* Create the semaphore used by the ISR to wake this task. */
	vSemaphoreCreateBinary( xEMACSemaphore );
	
	/* Initialise the uIP stack. */
	timer_set( &periodic_timer, configTICK_RATE_HZ / 2 );
	timer_set( &arp_timer, configTICK_RATE_HZ * 10 );
	uip_init();
	uip_ipaddr( xIPAddr, uipIP_ADDR0, uipIP_ADDR1, uipIP_ADDR2, uipIP_ADDR3 );
	uip_sethostaddr( xIPAddr );
	httpd_init();

	/* Initialise the MAC. */
	while( Init_EMAC() != pdPASS )
    {
        vTaskDelay( uipINIT_WAIT );
    }

	portENTER_CRITICAL();
	{
		MAC_INTENABLE = INT_RX_DONE;
        VICIntEnable |= 0x00200000;
        VICVectAddr21 = ( portLONG ) vEMAC_ISR_Wrapper;
		prvSetMACAddress();
	}
	portEXIT_CRITICAL();
	

	for( ;; )
	{
		/* Is there received data ready to be processed? */
		uip_len = uiGetEMACRxData( uip_buf );
		
		if( uip_len > 0 )
		{
			/* Standard uIP loop taken from the uIP manual. */
			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
			{
				uip_arp_ipin();
				uip_input();

				/* If the above function invocation resulted in data that 
				should be sent out on the network, the global variable 
				uip_len is set to a value > 0. */
				if( uip_len > 0 )
				{
					uip_arp_out();
					prvENET_Send();
				}
			}
			else if( xHeader->type == htons( UIP_ETHTYPE_ARP ) )
			{
				uip_arp_arpin();

				/* If the above function invocation resulted in data that 
				should be sent out on the network, the global variable 
				uip_len is set to a value > 0. */
				if( uip_len > 0 )
				{
					prvENET_Send();
				}
			}
		}
		else
		{
			if( timer_expired( &periodic_timer ) )
			{
				timer_reset( &periodic_timer );
				for( i = 0; i < UIP_CONNS; i++ )
				{
					uip_periodic( i );
	
					/* If the above function invocation resulted in data that 
					should be sent out on the network, the global variable 
					uip_len is set to a value > 0. */
					if( uip_len > 0 )
					{
						uip_arp_out();
						prvENET_Send();
					}
				}	
	
				/* Call the ARP timer function every 10 seconds. */
				if( timer_expired( &arp_timer ) )
				{
					timer_reset( &arp_timer );
					uip_arp_timer();
				}
			}
			else
			{			
				/* We did not receive a packet, and there was no periodic
				processing to perform.  Block for a fixed period.  If a packet
				is received during this period we will be woken by the ISR
				giving us the Semaphore. */
				xSemaphoreTake( xEMACSemaphore, configTICK_RATE_HZ / 2 );			
			}
		}
	}
}
		virtual bool init()
		{
			Init_EMAC();
			return true;
		}