void W5500HardwareInitilize(void)
{
  __GPIOH_CLK_ENABLE();
  /*W5500 CS/INT/RST Clock enable*/
  __GPIOB_CLK_ENABLE();
  __GPIOC_CLK_ENABLE();
  
  /*W5500 GPIO&SPI1 Clock enable*/
  __GPIOA_CLK_ENABLE();
  
  /*Initialize GPIO Structure*/
  GPIO_InitTypeDef	GPIO_InitStructure;

  /*Initialize CS Pin*/
  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStructure.Pin = W5500_CS_PIN;
  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(W5500_CS_PORT,&GPIO_InitStructure);
  
  /*Initialize INT Pin*/
  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStructure.Pin = W5500_INT_PIN;
  GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(W5500_INT_PORT,&GPIO_InitStructure);

  /*Ethernet shield does not have individual reset pin*/
  /* ==> Remove R23 and connect RSTN - D9 pin
        Now D9 is Reset pin.*/
  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStructure.Pin = W5500_RESET_PIN;
  GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(W5500_RESET_PORT,&GPIO_InitStructure);
  
  /*SPI init*/
  hspi1W5500.Instance = W5500_SPI;
  hspi1W5500.Init.Mode = SPI_MODE_MASTER;
  hspi1W5500.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1W5500.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1W5500.Init.CLKPolarity = SPI_POLARITY_HIGH;
  hspi1W5500.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi1W5500.Init.NSS = SPI_NSS_SOFT;
  hspi1W5500.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
  hspi1W5500.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1W5500.Init.TIMode = SPI_TIMODE_DISABLED;
  hspi1W5500.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
  hspi1W5500.Init.CRCPolynomial = 10;
  HAL_SPI_Init(&hspi1W5500);
  
  W5500HardwareReset();
}
void W5500HardwareInitilize(void)
{
	/*Initialize Structure*/
	GPIO_InitTypeDef	GPIO_InitStructure;
	SPI_InitTypeDef		SPI_InitStructure;
	EXTI_InitTypeDef	EXTI_InitStructure;
	NVIC_InitTypeDef	NVIC_InitStructure;

	/*Enable clock related Periphs*/
	RCC_APB2PeriphClockCmd(W5500_SPI_RCC,ENABLE);
	RCC_APB2PeriphClockCmd(W5500_GPIO_RCC,ENABLE);

	/*Initialize CLK Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_CLK_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(W5500_CLK_PORT,&GPIO_InitStructure);

	/*Initialize MOSI Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_MOSI_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(W5500_MOSI_PORT,&GPIO_InitStructure);

	/*Initialize MISO Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_MISO_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(W5500_MISO_PORT,&GPIO_InitStructure);

	/*Initialize CS Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_CS_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(W5500_CS_PORT,&GPIO_InitStructure);

	/*Initialize Reset Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_RESET_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(W5500_RESET_PORT,&GPIO_InitStructure);

	/*Initialize INT Pin*/
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = W5500_INT_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_Init(W5500_INT_PORT,&GPIO_InitStructure);

	/*Initialize SPI*/
	SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
	SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
	SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
	SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
	SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
	SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
	SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
	SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
	SPI_InitStructure.SPI_CRCPolynomial = 7;
	SPI_Init(W5500_SPI, &SPI_InitStructure);

	SPI_Cmd(W5500_SPI, ENABLE);

	W5500HardwareReset();
}