error_t lan8720Init(NetInterface *interface) { //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Reset PHY transceiver (soft reset) lan8720WritePhyReg(interface, LAN8720_PHY_REG_BMCR, BMCR_RESET); //Wait for the reset to complete while(lan8720ReadPhyReg(interface, LAN8720_PHY_REG_BMCR) & BMCR_RESET); //Dump PHY registers for debugging purpose lan8720DumpPhyReg(interface); //Successful initialization return NO_ERROR; }
error_t lan8720Init(NetInterface *interface) { //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Reset PHY transceiver (soft reset) lan8720WritePhyReg(interface, LAN8720_PHY_REG_BMCR, BMCR_RESET); //Wait for the reset to complete while(lan8720ReadPhyReg(interface, LAN8720_PHY_REG_BMCR) & BMCR_RESET); //Dump PHY registers for debugging purpose lan8720DumpPhyReg(interface); //Force the TCP/IP stack to poll the link state at startup interface->phyEvent = TRUE; //Notify the TCP/IP stack of the event osSetEvent(&netEvent); //Successful initialization return NO_ERROR; }
error_t lan8720Init(NetInterface *interface) { //STM32F4-DISCOVERY evaluation board? #if defined(USE_STM32F4_DISCOVERY) GPIO_InitTypeDef GPIO_InitStructure; //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Enable GPIOE clock RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); //Configure PE2 (PHY_RST) pin as an output GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOE, &GPIO_InitStructure); //Reset PHY transceiver (hard reset) GPIO_ResetBits(GPIOE, GPIO_Pin_2); sleep(10); GPIO_SetBits(GPIOE, GPIO_Pin_2); sleep(10); #endif //Reset PHY transceiver (soft reset) lan8720WritePhyReg(interface, LAN8720_PHY_REG_BMCR, BMCR_RESET); //Wait for the reset to complete while(lan8720ReadPhyReg(interface, LAN8720_PHY_REG_BMCR) & BMCR_RESET); //Dump PHY registers for debugging purpose lan8720DumpPhyReg(interface); //Successful initialization return NO_ERROR; }
error_t lan8720Init(NetInterface *interface) { //LPC1830-Xplorer evaluation board? #if defined(USE_LPC1830_XPLORER) //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Enable GPIO peripheral clock LPC_CCU1->CLK_M3_GPIO_CFG |= CCU1_CLK_M3_GPIO_CFG_RUN_Msk; while(!(LPC_CCU1->CLK_M3_GPIO_STAT & CCU1_CLK_M3_GPIO_STAT_RUN_Msk)); //Configure P1.0 as a general purpose output LPC_SCU->SFSP1_0 = 0; LPC_GPIO_PORT->DIR[0] |= (1 << 4); //Reset PHY transceiver (hard reset) LPC_GPIO_PORT->CLR[0] = (1 << 4); sleep(10); LPC_GPIO_PORT->SET[0] = (1 << 4); sleep(10); //LPC4330-Xplorer evaluation board? #elif defined(USE_LPC4330_XPLORER) //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Enable GPIO peripheral clock LPC_CCU1->CLK_M4_GPIO_CFG |= CCU1_CLK_M4_GPIO_CFG_RUN_Msk; while(!(LPC_CCU1->CLK_M4_GPIO_STAT & CCU1_CLK_M4_GPIO_STAT_RUN_Msk)); //Configure P6.1 as a general purpose output LPC_SCU->SFSP6_1 = 0; LPC_GPIO_PORT->DIR[3] |= (1 << 0); //Reset PHY transceiver (hard reset) LPC_GPIO_PORT->CLR[3] = (1 << 0); sleep(10); LPC_GPIO_PORT->SET[3] = (1 << 0); sleep(10); //STM32F4-DISCOVERY evaluation board? #elif defined(USE_STM32F4_DISCOVERY) GPIO_InitTypeDef GPIO_InitStructure; //Debug message TRACE_INFO("Initializing LAN8720...\r\n"); //Enable GPIOE clock RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); //Configure PE2 (PHY_RST) pin as an output GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOE, &GPIO_InitStructure); //Reset PHY transceiver (hard reset) GPIO_ResetBits(GPIOE, GPIO_Pin_2); sleep(10); GPIO_SetBits(GPIOE, GPIO_Pin_2); sleep(10); #endif //Reset PHY transceiver (soft reset) lan8720WritePhyReg(interface, LAN8720_PHY_REG_BMCR, BMCR_RESET); //Wait for the reset to complete while(lan8720ReadPhyReg(interface, LAN8720_PHY_REG_BMCR) & BMCR_RESET); //Dump PHY registers for debugging purpose lan8720DumpPhyReg(interface); //Successful initialization return NO_ERROR; }