/* Read a register on MDIO bus (access to the PHY) This function is looping until PHY gets ready */
static unsigned long ulReadMDIO(volatile avr32_macb_t *macb, unsigned short usAddress)
/* Read a register on MDIO bus (access to the PHY) This function is looping until PHY gets ready */
static unsigned long ulReadMDIO(volatile avr32_macb_t *macb, unsigned short usAddress)
{
unsigned long value, status;
  macb->ncr |= AVR32_MACB_NCR_MPE_MASK;
  macb->man = (AVR32_MACB_SOF_MASK & (0x01<<AVR32_MACB_SOF_OFFSET))
            | (2 << AVR32_MACB_CODE_OFFSET)
            | (2 << AVR32_MACB_RW_OFFSET)
            | ((ETHERNET_CONF_PHY_ADDR & 0x1f) << AVR32_MACB_PHYA_OFFSET)
            | (usAddress << AVR32_MACB_REGA_OFFSET);
  do {
    status = macb->nsr;
  } while (!(status & AVR32_MACB_NSR_IDLE_MASK));
  value = macb->man & 0x0000ffff;
  macb->ncr &= ~AVR32_MACB_NCR_MPE_MASK;
  return (value);
}