/* Wait PHY operation complete. Return 1 if the operation completed successfully. May be need to re-implemented to reduce CPU load.  */
static unsigned char EMAC_WaitPhy(unsigned int retry)
/* Wait PHY operation complete. Return 1 if the operation completed successfully. May be need to re-implemented to reduce CPU load.  */
static unsigned char EMAC_WaitPhy(unsigned int retry)
{
    unsigned int retry_count = 0;
    while((AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE) == 0) {
        if (retry == 0) {
            continue;
        }
        retry_count++;
        if(retry_count >= retry) {
            TRACE_ERROR("E: Wait PHY time out\n\r");
            return 0;
        }
    }
    return 1;
}