void GMACD_SetRxCallback(sGmacd * pGmacd, fGmacdTransferCallback fRxCb) { Gmac *pHw = pGmacd->pHw; if (fRxCb == NULL) { GMAC_DisableIt(pHw, GMAC_IDR_RCOMP); pGmacd->fRxCb = NULL; } else { pGmacd->fRxCb = fRxCb; GMAC_EnableIt(pHw, GMAC_IER_RCOMP); } }
void GMACD_SetRxCallback(sGmacd * pGmacd, fGmacdTransferCallback fRxCb, gmacQueList_t queIdx) { Gmac *pHw = pGmacd->pHw; if (fRxCb == NULL) { GMAC_DisableIt(pHw, GMAC_IDR_RCOMP, queIdx); pGmacd->queueList[queIdx].fRxCb = NULL; } else { pGmacd->queueList[queIdx].fRxCb = fRxCb; GMAC_EnableIt(pHw, GMAC_IER_RCOMP, queIdx); } }
/** * \brief Initialize the GMAC with the Gmac controller address * \param pGmacd Pointer to GMAC Driver instance. * \param pHw Pointer to HW address for registers. * \param bID HW ID for power management * \param enableCAF Enable/Disable CopyAllFrame. * \param enableNBC Enable/Disable NoBroadCast. */ void GMACD_Init(sGmacd *pGmacd, Gmac *pHw, uint8_t bID, uint8_t enableCAF, uint8_t enableNBC ) { uint32_t dwNcfgr; /* Check parameters */ assert(GRX_BUFFERS * GMAC_RX_UNITSIZE > GMAC_FRAME_LENTGH_MAX); TRACE_DEBUG("GMAC_Init\n\r"); /* Initialize struct */ pGmacd->pHw = pHw; pGmacd->bId = bID; /* Power ON */ PMC_EnablePeripheral(bID); /* Disable TX & RX and more */ GMAC_NetworkControl(pHw, 0); GMAC_DisableIt(pHw, ~0u); GMAC_ClearStatistics(pHw); /* Clear all status bits in the receive status register. */ GMAC_ClearRxStatus(pHw, GMAC_RSR_RXOVR | GMAC_RSR_REC | GMAC_RSR_BNA |GMAC_RSR_HNO); /* Clear all status bits in the transmit status register */ GMAC_ClearTxStatus(pHw, GMAC_TSR_UBR | GMAC_TSR_COL | GMAC_TSR_RLE | GMAC_TSR_TXGO | GMAC_TSR_TFC | GMAC_TSR_TXCOMP | GMAC_TSR_UND | GMAC_TSR_HRESP | GMAC_TSR_LCO); /* Clear interrupts */ GMAC_GetItStatus(pHw); /* Enable the copy of data into the buffers ignore broadcasts, and don't copy FCS. */ dwNcfgr = GMAC_NCFGR_FD | GMAC_NCFGR_GBE | GMAC_NCFGR_DBW_DBW64 | GMAC_NCFGR_CLK_MCK_64; if( enableCAF ) { dwNcfgr |= GMAC_NCFGR_CAF; } if( enableNBC ) { dwNcfgr |= GMAC_NCFGR_NBC; } GMAC_Configure(pHw, dwNcfgr); }