/* Initialize EMAC interface, including descriptors, MAC address, and PHY.  */
void EMAC_Open(uint8_t *pu8MacAddr)
/* Initialize EMAC interface, including descriptors, MAC address, and PHY.  */
void EMAC_Open(uint8_t *pu8MacAddr)
{
    EMAC_TxDescInit();
    EMAC_RxDescInit();
    EMAC_SetMacAddr(pu8MacAddr);
    EMAC->INTEN = EMAC_INTEN_RXIEN_Msk |
                  EMAC_INTEN_TXIEN_Msk |
                  EMAC_INTEN_RXGDIEN_Msk |
                  EMAC_INTEN_TXCPIEN_Msk |
                  EMAC_INTEN_RXBEIEN_Msk |
                  EMAC_INTEN_TXBEIEN_Msk |
                  EMAC_INTEN_RDUIEN_Msk |
                  EMAC_INTEN_TSALMIEN_Msk |
                  EMAC_INTEN_WOLIEN_Msk;
    EMAC->CTL = EMAC_CTL_STRIPCRC_Msk |
                EMAC_CTL_RMIIEN_Msk;
    EMAC->CAMCTL =  EMAC_CAMCTL_CMPEN_Msk |
                    EMAC_CAMCTL_AMP_Msk |
                    EMAC_CAMCTL_ABP_Msk;
    EMAC->MRFL = EMAC_MAX_PKT_SIZE;
}