/*..........................................................................*/
void BSP_init(void) {
	SystemInit();         /* initialize STM32 system (clock, PLL and Flash) */

	/* initialize LEDs on Olimex P207 eval board */
	omxEval_led_init();

	/* initialize LCD on Olimex P207 eval board */
  InitLcd();

  /* initialize RS-232 serial port on Olimex P207 eval board */
  omxEval_rs232_init();

	/* initialize LEDs, Key Button, and LCD on STM322XX-EVAL board */
	// alu: TODO BSP_ButtonAndLED_Init();

	/* initialize the Serial for printfs to the serial port */
	// alu: TODO BSP_USART_Init();

	/* initialize the EXTI Line0 interrupt used for testing */
	// alu: TODO BSP_EXTI_Init();

	/* initialize the ETH GPIO */
	ETH_GPIO_Config();

	/* initialize the ETH MACDMA */
	ETH_MACDMA_Config();

	QS_OBJ_DICTIONARY(&l_SysTick_Handler);
}
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  RCC_ClocksTypeDef RCC_Clocks;
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

#ifdef USE_LCD
  if (EthInitStatus == 0)
  {
    LCD_SetTextColor(Red);
    LCD_DisplayStringLine(Line5, (uint8_t*)"   Ethernet Init   ");
    LCD_DisplayStringLine(Line6, (uint8_t*)"      failed      ");
    while(1);
  }
#endif

  /* Configure the PHY to generate an interrupt on change of link status */
  Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

  /* Configure the EXTI for Ethernet link status. */
  Eth_Link_EXTIConfig();
  
  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);  
}
/**
 * @brief  ETH_BSP_Config
 * @param  None
 * @retval None
 */
void ETH_BSP_Config(void) {
	/***************************************************************************
	 NOTE:
	 When using Systick to manage the delay in Ethernet driver, the Systick
	 must be configured before Ethernet initialization and, the interrupt
	 priority should be the highest one.
	 *****************************************************************************/

	/* Configure the GPIO ports for ethernet pins */
	ETH_GPIO_Config();

	/* Configure the Ethernet MAC/DMA */
	ETH_MACDMA_Config();

	/* Get Ethernet link status*/
	if (ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_SR ) & 1) {
		EthStatus |= ETH_LINK_FLAG;
	}

	/* Configure the PHY to generate an interrupt on change of link status */
	Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

	/* Configure the EXTI for Ethernet link status. */
	Eth_Link_EXTIConfig();
}
/**
 * @brief  ETH_BSP_Config
 * @param  None
 * @retval None
 */
void ETH_BSP_Config(void) {
	RCC_ClocksTypeDef RCC_Clocks;

	/* Configure the GPIO ports for ethernet pins */
	ETH_GPIO_Config();

	/* Configure the Ethernet MAC/DMA */
	ETH_MACDMA_Config();

	if (EthInitStatus == 0) {
		printf("   Ethernet Init  \n ");
		printf("      failed      \n");
		while (1)
			;
	}

	/* Configure the PHY to generate an interrupt on change of link status */
	Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

	/* Configure the EXTI for Ethernet link status. */
	Eth_Link_EXTIConfig();

	/* Configure Systick clock source as HCLK */
	SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

	/* SystTick configuration: an interrupt every 10ms */
	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
}
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();

  /* Config NVIC for Ethernet */
  //ETH_NVIC_Config();

  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  /* Get Ethernet link status*/
  if(ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_SR) & 1)
  {
    EthStatus |= ETH_LINK_FLAG;
  }

  /* Configure the PHY to generate an interrupt on change of link status */
  Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

  /* Configure the EXTI for Ethernet link status. */
  Eth_Link_EXTIConfig();
  
  if (ETH_link_xSemaphore == NULL)
  {
    /* create binary semaphore used for ETH_link handling */
    vSemaphoreCreateBinary( ETH_link_xSemaphore );
  }

  /* create the task that handles the ETH_link */
  xTaskCreate(Eth_Link_IT_task, (signed char*) "E_link", ETH_LINK_TASK_STACK_SIZE, (void *)DP83848_PHY_ADDRESS,
              ETH_LINK_TASK_PRIORITY,NULL);
}
示例#6
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  RCC_ClocksTypeDef RCC_Clocks;
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  if (EthInitStatus == 0)
  {
    LCD_SetTextColor(LCD_COLOR_RED);
    LCD_DisplayStringLine(LINE(5), (uint8_t*)"   Ethernet Init   ");
    LCD_DisplayStringLine(LINE(6), (uint8_t*)"      failed      ");
    while(1);
  }
  
  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);  
}
示例#7
0
/**
 * @brief Late initialization after heap and global initializations.
 */
void late_init()
{
	/**
	 * Open the standard I/O.
	 */
	 caribou_uart_config_t config;
	_stdout = _stdin = _stderr = fopen(CONSOLE_USART,"rw");
	caribou_uart_init_config(&config);
	config.baud_rate	= CARIBOU_UART_BAUD_RATE_115200;
	config.word_size	= CARIBOU_UART_WORDSIZE_8;
	config.stop_bits	= CARIBOU_UART_STOPBITS_1;
	config.parity_bits	= CARIBOU_UART_PARITY_NONE;
	config.flow_control	= /* CARIBOU_UART_FLOW_NONE */ CARIBOU_UART_FLOW_RTS_CTS;
	caribou_uart_set_config(CONSOLE_USART,&config);

	#if 0
		caribou_vector_install(ETH_LINK_EXTI_IRQn,isr_phy_eth0,&network_interface.phyAddress);
		caribou_vector_install(ETH_IRQn,isr_eth0,NULL);

		/* Configure the Ethernet MAC/DMA */
		ETH_MACDMA_Config();
		/* Configure the PHY to generate an interrupt on change of link status */
		Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);
		/* Configure the EXTI for Ethernet link status. */
		Eth_Link_EXTIConfig();
		/* Enable the interrupt vectors... */
		caribou_vector_enable(ETH_LINK_EXTI_IRQn);
		caribou_vector_enable(ETH_IRQn);
	#endif

		caribou_gpio_set(&led1);
		caribou_gpio_set(&led2);
		caribou_gpio_set(&led3);
		caribou_gpio_set(&led4);
}
示例#8
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{

  RCC_ClocksTypeDef RCC_Clocks;
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();
  
  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);  
}
示例#9
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Config NVIC for Ethernet */
  ETH_NVIC_Config();

  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  if (EthInitStatus == 0) {
    LCD_SetTextColor(LCD_COLOR_RED);
    LCD_DisplayStringLine(Line5, (uint8_t*)"   Ethernet Init   ");
    LCD_DisplayStringLine(Line6, (uint8_t*)"      failed      ");
    while(1);
  }
}
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  RCC_ClocksTypeDef RCC_Clocks;

  /***************************************************************************
    NOTE: 
         When using Systick to manage the delay in Ethernet driver, the Systick
         must be configured before Ethernet initialization and, the interrupt 
         priority should be the highest one.
  *****************************************************************************/

  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

  /* Set Systick interrupt priority to 0*/
  NVIC_SetPriority (SysTick_IRQn, 0);

  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();

  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  /* Get Ethernet link status*/
  if(ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_SR) & 1)
  {
  	//printf("link\n");
    EthStatus |= ETH_LINK_FLAG;
  }
  //else
  	//printf("unlink\n");

  /* Configure the PHY to generate an interrupt on change of link status */
  Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

  /* Configure the EXTI for Ethernet link status. */
  Eth_Link_EXTIConfig(); 
}
示例#11
0
void rt_hw_stm32_eth_init(void)
{
	GPIO_Configuration();
	NVIC_Configuration();
	ETH_MACDMA_Config();

    stm32_eth_device.dev_addr[0] = 0x00;
    stm32_eth_device.dev_addr[1] = 0x60;
    stm32_eth_device.dev_addr[2] = 0x6e;
	{
		uint32_t cpu_id[3] = {0};
		cpu_id[2] = DevID_SNo2; cpu_id[1] = DevID_SNo1; cpu_id[0] = DevID_SNo0;
		
		// generate MAC addr from 96bit unique ID (only for test)
		stm32_eth_device.dev_addr[3] = (uint8_t)((cpu_id[0]>>16)&0xFF);
	    stm32_eth_device.dev_addr[4] = (uint8_t)((cpu_id[0]>>8)&0xFF);
	    stm32_eth_device.dev_addr[5] = (uint8_t)(cpu_id[0]&0xFF);

//	    stm32_eth_device.dev_addr[3] = *(rt_uint8_t*)(0x1FFF7A10+7);
//	    stm32_eth_device.dev_addr[4] = *(rt_uint8_t*)(0x1FFF7A10+8);
//	    stm32_eth_device.dev_addr[5] = *(rt_uint8_t*)(0x1FFF7A10+9);
	}

	stm32_eth_device.parent.parent.init       = rt_stm32_eth_init;
	stm32_eth_device.parent.parent.open       = rt_stm32_eth_open;
	stm32_eth_device.parent.parent.close      = rt_stm32_eth_close;
	stm32_eth_device.parent.parent.read       = rt_stm32_eth_read;
	stm32_eth_device.parent.parent.write      = rt_stm32_eth_write;
	stm32_eth_device.parent.parent.control    = rt_stm32_eth_control;
	stm32_eth_device.parent.parent.user_data  = RT_NULL;

	stm32_eth_device.parent.eth_rx     = rt_stm32_eth_rx;
	stm32_eth_device.parent.eth_tx     = rt_stm32_eth_tx;

	/* init tx semaphore */
	rt_sem_init(&tx_wait, "tx_wait", 1, RT_IPC_FLAG_FIFO);

	/* register eth device */
	eth_device_init(&(stm32_eth_device.parent), "e0");
}
示例#12
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  RCC_ClocksTypeDef RCC_Clocks;

  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();

  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  if (EthInitStatus == 0) {
    printf("\n\rETH init failed\r\n");
    while(1);
  }

  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms SDB: change to 5 mS*/
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 2000);
}
示例#13
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Config NVIC for Ethernet */
  ETH_NVIC_Config();

  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  if (EthInitStatus == 0)
  {
    while(1);
  }

  /* Configure the PHY to generate an interrupt on change of link status */
  Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);

  /* Configure the EXTI for Ethernet link status. */
  Eth_Link_EXTIConfig();
}
示例#14
0
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
#if 0
  RCC_ClocksTypeDef RCC_Clocks;
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();

  if (EthInitStatus == 0)
  {
    _printf("Ethernet Init failed\n");
    while(1);
  }

  /* Configure the PHY to generate an interrupt on change of link status */
  //Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);
  Eth_Link_PHYITConfig(KS8721_PHY_ADDRESS);

  /* Configure the EXTI for Ethernet link status. */
  //Eth_Link_EXTIConfig();
#else

	ETH_InitTypeDef ETH_InitStructure;

	/* Enable ETHERNET clocks  */
	RCC_AHB1PeriphClockCmd(	  RCC_AHB1Periph_ETH_MAC
							| RCC_AHB1Periph_ETH_MAC_Tx
							| RCC_AHB1Periph_ETH_MAC_Rx
							| RCC_AHB1Periph_ETH_MAC_PTP, ENABLE);

	/* Enable SYSCFG clock */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

	/*Select RMII Interface*/
	SYSCFG_ETH_MediaInterfaceConfig(SYSCFG_ETH_MediaInterface_RMII);

	/* Reset ETHERNET on AHB Bus */
	ETH_DeInit();

	/* Software reset */
	ETH_SoftwareReset();

	/* Wait for software reset */
	while (ETH_GetSoftwareResetStatus() == SET);

	/* ETHERNET Configuration ------------------------------------------------------*/
	/* Call ETH_StructInit if you don't like to configure all ETH_InitStructure parameter */
	ETH_StructInit(&ETH_InitStructure);

	/* Fill ETH_InitStructure parametrs */
	/*------------------------   MAC   -----------------------------------*/
	ETH_InitStructure.ETH_AutoNegotiation			= ETH_AutoNegotiation_Disable  ;
	ETH_InitStructure.ETH_Speed						= ETH_Speed_100M;
	ETH_InitStructure.ETH_LoopbackMode				= ETH_LoopbackMode_Disable;
	ETH_InitStructure.ETH_Mode						= ETH_Mode_FullDuplex;
	ETH_InitStructure.ETH_RetryTransmission			= ETH_RetryTransmission_Disable;
	ETH_InitStructure.ETH_AutomaticPadCRCStrip		= ETH_AutomaticPadCRCStrip_Disable;
	ETH_InitStructure.ETH_ReceiveAll				= ETH_ReceiveAll_Enable;
	ETH_InitStructure.ETH_BroadcastFramesReception	= ETH_BroadcastFramesReception_Disable;
	ETH_InitStructure.ETH_PromiscuousMode			= ETH_PromiscuousMode_Disable;
	ETH_InitStructure.ETH_MulticastFramesFilter		= ETH_MulticastFramesFilter_Perfect;
	ETH_InitStructure.ETH_UnicastFramesFilter		= ETH_UnicastFramesFilter_Perfect;

	unsigned int PhyAddr;
	uint16_t reg2;
	uint16_t reg3;

	// read the ID for match
	for (PhyAddr = 1; 32 >= PhyAddr; PhyAddr++)
	{
		reg2 = ETH_ReadPHYRegister(PhyAddr,2);	//PHY_MICR_INT_EN ?
		reg3 = ETH_ReadPHYRegister(PhyAddr,3);

		if ((reg2 == 0x0022) && (reg3 == 0x1609))
			break;
	}

	if (PhyAddr > 32)
	{
		_CONSOLE(LogId, "Ethernet Phy Not Found\n\r");
		return;// 1;
	}

	/* Configure Ethernet */
	if (ETH_Init(&ETH_InitStructure, PhyAddr) == 0)
	{
		_CONSOLE(LogId, "Ethernet Initialization Failed\n\r");
		return;// 1;
	}

	_CONSOLE(LogId, "Check LAN LEDs\n\r");
  
#endif
}
/**
  * @brief  ETH_BSP_Config
  * @param  None
  * @retval None
  */
void ETH_BSP_Config(void)
{
  RCC_ClocksTypeDef RCC_Clocks;
  
  /* Configure the GPIO ports for ethernet pins */
  ETH_GPIO_Config();
  
  /* Configure the Ethernet MAC/DMA */
  ETH_MACDMA_Config();
	

  if (EthInitStatus == 0)
  {
		
		__IO uint32_t timeout = 0;
		
    //LCD_String(20,50,"   Ethernet Init   ",RED);
    //LCD_String(20,80,"      failed      ",RED);
		printf("\n\r Ethernet Init failed\n\r");
    //while(1);
		while(EthInitStatus == 0)
		{
			phy_r0 = ETH_ReadPHYRegister(0, 0) ;
      phy_r1 = ETH_ReadPHYRegister(0, 1) ;
      phy_r2 = ETH_ReadPHYRegister(0, 2) ;
      phy_r3 = ETH_ReadPHYRegister(0, 3) ;
      phy_r4 = ETH_ReadPHYRegister(0, 4) ;
      phy_r5 = ETH_ReadPHYRegister(0, 5) ;
      phy_r6 = ETH_ReadPHYRegister(0, 6) ;
      phy_r17 = ETH_ReadPHYRegister(0, 17) ;
      phy_r18 = ETH_ReadPHYRegister(0, 18) ;
      phy_r26 = ETH_ReadPHYRegister(0, 26) ;
      phy_r27 = ETH_ReadPHYRegister(0, 27) ;
      phy_r29 = ETH_ReadPHYRegister(0, 29) ;
      phy_r30 = ETH_ReadPHYRegister(0, 30) ;
      phy_r31 = ETH_ReadPHYRegister(0, 31) ;
			
			 if(!(ETH_WritePHYRegister(0, PHY_BCR, PHY_Loopback|PHY_AutoNegotiation|PHY_FullDuplex)))
      {
        /* Return ERROR in case of write timeout */
            ;
      }
	     
			 do
      {
          timeout++;
      } while (!(ETH_ReadPHYRegister(0, PHY_BSR) & PHY_Linked_Status) && (timeout < PHY_READ_TO));

		
			
		}
		
  }
  
  /* Configure Systick clock source as HCLK */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SystTick configuration: an interrupt every 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); 
}
//LAN8720初始化
//返回值:0,成功;
//    其他,失败
uint8_t bsp_InitLan8720(void)
{
	uint8_t rval=0;
	GPIO_InitTypeDef GPIO_InitStructure;
  
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOB , ENABLE);//使能GPIO时钟 RMII接口
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);   //使能SYSCFG时钟
  
	SYSCFG_ETH_MediaInterfaceConfig(SYSCFG_ETH_MediaInterface_RMII); //MAC和PHY之间使用RMII接口

	/*网络引脚设置 RMII接口 
	  ETH_MDIO -------------------------> PA2
	  ETH_MDC --------------------------> PC1
	  ETH_RMII_REF_CLK------------------> PA1
	  ETH_RMII_CRS_DV ------------------> PA7
	  ETH_RMII_RXD0 --------------------> PC4
	  ETH_RMII_RXD1 --------------------> PC5
	  ETH_RMII_TX_EN -------------------> PB11
	  ETH_RMII_TXD0 --------------------> PB12
	  ETH_RMII_TXD1 --------------------> PB13
	  ETH_RESET-------------------------> PA0*/
					
	  //配置PA1 PA2 PA7
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_7;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;  
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_ETH); //引脚复用到网络接口上
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_ETH);
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_ETH);

	//配置PC1,PC4 and PC5
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5;
	GPIO_Init(GPIOC, &GPIO_InitStructure);
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource1, GPIO_AF_ETH); //引脚复用到网络接口上
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_ETH);
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);
                                
	//配置PG11, PG14 and PG13 
	GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_ETH);
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource12, GPIO_AF_ETH);
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_ETH);
	
	//配置PD3为推完输出
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;	//推完输出
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;  
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	LAN8720_CLR;					//硬件复位LAN8720
	bsp_DelayMS(50);	
	LAN8720_SET;				 	//复位结束 
	ETHERNET_NVICConfiguration();
	rval=ETH_MACDMA_Config();
	return !rval;					//ETH的规则为:0,失败;1,成功;所以要取反一下 
}