Example #1
0
/* 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;
}
Example #2
0
/* Read a value via the MII link (blocking) */
err_t lpc_mii_read(u32_t PhyReg, u32_t *data) 
{
	u32_t mst = 250;
	err_t sts = ERR_OK;

	/* Read value at PHY address and register */
	lpc_mii_read_noblock(PhyReg);

	/* Wait for unbusy status */
	while (mst > 0) {
		sts = LPC_ETHERNET->MAC_MII_ADDR & MAC_MIIA_GB;
		if (sts == 0) {
			mst = 0;
			*data = LPC_ETHERNET->MAC_MII_DATA;
		} else {
			mst--;
			msDelay(1);
		}
	}

	if (sts != 0)
		sts = ERR_TIMEOUT;

	return sts;
}
Example #3
0
/* Read a value via the MII link (blocking) */
err_t lpc_mii_read(u32_t PhyReg, u32_t *data)
{		
	LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
    				("Reading MII register\r\n"));
	u32_t mst = 250;
	err_t sts = ERR_OK;

	/* Read value at PHY address and register */
	lpc_mii_read_noblock(PhyReg);

	/* Wait for unbusy status */
	while (mst > 0) {
		sts = LPC_EMAC->MIND & ~EMAC_MIND_MII_LINK_FAIL;
		if ((sts & EMAC_MIND_BUSY) == 0) {
			mst = 0;
			*data = LPC_EMAC->MRDD;
		} else {
			mst--;
			osDelay(1);
		}
	}

	LPC_EMAC->MCMD = 0;

	if (sts != 0)
		sts = ERR_TIMEOUT;

	return sts;
}
/* 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;
}