/** * This function resets the device but preserves the options set by the user. * * The descriptor list could be reinitialized with the same calls to * XLlTemac_SgSetSpace() as used in main(). Doing this is a matter of preference. * In many cases, an OS may have resources tied up in the descriptors. * Reinitializing in this case may bad for the OS since its resources may be * permamently lost. * * @param TemacInstancePtr is a pointer to the instance of the Temac * component. * * @return XST_SUCCESS if successful, else XST_FAILURE. * * @note None. * ******************************************************************************/ static int TemacResetDevice(XLlTemac * TemacInstancePtr, XLlDma * DmaInstancePtr) { int Status; u8 MacSave[6]; u32 Options; //u32 RxThreshold = 1; //u32 TxThreshold = 1; //u32 RxWaitbound = 0; //u32 TxWaitbound = 0; //XLlDma_BdRing * RxRingPtr = &XLlDma_GetRxRing(DmaInstancePtr); //XLlDma_BdRing * TxRingPtr = &XLlDma_GetTxRing(DmaInstancePtr); /* * Stop LLTEMAC device */ XLlTemac_Stop(TemacInstancePtr); /* * Save the device state */ XLlTemac_GetMacAddress(TemacInstancePtr, MacSave); Options = XLlTemac_GetOptions(TemacInstancePtr); /* * Stop and reset the device */ XLlTemac_Reset(TemacInstancePtr, XTE_NORESET_HARD); /* * Restore the state */ Status = XLlTemac_SetMacAddress(TemacInstancePtr, MacSave); Status |= XLlTemac_SetOptions(TemacInstancePtr, Options); Status |= XLlTemac_ClearOptions(TemacInstancePtr, ~Options); if (Status != XST_SUCCESS) { TemacUtilErrorTrap("Error restoring state after reset"); return XST_FAILURE; } /* * Restart the device */ XLlTemac_Start(TemacInstancePtr); return XST_SUCCESS; }
/** * This function resets the device but preserves the options set by the user. * * @param None. * * @return XST_SUCCESS if successful, else XST_FAILURE. * * @note None. * ******************************************************************************/ int TemacResetDevice(void) { int Status; u8 MacSave[6]; u32 Options; /* * Stop device */ XLlTemac_Stop(&TemacInstance); /* * Save the device state */ XLlTemac_GetMacAddress(&TemacInstance, MacSave); Options = XLlTemac_GetOptions(&TemacInstance); /* * Stop and reset both the fifo and the temac the devices */ XLlFifo_Reset(&FifoInstance); XLlTemac_Reset(&TemacInstance, XTE_NORESET_HARD); /* * Restore the state */ Status = XLlTemac_SetMacAddress(&TemacInstance, MacSave); Status |= XLlTemac_SetOptions(&TemacInstance, Options); Status |= XLlTemac_ClearOptions(&TemacInstance, ~Options); if (Status != XST_SUCCESS) { TemacUtilErrorTrap("Error restoring state after reset"); return XST_FAILURE; } return XST_SUCCESS; }