Ejemplo n.º 1
0
/******************************************************************************
* Function Name: _phy_reg_set
* Description  : Sets a PHY device to read or write mode
* Arguments    : reg_addr - address of the PHY register
*              : option - mode
* Return Value : none
******************************************************************************/
void  _phy_reg_set( uint16_t reg_addr, int32_t option )
{
  int32_t    i;
  uint16_t data;

  data = 0;
  data = (PHY_ST << 14);        /* ST code    */

  if( option == PHY_READ )
  {
    data |= (PHY_READ << 12);  /* OP code(RD)  */
  }
  else
  {
    data |= (PHY_WRITE << 12);  /* OP code(WT)  */
  }

  data |= (PHY_ADDR << 7);    /* PHY Address  */
  data |= (reg_addr << 2);    /* Reg Address  */

  i = 14;
  while( i > 0 )
  {
    if( (data & 0x8000) == 0 )
    {
      _phy_mii_write_0();
    }
    else
    {
      _phy_mii_write_1();
    }
    data <<= 1;
    i--;
  }
}
Ejemplo n.º 2
0
/******************************************************************************
* Function Name: _phy_reg_write
* Description  : Writes to PHY register through MII interface
* Arguments    : data - value to write
* Return Value : none
******************************************************************************/
void  _phy_reg_write( uint16_t data )
{
  int32_t  i;

  i = 16;
  while( i > 0 )
  {
    if( (data & 0x8000) == 0 )
    {
      _phy_mii_write_0();
    }
    else
    {
      _phy_mii_write_1();
    }
    i--;
    data <<= 1;
  }
}
Ejemplo n.º 3
0
/******************************************************************************
* Function Name: _phy_reg_write
* Description  : Writes to PHY register through MII interface
* Arguments    : data - value to write
* Return Value : none
******************************************************************************/
void  _phy_reg_write( unsigned short data )
{
  long  i;

  i = 16;
  while( i > 0 )
  {
    if( (data & 0x8000) == 0 )
    {
      _phy_mii_write_0();
    }
    else
    {
      _phy_mii_write_1();
    }
    i--;
    data <<= 1;
  }
}
Ejemplo n.º 4
0
/******************************************************************************
* Function Name: _phy_ta_10
* Description  : Switches data bus so MII interface can drive data
*              : for write operation
* Arguments    : none
* Return Value : none
******************************************************************************/
void _phy_ta_10(void)
{
    _phy_mii_write_1();
    _phy_mii_write_0();
}