/* Phy status update state machine */ s32_t lpc_phy_sts_sm(struct netif *netif) { static u32_t sts; s32_t changed = 0; switch (phyustate) { default: case 0: /* Read BMSR to clear faults */ lpc_mii_read_noblock(LAN8_BSR_REG); phyustate = 1; break; case 1: /* Wait for read status state */ if (!lpc_mii_is_busy()) { /* Get PHY status with link state */ sts = lpc_mii_read_data(); lpc_mii_read_noblock(LAN8_PHYSPLCTL_REG); phyustate = 2; } break; case 2: /* Wait for read status state */ if (!lpc_mii_is_busy()) { /* Update PHY status */ changed = lpc_update_phy_sts(netif, sts, lpc_mii_read_data()); phyustate = 0; } break; } return changed; }
int EthernetInterface::get_transmission_status(void) { // 1 = 1/2 duplex, 2 = full duplex uint32_t tmp = lpc_mii_read_data(); if(tmp & DP8_FULLDUPLEX) { return 2; // "FULL DUPLEX"; } else { return 1; // "HALF DUPLEX"; } }
/* Phy status update state machine */ s32_t lpc_phy_sts_sm(struct netif *netif) { s32_t changed = 0; switch (phyustate) { default: case 0: /* Read BMSR to clear faults */ lpc_mii_read_noblock(DP8_PHY_STAT_REG); phyustate = 1; break; case 1: /* Wait for read status state */ if (!lpc_mii_is_busy()) { /* Update PHY status */ changed = lpc_update_phy_sts(netif, lpc_mii_read_data()); phyustate = 0; } break; } return changed; }
uint32_t EthernetInterface::mii_read_data(void) { return lpc_mii_read_data(); // 16-bit MRDD - address 0x2008 4030 }
int EthernetInterface::get_connection_speed(void) { // 10 or 100 Mb uint32_t tmp = lpc_mii_read_data(); return (tmp & DP8_SPEED10MBPS) ? 10 : 100; }
bool EthernetInterface::is_connected(void) { uint32_t tmp = lpc_mii_read_data(); return (tmp & DP8_VALID_LINK) ? true : false; }