static void app_low_level_init(void) { // Open uart module for debug hardware_init(); // Open ENET clock gate CLOCK_SYS_EnableEnetClock(0); // Select PTP timer outclk CLOCK_SYS_SetEnetTimeStampSrc(0, kClockTimeSrcOsc0erClk); // Disable the mpu MPU_BWR_CESR_VLD(MPU, 0); }
/*FUNCTION**************************************************************** * * Function Name: enet_mac_init * Return Value: The execution status. * Description:Initialize the ENET device with the basic configuration * When ENET is used, this function need to be called by the NET initialize * interface. *END*********************************************************************/ uint32_t enet_mac_init(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg, enet_txbd_config_t *txbdCfg) { uint32_t timeOut = 0; uint32_t devNumber, result = 0; /* Check the input parameters*/ if (enetIfPtr == NULL) { return kStatus_ENET_InvalidInput; } /* Get device number and check the parameter*/ devNumber = enetIfPtr->deviceNumber; /* Store the global ENET structure for ISR input parameters */ enetIfHandle = enetIfPtr; /* Turn on ENET module clock gate */ CLOCK_SYS_EnableEnetClock(0U); /* Reset ENET mac*/ enet_hal_reset_ethernet(devNumber); while ((!enet_hal_is_reset_completed(devNumber)) && (timeOut < kEnetMaxTimeout)) { time_delay(1); timeOut++; } /* Check out if timeout*/ if (timeOut == kEnetMaxTimeout) { return kStatus_ENET_TimeOut; } /* Disable all ENET mac interrupt and Clear all interrupt events*/ enet_hal_config_interrupt(devNumber, kEnetAllInterrupt, false); enet_hal_clear_interrupt(devNumber, kEnetAllInterrupt); /* Program this station's physical address*/ enet_hal_set_mac_address(devNumber, enetIfPtr->macCfgPtr->macAddr); /* Enable Multicast group filtering. The entry is All F because we want to listen * all multicast*/ uint32_t i = 0; for (i=0; i<=63; i++){ enet_hal_set_group_hashtable(devNumber, i<<26, kEnetSpecialAddressEnable); } /* Enable Unicast Group with 0 hash table entry. It means it * will accept only its own MAC address as the destination address if * something is received.*/ enet_hal_set_individual_hashtable(devNumber, 0, kEnetSpecialAddressInit); /* Configure mac controller*/ result = enet_mac_configure_controller(enetIfPtr); if(result != kStatus_ENET_Success) { return result; } /* Clear mib zero counters*/ enet_hal_clear_mib(devNumber, true); /* Initialize FIFO and accelerator*/ result = enet_mac_configure_fifo_accel(enetIfPtr); if(result != kStatus_ENET_Success) { return result; } /* Initialize receive buffer descriptors*/ result = enet_mac_rxbd_init(enetIfPtr, rxbdCfg); if(result != kStatus_ENET_Success) { return result; } /* Initialize transmit buffer descriptors*/ result = enet_mac_txbd_init(enetIfPtr, txbdCfg); if(result != kStatus_ENET_Success) { return result; } /* Initialize rmii/mii interface*/ result = enet_mac_mii_init(enetIfPtr); if (result != kStatus_ENET_Success) { return result; } return kStatus_ENET_Success; }