/**
  * @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);  
}
Ejemplo n.º 2
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("   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);
}
/*..........................................................................*/
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);
}
Ejemplo n.º 4
0
/**
 * @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();
}
Ejemplo n.º 5
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);  
}
/**
  * @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);
}
Ejemplo n.º 7
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);  
}
Ejemplo n.º 8
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);
  }
}
Ejemplo n.º 9
0
/**
  * @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(); 
}
Ejemplo n.º 10
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);
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 12
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
}
Ejemplo n.º 13
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)
  {
		
		__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); 
}