[ETH] Phy ID configurable as parameter

This commit is contained in:
brabo
2014-12-05 20:24:00 +01:00
committed by Frantisek Burian
parent c09d2583dd
commit 9cced2c0b4
3 changed files with 24 additions and 17 deletions

13
lib/ethernet/phy.c Normal file → Executable file
View File

@@ -40,23 +40,24 @@
/*---------------------------------------------------------------------------*/
/** @brief Is the link up ?
*
* @param[in] phy uint8_t phy ID of the PHY
* @returns bool true, if link is up
*/
bool phy_link_isup(void)
bool phy_link_isup(uint8_t phy)
{
return eth_smi_read(1, PHY_REG_BSR) & PHY_REG_BSR_UP;
return eth_smi_read(phy, PHY_REG_BSR) & PHY_REG_BSR_UP;
}
/*---------------------------------------------------------------------------*/
/** @brief Reset the PHY
*
* Reset the PHY chip and wait for done
* @param[in] phy uint8_t phy ID of the PHY
*/
void phy_reset(void)
void phy_reset(uint8_t phy)
{
eth_smi_write(1, PHY_REG_BCR, PHY_REG_BCR_RESET);
while (eth_smi_read(1, PHY_REG_BCR) & PHY_REG_BCR_RESET);
eth_smi_write(phy, PHY_REG_BCR, PHY_REG_BCR_RESET);
while (eth_smi_read(phy, PHY_REG_BCR) & PHY_REG_BCR_RESET);
}
/*---------------------------------------------------------------------------*/